Documentation
¶
Overview ¶
Package revisionops holds the configuration store operations shared by the `store`/`migrate` CLI and the admin API: normalizing payloads, creating drafts, publishing, rolling back and diffing. Entry points parse arguments, check identity and format output; the rules (publishable checks, optimistic concurrency, audit) live here so both behave alike.
Index ¶
- func Diff(fromName string, from []byte, toName string, to []byte) (string, error)
- func Normalize(cfg *config.Config) ([]byte, error)
- func RawDiff(fromName string, from []byte, toName string, to []byte) (string, error)
- func Reencode(payload []byte) []byte
- type ConflictError
- type DraftRequest
- type PublishRequest
- type RollbackRequest
- type RollbackResult
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
Diff returns a unified diff of two payloads in the current encoding, so revisions stored by an older encoder differ only where their content does.
func Normalize ¶
Normalize applies the store rules to a loaded configuration and returns its payload in the deterministic encoding.
Types ¶
type ConflictError ¶
type ConflictError struct {
Expected, Published int64
}
ConflictError reports that another revision was published after the one the caller based its work on. It wraps revision.ErrConflict.
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
func (*ConflictError) Unwrap ¶
func (e *ConflictError) Unwrap() error
type DraftRequest ¶
type DraftRequest struct {
Payload []byte
// Parent is the revision the draft builds on; 0 means the published one.
Parent int64
Author, Comment string
// SkipIfPublished returns the published revision instead of a new draft
// when the payload equals it.
SkipIfPublished bool
}
DraftRequest creates a draft revision from a normalized payload.
type PublishRequest ¶
type PublishRequest struct {
ID int64
// RestartRequired allows changes that apply only after a restart.
RestartRequired bool
// ExpectedPublished, when set, is the published revision the caller
// based its work on; another one being published fails with
// *ConflictError.
ExpectedPublished *int64
Author string
}
PublishRequest publishes a draft.
type RollbackRequest ¶
type RollbackRequest struct {
// To is the revision to restore; 0 means the newest earlier published
// content.
To int64
RestartRequired bool
Author, Comment string
}
RollbackRequest restores earlier published content as a new revision.
type RollbackResult ¶
type RollbackResult struct {
// Published is the new revision; From was published before it and
// Target holds the restored content.
Published revision.Revision
From, Target int64
}
RollbackResult describes a rollback.
type Service ¶
Service runs revision operations on a store. Via names the entry point in audit records ("cli", "admin-api").
func (Service) Draft ¶
func (s Service) Draft(ctx context.Context, req DraftRequest) (rev revision.Revision, unchanged bool, err error)
Draft stores a draft. unchanged reports that SkipIfPublished applied and rev is the published revision.
func (Service) Rollback ¶
func (s Service) Rollback(ctx context.Context, req RollbackRequest) (RollbackResult, error)
Rollback checks and publishes the content of an earlier revision.