Documentation
¶
Index ¶
- Constants
- type BlockNodeRuntimeResolver
- func (b *BlockNodeRuntimeResolver) ChartName() (*automa.EffectiveValue[string], error)
- func (b *BlockNodeRuntimeResolver) ChartRef() (*automa.EffectiveValue[string], error)
- func (b *BlockNodeRuntimeResolver) ChartVersion() (*automa.EffectiveValue[string], error)
- func (b *BlockNodeRuntimeResolver) CurrentState() (state.BlockNodeState, error)
- func (b *BlockNodeRuntimeResolver) Namespace() (*automa.EffectiveValue[string], error)
- func (b *BlockNodeRuntimeResolver) RefreshState(ctx context.Context, force bool) error
- func (b *BlockNodeRuntimeResolver) ReleaseName() (*automa.EffectiveValue[string], error)
- func (b *BlockNodeRuntimeResolver) Storage() (*automa.EffectiveValue[models.BlockNodeStorage], error)
- func (b *BlockNodeRuntimeResolver) WithConfig(cfg models.Config) Resolver[state.BlockNodeState, models.BlockNodeInputs]
- func (b *BlockNodeRuntimeResolver) WithIntent(intent models.Intent) Resolver[state.BlockNodeState, models.BlockNodeInputs]
- func (b *BlockNodeRuntimeResolver) WithState(st state.BlockNodeState) Resolver[state.BlockNodeState, models.BlockNodeInputs]
- func (b *BlockNodeRuntimeResolver) WithUserInputs(inputs models.BlockNodeInputs) Resolver[state.BlockNodeState, models.BlockNodeInputs]
- type ClusterRuntimeResolver
- func (c *ClusterRuntimeResolver) CurrentState() (state.ClusterState, error)
- func (c *ClusterRuntimeResolver) RefreshState(ctx context.Context, force bool) error
- func (c *ClusterRuntimeResolver) WithConfig(cfg models.Config) Resolver[state.ClusterState, models.ClusterInputs]
- func (c *ClusterRuntimeResolver) WithIntent(intent models.Intent) Resolver[state.ClusterState, models.ClusterInputs]
- func (c *ClusterRuntimeResolver) WithState(st state.ClusterState) Resolver[state.ClusterState, models.ClusterInputs]
- func (c *ClusterRuntimeResolver) WithUserInputs(inputs models.ClusterInputs) Resolver[state.ClusterState, models.ClusterInputs]
- type MachineRuntimeResolver
- func (m *MachineRuntimeResolver) CurrentState() (state.MachineState, error)
- func (m *MachineRuntimeResolver) RefreshState(ctx context.Context, force bool) error
- func (c *MachineRuntimeResolver) WithConfig(cfg models.Config) Resolver[state.MachineState, models.MachineInputs]
- func (c *MachineRuntimeResolver) WithIntent(intent models.Intent) Resolver[state.MachineState, models.MachineInputs]
- func (c *MachineRuntimeResolver) WithState(st state.MachineState) Resolver[state.MachineState, models.MachineInputs]
- func (c *MachineRuntimeResolver) WithUserInputs(inputs models.MachineInputs) Resolver[state.MachineState, models.MachineInputs]
- type Resolver
- func NewBlockNodeRuntimeResolver(cfg models.Config, blockNodeState state.BlockNodeState, ...) (Resolver[state.BlockNodeState, models.BlockNodeInputs], error)
- func NewClusterRuntimeResolver(cfg models.Config, clusterState state.ClusterState, ...) (Resolver[state.ClusterState, models.ClusterInputs], error)
- func NewMachineRuntimeResolver(cfg models.Config, clusterState state.MachineState, ...) (Resolver[state.MachineState, models.MachineInputs], error)
- type RuntimeResolver
Constants ¶
const DefaultRefreshInterval = 10 * time.Minute
DefaultRefreshInterval is the default duration after which the resolver should refresh its state from the reality checker. This is a balance between ensuring reasonably fresh state and avoiding excessive calls to the reality checker, which may be expensive or rate-limited.
const DefaultRefreshTimeout = 60 * time.Second
DefaultRefreshTimeout is the default timeout for state refresh operations, which may involve calls to external systems and should not be allowed to run indefinitely.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockNodeRuntimeResolver ¶
type BlockNodeRuntimeResolver struct {
// contains filtered or unexported fields
}
BlockNodeRuntimeResolver manages the current state of block-node related information, including configuration, user inputs, and reality-checked state.
Resolution strategy (highest -> lowest precedence): 1. Current state (automa.StrategyCurrent)
- If `br.state != nil` and `br.state.ReleaseInfo.Status == release.StatusDeployed`, the resolver returns the value from `br.state`.
- For string fields the deployed state is validated to be non-empty; an empty value for a deployed release results in an `errorx.IllegalState` error.
2. User inputs (automa.StrategyUserInput)
- If no valid deployed current state is available and `br.inputs != nil` (and for strings the input is non-empty), the resolver returns the user-provided value.
3. Config defaults (automa.StrategyConfig)
- If neither current state nor user inputs supply a value, the resolver returns the config default value.
Notes:
- Returned values are `*automa.EffectiveValue[T]` carrying the chosen value and the strategy indicating its source.
- Structured types (e.g. `models.BlockNodeStorage`) follow the same precedence but do not perform non-empty string validation.
- Helper methods `WithUserInputs`, `WithConfig`, and `WithState` set the resolver's sources so resolution uses those values.
- The resolver relies on the runtime base for reality checking, last-sync extraction, cloning and default state construction.
func (*BlockNodeRuntimeResolver) ChartName ¶
func (b *BlockNodeRuntimeResolver) ChartName() (*automa.EffectiveValue[string], error)
func (*BlockNodeRuntimeResolver) ChartRef ¶
func (b *BlockNodeRuntimeResolver) ChartRef() (*automa.EffectiveValue[string], error)
func (*BlockNodeRuntimeResolver) ChartVersion ¶
func (b *BlockNodeRuntimeResolver) ChartVersion() (*automa.EffectiveValue[string], error)
ChartVersion resolves the effective chart version for the block node based on the following precedence: 1. If the current state indicates a deployed release and the intent is an upgrade, the resolver checks for a user-provided chart version in the inputs. If provided, this takes precedence. 2. If no user input is provided for the chart version during an upgrade intent, but the current deployed state has a version, that version is used next. 3. If neither of the above provide a chart version during an upgrade intent, the resolver falls back to the config default. 4. For non-upgrade intents, if the current state indicates a deployed release, the chart version from the deployed state is used and cannot be overridden by user input or config. 5. If there is no deployed release, but user input provides a chart version, that is used next. 6. Finally, if none of the above sources provide a chart version, the resolver returns the config default.
This resolution strategy ensures that during an upgrade, user input can specify a new chart version, but if not provided, the system retains the currently deployed version. For non-upgrade actions, the deployed version is authoritative if it exists, preventing unintended changes to the chart version.
func (*BlockNodeRuntimeResolver) CurrentState ¶
func (b *BlockNodeRuntimeResolver) CurrentState() (state.BlockNodeState, error)
func (*BlockNodeRuntimeResolver) Namespace ¶
func (b *BlockNodeRuntimeResolver) Namespace() (*automa.EffectiveValue[string], error)
func (*BlockNodeRuntimeResolver) RefreshState ¶
func (b *BlockNodeRuntimeResolver) RefreshState(ctx context.Context, force bool) error
func (*BlockNodeRuntimeResolver) ReleaseName ¶
func (b *BlockNodeRuntimeResolver) ReleaseName() (*automa.EffectiveValue[string], error)
func (*BlockNodeRuntimeResolver) Storage ¶
func (b *BlockNodeRuntimeResolver) Storage() (*automa.EffectiveValue[models.BlockNodeStorage], error)
func (*BlockNodeRuntimeResolver) WithConfig ¶
func (b *BlockNodeRuntimeResolver) WithConfig(cfg models.Config) Resolver[state.BlockNodeState, models.BlockNodeInputs]
func (*BlockNodeRuntimeResolver) WithIntent ¶
func (b *BlockNodeRuntimeResolver) WithIntent(intent models.Intent) Resolver[state.BlockNodeState, models.BlockNodeInputs]
func (*BlockNodeRuntimeResolver) WithState ¶
func (b *BlockNodeRuntimeResolver) WithState(st state.BlockNodeState) Resolver[state.BlockNodeState, models.BlockNodeInputs]
func (*BlockNodeRuntimeResolver) WithUserInputs ¶
func (b *BlockNodeRuntimeResolver) WithUserInputs(inputs models.BlockNodeInputs) Resolver[state.BlockNodeState, models.BlockNodeInputs]
type ClusterRuntimeResolver ¶
type ClusterRuntimeResolver struct {
// contains filtered or unexported fields
}
func (*ClusterRuntimeResolver) CurrentState ¶
func (c *ClusterRuntimeResolver) CurrentState() (state.ClusterState, error)
func (*ClusterRuntimeResolver) RefreshState ¶
func (c *ClusterRuntimeResolver) RefreshState(ctx context.Context, force bool) error
RefreshState refreshes the current state using the configured reality checker. It respects refreshInterval by comparing against the concrete ClusterState.LastSync field rather than using an injected helper.
func (*ClusterRuntimeResolver) WithConfig ¶
func (c *ClusterRuntimeResolver) WithConfig(cfg models.Config) Resolver[state.ClusterState, models.ClusterInputs]
func (*ClusterRuntimeResolver) WithIntent ¶
func (c *ClusterRuntimeResolver) WithIntent(intent models.Intent) Resolver[state.ClusterState, models.ClusterInputs]
func (*ClusterRuntimeResolver) WithState ¶
func (c *ClusterRuntimeResolver) WithState(st state.ClusterState) Resolver[state.ClusterState, models.ClusterInputs]
func (*ClusterRuntimeResolver) WithUserInputs ¶
func (c *ClusterRuntimeResolver) WithUserInputs(inputs models.ClusterInputs) Resolver[state.ClusterState, models.ClusterInputs]
type MachineRuntimeResolver ¶
type MachineRuntimeResolver struct {
// contains filtered or unexported fields
}
func (*MachineRuntimeResolver) CurrentState ¶
func (m *MachineRuntimeResolver) CurrentState() (state.MachineState, error)
func (*MachineRuntimeResolver) RefreshState ¶
func (m *MachineRuntimeResolver) RefreshState(ctx context.Context, force bool) error
RefreshState refreshes the current machine state from the reality checker, using the concrete MachineState.LastSync to apply refresh interval checks.
func (*MachineRuntimeResolver) WithConfig ¶
func (c *MachineRuntimeResolver) WithConfig(cfg models.Config) Resolver[state.MachineState, models.MachineInputs]
func (*MachineRuntimeResolver) WithIntent ¶
func (c *MachineRuntimeResolver) WithIntent(intent models.Intent) Resolver[state.MachineState, models.MachineInputs]
func (*MachineRuntimeResolver) WithState ¶
func (c *MachineRuntimeResolver) WithState(st state.MachineState) Resolver[state.MachineState, models.MachineInputs]
func (*MachineRuntimeResolver) WithUserInputs ¶
func (c *MachineRuntimeResolver) WithUserInputs(inputs models.MachineInputs) Resolver[state.MachineState, models.MachineInputs]
type Resolver ¶
type Resolver[S any, I any] interface { WithIntent(intent models.Intent) Resolver[S, I] WithUserInputs(inputs I) Resolver[S, I] WithConfig(cfg models.Config) Resolver[S, I] WithState(blockNodeState S) Resolver[S, I] RefreshState(ctx context.Context, force bool) error CurrentState() (S, error) }
func NewBlockNodeRuntimeResolver ¶
func NewBlockNodeRuntimeResolver( cfg models.Config, blockNodeState state.BlockNodeState, realityChecker reality.Checker[state.BlockNodeState], refreshInterval time.Duration, ) (Resolver[state.BlockNodeState, models.BlockNodeInputs], error)
func NewClusterRuntimeResolver ¶
func NewClusterRuntimeResolver( cfg models.Config, clusterState state.ClusterState, realityChecker reality.Checker[state.ClusterState], refreshInterval time.Duration, ) (Resolver[state.ClusterState, models.ClusterInputs], error)
NewClusterRuntimeResolver creates a ClusterRuntime with the provided configuration, initial state, reality checker, and refresh interval. The caller is responsible for retaining and injecting the returned instance — no package-level singleton is used.
func NewMachineRuntimeResolver ¶
func NewMachineRuntimeResolver( cfg models.Config, clusterState state.MachineState, realityChecker reality.Checker[state.MachineState], refreshInterval time.Duration, ) (Resolver[state.MachineState, models.MachineInputs], error)
NewMachineRuntimeResolver creates a MachineRuntimeResolver with the provided configuration, initial state, reality checker, and refresh interval. The caller is responsible for retaining and injecting the returned instance — no package-level singleton is used.
type RuntimeResolver ¶
type RuntimeResolver struct {
BlockNodeRuntime Resolver[state.BlockNodeState, models.BlockNodeInputs]
ClusterRuntime Resolver[state.ClusterState, models.ClusterInputs]
MachineRuntime Resolver[state.MachineState, models.MachineInputs]
// contains filtered or unexported fields
}
RuntimeResolver holds the fully-initialised runtime components for all node types. It is constructed once at the composition root (main / command init) and injected into every layer that needs it, eliminating package-level singletons.
func NewRuntimeResolver ¶
func NewRuntimeResolver( cfg models.Config, sm state.Manager, realityChecker reality.Checkers, refreshInterval time.Duration, ) (*RuntimeResolver, error)
NewRuntimeResolver creates a RuntimeResolver by constructing each runtime from the supplied configuration, current persisted state, reality checker, and refresh interval.
func (*RuntimeResolver) AddActionHistory ¶
func (r *RuntimeResolver) AddActionHistory(entry state.ActionHistory) state.Writer
func (*RuntimeResolver) CurrentState ¶
func (r *RuntimeResolver) CurrentState() (state.State, error)
CurrentState reads the current state from all runtimes and composes it into a single state.State struct. This is the single source of truth for all state reads in the CLI layer, ensuring that all reads are consistent and reflect the latest reality state (subject to each runtime's staleness checks). Ensure to call Refresh() before this to ensure that all runtimes have the latest reality state
func (*RuntimeResolver) FlushAll ¶
func (r *RuntimeResolver) FlushAll(currentState state.State) error