Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCommand ¶
NewCommand builds the simulate parent command and its subcommands.
Types ¶
type Action ¶
type Action interface {
// Name is a short identifier for the action (for example "promote").
Name() string
// Describe returns a one-line human-readable summary of the action.
Describe() string
// Apply replays the action against the clone manifest and returns the
// effects plus the after-state path.
Apply(ctx ActionContext) (*ActionOutcome, error)
}
Action is a hypothetical operation the what-if engine can replay against a cloned manifest. Implementations drive the real orchestration logic in record-only mode and report the effects it would produce.
type ActionContext ¶
type ActionContext struct {
// ClonePath is the path to the temp clone of the manifest the action may
// mutate. The real promoter writes its transitions here.
ClonePath string
// Actor is the identity that performs the hypothetical action.
Actor string
}
ActionContext carries the inputs an Action needs to replay orchestration against the cloned manifest. ClonePath points at the temp copy of the user's manifest; the real file is never handed to an action.
type ActionOutcome ¶
type ActionOutcome struct {
// Effects is the ordered list of steps the orchestration would take.
Effects []Effect
// AfterStatePath is the manifest path holding the after-state.
AfterStatePath string
}
ActionOutcome is what an Action returns after replaying orchestration. It carries the ordered effects plus the path holding the resolved after-state (the clone path, since the real promoter writes there).
type DeployDiff ¶
type DeployDiff struct {
Name string `json:"name"`
SHA FieldChange `json:"sha"`
Version FieldChange `json:"version"`
}
DeployDiff captures the field changes for a single named deploy within an environment.
type Disposition ¶
type Disposition string
Disposition classifies how the orchestration treats a single effect when the hypothetical action is replayed in record-only mode.
const ( // DispositionRun marks an effect the orchestration would carry out. DispositionRun Disposition = "run" // DispositionSkip marks an effect the orchestration would skip as a no-op. DispositionSkip Disposition = "skip" // DispositionGate marks an effect held back behind a gate or guard. DispositionGate Disposition = "gate" )
type Effect ¶
type Effect struct {
Disposition Disposition `json:"disposition"`
Action string `json:"action"`
Target string `json:"target"`
Detail string `json:"detail"`
}
Effect is one ordered step the orchestration would take for the simulated action. It carries the disposition (run, skip, or gate), the kind of action, the target it acts on, and a human-readable detail string.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine runs hypothetical actions against a clone of the user's manifest and reports the resulting state diff and effect sequence. It never mutates the user's real manifest and never touches git or the network.
type EnvDiff ¶
type EnvDiff struct {
Environment string `json:"environment"`
Version FieldChange `json:"version"`
SHA FieldChange `json:"sha"`
Divergence FieldChange `json:"divergence"`
PreviousRing FieldChange `json:"previous_ring"`
Deploys []DeployDiff `json:"deploys,omitempty"`
}
EnvDiff captures the field-by-field changes for a single environment. The run-stamped CommittedAt and CommittedBy fields are deliberately excluded: timestamps are run-stamped and not part of the what-if outcome.
type FieldChange ¶
type FieldChange struct {
Field string `json:"field"`
From string `json:"from"`
To string `json:"to"`
Changed bool `json:"changed"`
}
FieldChange records a single field transitioning from one value to another. Changed is true only when From and To differ.
type PromoteAction ¶
type PromoteAction struct {
// contains filtered or unexported fields
}
PromoteAction replays the real promotion orchestration against a cloned manifest. It drives promote.NewPromoter in non-dry-run mode so the genuine state-machine computes transitions and writes them to the clone only.
func NewPromoteAction ¶
func NewPromoteAction(mode promote.PromotionMode, target string) *PromoteAction
NewPromoteAction builds a PromoteAction for the given promotion mode and target. The target is only consulted for cascade mode.
func (*PromoteAction) Apply ¶
func (a *PromoteAction) Apply(ctx ActionContext) (*ActionOutcome, error)
Apply runs the real promoter against the clone manifest in non-dry-run mode and maps the returned PromotionResult into an ordered effect sequence. The promoter writes its transitions to the clone path via os.WriteFile only; no git or network call is made.
func (*PromoteAction) Describe ¶
func (a *PromoteAction) Describe() string
Describe returns a one-line summary of the promotion being simulated.
func (*PromoteAction) Name ¶
func (a *PromoteAction) Name() string
Name returns the action identifier.
type Result ¶
type Result struct {
// ActionName is the short identifier of the simulated action.
ActionName string `json:"action"`
// ActionDescribe is the one-line human-readable summary of the action.
ActionDescribe string `json:"describe"`
// Diff is the before and after state difference.
Diff StateDiff `json:"diff"`
// Effects is the ordered list of orchestration steps.
Effects []Effect `json:"effects"`
}
Result is the outcome of one simulation: the action identity, the before and after state diff, and the ordered effect sequence.
func (*Result) RenderHuman ¶
RenderHuman writes a human-readable report of the simulation to w. The output is deterministic: environment keys are sorted and run-stamped timestamps are excluded from the diff.
type StateDiff ¶
type StateDiff struct {
// Envs holds the per-environment diffs in sorted-key order.
Envs []EnvDiff `json:"envs"`
}
StateDiff is the difference between a before and after manifest state, keyed by environment name in deterministic (sorted) order.
func DiffState ¶
DiffState computes the StateDiff between before and after environment states. Environment keys are sorted for deterministic output. Run-stamped timestamps (CommittedAt, CommittedBy) are ignored so output stays stable across runs.