Documentation
¶
Index ¶
- Constants
- func CheckWorkflowReport(ctx context.Context, report *automa.Report)
- func DefaultRunE(cmd *cobra.Command, args []string) error
- func DetectShortNameCollisions(root *cobra.Command) bool
- func ExtractRootFlags(cmd *cobra.Command, args []string, flags *RootFlags) error
- func GetExecutionMode(continueOnErr bool, stopOnErr bool, rollbackOnErr bool) (automa.TypeMode, error)
- func RequireGlobalChecks(cmd *cobra.Command) bool
- func RunPersistentPreRun(cmd *cobra.Command, args []string) error
- func RunStartupMigrations(ctx context.Context) error
- func RunWorkflow(ctx context.Context, fn func() (*automa.Report, error))
- func RunWorkflowBuilder(ctx context.Context, b automa.Builder)
- func SkipGlobalChecks(cmd *cobra.Command)
- type CountFlagDefinition
- type FlagDefinition
- func FlagConfig() FlagDefinition[string]
- func FlagContinueOnError() FlagDefinition[bool]
- func FlagForce() FlagDefinition[bool]
- func FlagLogLevel() FlagDefinition[string]
- func FlagMetricsServer() FlagDefinition[bool]
- func FlagNoReuseValues() FlagDefinition[bool]
- func FlagNodeType() FlagDefinition[string]
- func FlagNonInteractive() FlagDefinition[bool]
- func FlagOutputFormat() FlagDefinition[string]
- func FlagProfile() FlagDefinition[string]
- func FlagRollbackOnError() FlagDefinition[bool]
- func FlagSkipHardwareChecks() FlagDefinition[bool]
- func FlagStopOnError() FlagDefinition[bool]
- func FlagValuesFile() FlagDefinition[string]
- func FlagVersion() FlagDefinition[bool]
- func FlagWithStorageReset() FlagDefinition[bool]
- func (fp FlagDefinition[T]) Clone() FlagDefinition[T]
- func (fp FlagDefinition[T]) MarkRequired(cmd *cobra.Command, v bool) error
- func (fp FlagDefinition[T]) MarkRequiredP(cmd *cobra.Command, v bool) error
- func (fp FlagDefinition[T]) SetVar(cmd *cobra.Command, p *T, required bool)
- func (fp FlagDefinition[T]) SetVarP(cmd *cobra.Command, p *T, required bool)
- func (fp FlagDefinition[T]) Value(cmd *cobra.Command, args []string) (T, error)
- func (fp FlagDefinition[T]) ValueLocal(cmd *cobra.Command, args []string) (T, error)
- func (fp FlagDefinition[T]) ValueOwnPersistent(cmd *cobra.Command, args []string) (T, error)
- type RootFlags
- type SetupResult
Constants ¶
const KeyRequireGlobalChecks = "requireGlobalChecks"
Variables ¶
This section is empty.
Functions ¶
func CheckWorkflowReport ¶ added in v0.12.0
CheckWorkflowReport checks for errors, saves the YAML report, and prints a compact summary. Exported for commands that handle reports outside RunWorkflow (e.g. block node install/upgrade/reset).
func DefaultRunE ¶
DefaultRunE is a default RunE function that shows help message and provides a placeholder to add common behaviour. We always add a run function to commands to ensure cobra marks it as Runnable and allows our commands to invoke PersistentPreRunE functions of the root command.
func DetectShortNameCollisions ¶ added in v0.12.0
func ExtractRootFlags ¶ added in v0.12.0
ExtractRootFlags extracts the flags registered on the root command. Config and logging are already initialized by root.go's initConfig (via cobra.OnInitialize).
func GetExecutionMode ¶ added in v0.7.0
func GetExecutionMode(continueOnErr bool, stopOnErr bool, rollbackOnErr bool) (automa.TypeMode, error)
GetExecutionMode determines the execution mode based on the provided flags. It ensures that only one of the flags is set; otherwise, it returns an error. The precedence is as follows: 1. continueOnErr 2. rollbackOnErr 3. stopOnErr (default)
func RequireGlobalChecks ¶
RequireGlobalChecks checks if a command requires global pre-run checks. By default, commands require global checks unless explicitly marked to skip them.
func RunPersistentPreRun ¶ added in v0.16.0
RunPersistentPreRun is the body of the root PersistentPreRunE hook. It runs before every command and is responsible for:
- Verifying the weaver installation (skipped for commands that opt out via SkipGlobalChecks).
- Running any pending startup migrations.
func RunStartupMigrations ¶ added in v0.14.0
RunStartupMigrations runs a single ordered pass over all startup-scoped migrations. It is a no-op when no migrations apply.
func RunWorkflow ¶
RunWorkflow executes a workflow function and renders progress via Bubble Tea with spinners and status icons, or raw zerolog output when --non-interactive is set.
func RunWorkflowBuilder ¶ added in v0.15.0
RunWorkflowBuilder is a convenience wrapper that builds an automa workflow and runs it via RunWorkflow.
func SkipGlobalChecks ¶
SkipGlobalChecks marks a command to skip global pre-run checks. This is useful for commands like 'install' that need to run before any checks can be performed. It sets the annotation "requireGlobalChecks" to "false".
Types ¶
type CountFlagDefinition ¶ added in v0.16.0
CountFlagDefinition defines a count-style persistent flag (e.g. -V -V → 2). It is separate from FlagDefinition[int] because pflag registers count flags with type "count" and requires CountVarP/GetCount rather than IntVarP/GetInt.
func FlagVerbose ¶ added in v0.16.0
func FlagVerbose() CountFlagDefinition
type FlagDefinition ¶ added in v0.7.0
FlagDefinition defines a command-line flag typed by T.
func FlagConfig ¶ added in v0.12.0
func FlagConfig() FlagDefinition[string]
func FlagContinueOnError ¶ added in v0.7.0
func FlagContinueOnError() FlagDefinition[bool]
func FlagForce ¶ added in v0.12.0
func FlagForce() FlagDefinition[bool]
func FlagLogLevel ¶ added in v0.12.0
func FlagLogLevel() FlagDefinition[string]
func FlagMetricsServer ¶ added in v0.7.0
func FlagMetricsServer() FlagDefinition[bool]
func FlagNoReuseValues ¶ added in v0.12.0
func FlagNoReuseValues() FlagDefinition[bool]
func FlagNodeType ¶ added in v0.7.0
func FlagNodeType() FlagDefinition[string]
func FlagNonInteractive ¶ added in v0.16.0
func FlagNonInteractive() FlagDefinition[bool]
func FlagOutputFormat ¶ added in v0.12.0
func FlagOutputFormat() FlagDefinition[string]
func FlagProfile ¶ added in v0.7.0
func FlagProfile() FlagDefinition[string]
func FlagRollbackOnError ¶ added in v0.7.0
func FlagRollbackOnError() FlagDefinition[bool]
func FlagSkipHardwareChecks ¶ added in v0.9.0
func FlagSkipHardwareChecks() FlagDefinition[bool]
FlagSkipHardwareChecks is a hidden persistent flag registered on the root command. When set, it skips CPU, memory, and storage validation in NewNodeSafetyCheckWorkflow (see internal/workflows/preflight.go). Privilege, user, and host profile checks still run. This flag is intentionally not supported by the "check" command since its purpose is to validate hardware requirements.
Used by: block node install, kube cluster install. Registered in: cmd/weaver/commands/root.go (hidden). See docs/dev/hidden-flags.md for full documentation.
func FlagStopOnError ¶ added in v0.7.0
func FlagStopOnError() FlagDefinition[bool]
func FlagValuesFile ¶ added in v0.7.0
func FlagValuesFile() FlagDefinition[string]
func FlagVersion ¶ added in v0.12.0
func FlagVersion() FlagDefinition[bool]
func FlagWithStorageReset ¶ added in v0.12.0
func FlagWithStorageReset() FlagDefinition[bool]
func (FlagDefinition[T]) Clone ¶ added in v0.12.0
func (fp FlagDefinition[T]) Clone() FlagDefinition[T]
Clone returns an independent copy of the descriptor. Useful when you need a local variant with a different default or description.
func (FlagDefinition[T]) MarkRequired ¶ added in v0.7.0
func (fp FlagDefinition[T]) MarkRequired(cmd *cobra.Command, v bool) error
func (FlagDefinition[T]) MarkRequiredP ¶ added in v0.7.0
func (fp FlagDefinition[T]) MarkRequiredP(cmd *cobra.Command, v bool) error
func (FlagDefinition[T]) SetVar ¶ added in v0.7.0
func (fp FlagDefinition[T]) SetVar(cmd *cobra.Command, p *T, required bool)
SetVar sets up the non-persistent flag and exits on error.
func (FlagDefinition[T]) SetVarP ¶ added in v0.7.0
func (fp FlagDefinition[T]) SetVarP(cmd *cobra.Command, p *T, required bool)
SetVarP sets up the persistent flag and exits on error.
func (FlagDefinition[T]) Value ¶ added in v0.7.0
func (fp FlagDefinition[T]) Value(cmd *cobra.Command, args []string) (T, error)
Value resolves a flag value using the following precedence:
- Local (non-persistent) flags on this command
- Own persistent flags on this command (defined via SetVarP on this command directly)
- Persistent flags inherited from parent/root commands (merged by Cobra via ParseFlags)
Use ValueLocal() or ValueOwnPersistent() if you need strict single-scope semantics.
func (FlagDefinition[T]) ValueLocal ¶ added in v0.12.0
func (fp FlagDefinition[T]) ValueLocal(cmd *cobra.Command, args []string) (T, error)
func (FlagDefinition[T]) ValueOwnPersistent ¶ added in v0.12.0
func (fp FlagDefinition[T]) ValueOwnPersistent(cmd *cobra.Command, args []string) (T, error)
ValueOwnPersistent reads the value of a persistent flag defined directly on this command (via SetVarP). It does NOT search ancestor/parent commands.
Use Value() if you want the full resolution chain (local → own persistent → inherited persistent). Use ValueLocal() if you want only local (non-persistent) flags on this command.
type RootFlags ¶ added in v0.12.0
RootFlags contains the flags registered on the root command and available to every subcommand via persistent inheritance.
type SetupResult ¶ added in v0.16.0
type SetupResult struct {
Config models.Config
StateManager state.Manager
RealityChecker reality.Checkers
Runtime *rsl.RuntimeResolver
}
func Setup ¶ added in v0.16.0
func Setup() (*SetupResult, error)
Setup performs the common setup steps for all commands. It includes loading configuration, initializing the state manager, reality checker and runtime resolver