common

package
v0.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const KeyRequireGlobalChecks = "requireGlobalChecks"

Variables

This section is empty.

Functions

func DefaultRunE

func DefaultRunE(cmd *cobra.Command, args []string) error

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

func DetectShortNameCollisions(root *cobra.Command) bool

func ExtractRootFlags

func ExtractRootFlags(cmd *cobra.Command, args []string, flags *RootFlags) error

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

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

func RequireGlobalChecks(cmd *cobra.Command) bool

RequireGlobalChecks checks if a command requires global pre-run checks. By default, commands require global checks unless explicitly marked to skip them.

func RunPersistentPreRun

func RunPersistentPreRun(cmd *cobra.Command, args []string) error

RunPersistentPreRun is the body of the root PersistentPreRunE hook. It runs before every command and is responsible for:

  1. Verifying the weaver installation (skipped for commands that opt out via SkipGlobalChecks).
  2. Running any pending startup migrations.

func RunStartupMigrations

func RunStartupMigrations(ctx context.Context) error

RunStartupMigrations runs a single ordered pass over all startup-scoped migrations. It is a no-op when no migrations apply.

func RunWorkflow

func RunWorkflow(ctx context.Context, fn func() (*automa.Report, error)) error

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. It returns the first error encountered (workflow execution error or step failure) so cobra RunE handlers can propagate it to the top-level error handler in main.go.

func RunWorkflowBuilder

func RunWorkflowBuilder(ctx context.Context, b automa.Builder) error

RunWorkflowBuilder is a convenience wrapper that builds an automa workflow and runs it via RunWorkflow.

func SkipGlobalChecks

func SkipGlobalChecks(cmd *cobra.Command)

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 CommaSplitStringsFlagDefinition

type CommaSplitStringsFlagDefinition struct {
	Name        string
	ShortName   string
	Description string
	Default     []string
}

CommaSplitStringsFlagDefinition defines a []string flag whose values are comma-split at parse time: --items a,b,c yields []string{"a", "b", "c"}. Backed by pflag's StringSliceVarP / GetStringSlice. Use this when each value is a simple token with no embedded commas.

For values that themselves contain commas (e.g. a structured spec like "name=x,url=y"), use RepeatableStringFlagDefinition instead.

func (CommaSplitStringsFlagDefinition) Clone

Clone returns an independent copy of the descriptor.

func (CommaSplitStringsFlagDefinition) MarkRequired

func (fp CommaSplitStringsFlagDefinition) MarkRequired(cmd *cobra.Command, v bool) error

func (CommaSplitStringsFlagDefinition) MarkRequiredP

func (fp CommaSplitStringsFlagDefinition) MarkRequiredP(cmd *cobra.Command, v bool) error

func (CommaSplitStringsFlagDefinition) SetVar

func (fp CommaSplitStringsFlagDefinition) SetVar(cmd *cobra.Command, p *[]string, required bool)

func (CommaSplitStringsFlagDefinition) SetVarP

func (fp CommaSplitStringsFlagDefinition) SetVarP(cmd *cobra.Command, p *[]string, required bool)

func (CommaSplitStringsFlagDefinition) SetVarPHidden

func (fp CommaSplitStringsFlagDefinition) SetVarPHidden(cmd *cobra.Command, p *[]string, required bool)

func (CommaSplitStringsFlagDefinition) Value

func (fp CommaSplitStringsFlagDefinition) Value(cmd *cobra.Command, args []string) ([]string, error)

Value mirrors FlagDefinition[T].Value: local → own persistent → inherited persistent.

func (CommaSplitStringsFlagDefinition) ValueLocal

func (fp CommaSplitStringsFlagDefinition) ValueLocal(cmd *cobra.Command, args []string) ([]string, error)

func (CommaSplitStringsFlagDefinition) ValueOwnPersistent

func (fp CommaSplitStringsFlagDefinition) ValueOwnPersistent(cmd *cobra.Command, args []string) ([]string, error)

type CountFlagDefinition

type CountFlagDefinition struct {
	Name        string
	ShortName   string
	Description string
}

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

func FlagVerbose() CountFlagDefinition

func (CountFlagDefinition) SetVarP

func (f CountFlagDefinition) SetVarP(cmd *cobra.Command, p *int)

SetVarP registers the flag as a persistent count flag on the given command.

func (CountFlagDefinition) Value

func (f CountFlagDefinition) Value(cmd *cobra.Command, args []string) (int, error)

Value reads the current count value from the command's merged flag set.

type FlagDefinition

type FlagDefinition[T any] struct {
	Name        string
	ShortName   string
	Description string
	Default     T
}

FlagDefinition defines a command-line flag typed by T.

func FlagAlloyClusterSecretStore

func FlagAlloyClusterSecretStore() FlagDefinition[string]

func FlagApplicationStatePath added in v0.21.0

func FlagApplicationStatePath() FlagDefinition[string]

func FlagApplicationStateSize added in v0.21.0

func FlagApplicationStateSize() FlagDefinition[string]

func FlagArchivePath

func FlagArchivePath() FlagDefinition[string]

func FlagArchiveSize

func FlagArchiveSize() FlagDefinition[string]

func FlagBasePath

func FlagBasePath() FlagDefinition[string]

func FlagChartRepo

func FlagChartRepo() FlagDefinition[string]

func FlagClusterName

func FlagClusterName() FlagDefinition[string]

func FlagConfig

func FlagConfig() FlagDefinition[string]

func FlagContinueOnError

func FlagContinueOnError() FlagDefinition[bool]

func FlagDaemonBNOrbit added in v0.20.0

func FlagDaemonBNOrbit() FlagDefinition[string]

FlagDaemonBNOrbit is the Kubernetes namespace (orbit) for the block-node component written into daemon.yaml. Required when daemon.yaml does not already exist and block-node is enabled.

func FlagDaemonBin added in v0.20.0

func FlagDaemonBin() FlagDefinition[string]

FlagDaemonBin is the optional path to a locally-built solo-provisioner-daemon binary. When omitted the binary is auto-downloaded from the official GitHub Releases URL embedded in the infrastructure catalog.

func FlagDaemonCNNodeID added in v0.20.0

func FlagDaemonCNNodeID() FlagDefinition[string]

FlagDaemonCNNodeID is the numeric node identifier written into daemon.yaml as the consensus-node node_id. Required when daemon.yaml does not already exist and consensus-node is enabled.

func FlagDaemonCNOrbit added in v0.20.0

func FlagDaemonCNOrbit() FlagDefinition[string]

FlagDaemonCNOrbit is the Kubernetes namespace (orbit) for the consensus-node component written into daemon.yaml. Required when daemon.yaml does not already exist and consensus-node is enabled.

func FlagDaemonCNUpgradeDir added in v0.20.0

func FlagDaemonCNUpgradeDir() FlagDefinition[string]

FlagDaemonCNUpgradeDir is an optional override for the consensus-node upgrade staging directory. Defaults to /opt/hgcapp/services-hedera/HapiApp2.0/data/upgrade/current.

func FlagDaemonChecksum added in v0.20.0

func FlagDaemonChecksum() FlagDefinition[string]

FlagDaemonChecksum is an optional sha256 hex digest used to verify a binary supplied via --daemon-bin. Ignored when --daemon-bin is not set (the catalog checksum is used for auto-downloaded binaries).

func FlagDaemonComponents added in v0.20.0

func FlagDaemonComponents() FlagDefinition[string]

FlagDaemonComponents selects which daemon components to enable. Accepts a comma-separated list of component names: "consensus-node", "block-node". When omitted the operator is prompted interactively.

func FlagDaemonFromConfig added in v0.20.0

func FlagDaemonFromConfig() FlagDefinition[string]

FlagDaemonFromConfig is an optional path to an existing daemon.yaml to copy into place before running the install workflow.

func FlagForce

func FlagForce() FlagDefinition[bool]

func FlagHistoricRetention

func FlagHistoricRetention() FlagDefinition[string]

func FlagLivePath

func FlagLivePath() FlagDefinition[string]

func FlagLiveSize

func FlagLiveSize() FlagDefinition[string]

func FlagLoadBalancerEnabled

func FlagLoadBalancerEnabled() FlagDefinition[bool]

func FlagLogLevel

func FlagLogLevel() FlagDefinition[string]

func FlagLogPath

func FlagLogPath() FlagDefinition[string]

func FlagLogSize

func FlagLogSize() FlagDefinition[string]

func FlagLokiURL

func FlagLokiURL() FlagDefinition[string]

func FlagLokiUsername

func FlagLokiUsername() FlagDefinition[string]

func FlagMetricsServer

func FlagMetricsServer() FlagDefinition[bool]

func FlagMonitorBlockNode

func FlagMonitorBlockNode() FlagDefinition[bool]

func FlagNamespace

func FlagNamespace() FlagDefinition[string]

func FlagNoRestart

func FlagNoRestart() FlagDefinition[bool]

func FlagNoReuseValues

func FlagNoReuseValues() FlagDefinition[bool]

func FlagNodeType

func FlagNodeType() FlagDefinition[string]

func FlagNonInteractive

func FlagNonInteractive() FlagDefinition[bool]

func FlagOutputFormat

func FlagOutputFormat() FlagDefinition[string]

func FlagPluginPreset

func FlagPluginPreset() FlagDefinition[string]

func FlagPlugins

func FlagPlugins() FlagDefinition[string]

func FlagPluginsPath

func FlagPluginsPath() FlagDefinition[string]

func FlagPluginsSize

func FlagPluginsSize() FlagDefinition[string]

func FlagProfile

func FlagProfile() FlagDefinition[string]

func FlagPrometheusURL

func FlagPrometheusURL() FlagDefinition[string]

func FlagPrometheusUsername

func FlagPrometheusUsername() FlagDefinition[string]

func FlagPurgeStorage added in v0.18.0

func FlagPurgeStorage() FlagDefinition[bool]

func FlagRecentRetention

func FlagRecentRetention() FlagDefinition[string]

func FlagReleaseName

func FlagReleaseName() FlagDefinition[string]

func FlagRollbackOnError

func FlagRollbackOnError() FlagDefinition[bool]

func FlagSkipHardwareChecks

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/cli/commands/root.go (hidden). See docs/dev/hidden-flags.md for full documentation.

func FlagStopOnError

func FlagStopOnError() FlagDefinition[bool]

func FlagTeleportValuesFile

func FlagTeleportValuesFile() FlagDefinition[string]

func FlagTeleportVersion

func FlagTeleportVersion() FlagDefinition[string]

func FlagValuesFile

func FlagValuesFile() FlagDefinition[string]

func FlagVerificationPath

func FlagVerificationPath() FlagDefinition[string]

func FlagVerificationSize

func FlagVerificationSize() FlagDefinition[string]

func FlagVersion

func FlagVersion() FlagDefinition[bool]

func FlagWithStorageReset

func FlagWithStorageReset() FlagDefinition[bool]

func (FlagDefinition[T]) Clone

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

func (fp FlagDefinition[T]) MarkRequired(cmd *cobra.Command, v bool) error

func (FlagDefinition[T]) MarkRequiredP

func (fp FlagDefinition[T]) MarkRequiredP(cmd *cobra.Command, v bool) error

func (FlagDefinition[T]) SetVar

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

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]) SetVarPHidden

func (fp FlagDefinition[T]) SetVarPHidden(cmd *cobra.Command, p *T, required bool)

SetVarPHidden registers the flag as a persistent flag and marks it hidden so it does not appear in --help. Useful for deprecated or internal-only flags that must still be accepted on the command line.

func (FlagDefinition[T]) Value

func (fp FlagDefinition[T]) Value(cmd *cobra.Command, args []string) (T, error)

Value resolves a flag value using the following precedence:

  1. Local (non-persistent) flags on this command
  2. Own persistent flags on this command (defined via SetVarP on this command directly)
  3. 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

func (fp FlagDefinition[T]) ValueLocal(cmd *cobra.Command, args []string) (T, error)

func (FlagDefinition[T]) ValueOwnPersistent

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 RepeatableStringFlagDefinition

type RepeatableStringFlagDefinition struct {
	Name        string
	ShortName   string
	Description string
	Default     []string
}

RepeatableStringFlagDefinition defines a []string flag whose values are collected from repeated --flag occurrences without comma-splitting: each --item v contributes one element verbatim, so values that themselves contain commas (e.g. structured specs like "name=x,url=y") are preserved. Backed by pflag's StringArrayVarP / GetStringArray.

func FlagLokiRemotes

func FlagLokiRemotes() RepeatableStringFlagDefinition

func FlagPrometheusRemotes

func FlagPrometheusRemotes() RepeatableStringFlagDefinition

func (RepeatableStringFlagDefinition) Clone

Clone returns an independent copy of the descriptor.

func (RepeatableStringFlagDefinition) MarkRequired

func (fp RepeatableStringFlagDefinition) MarkRequired(cmd *cobra.Command, v bool) error

func (RepeatableStringFlagDefinition) MarkRequiredP

func (fp RepeatableStringFlagDefinition) MarkRequiredP(cmd *cobra.Command, v bool) error

func (RepeatableStringFlagDefinition) SetVar

func (fp RepeatableStringFlagDefinition) SetVar(cmd *cobra.Command, p *[]string, required bool)

func (RepeatableStringFlagDefinition) SetVarP

func (fp RepeatableStringFlagDefinition) SetVarP(cmd *cobra.Command, p *[]string, required bool)

func (RepeatableStringFlagDefinition) SetVarPHidden

func (fp RepeatableStringFlagDefinition) SetVarPHidden(cmd *cobra.Command, p *[]string, required bool)

func (RepeatableStringFlagDefinition) Value

func (fp RepeatableStringFlagDefinition) Value(cmd *cobra.Command, args []string) ([]string, error)

Value mirrors FlagDefinition[T].Value: local → own persistent → inherited persistent.

func (RepeatableStringFlagDefinition) ValueLocal

func (fp RepeatableStringFlagDefinition) ValueLocal(cmd *cobra.Command, args []string) ([]string, error)

func (RepeatableStringFlagDefinition) ValueOwnPersistent

func (fp RepeatableStringFlagDefinition) ValueOwnPersistent(cmd *cobra.Command, args []string) ([]string, error)

type RootFlags

type RootFlags struct {
	Config             string
	Force              bool
	SkipHardwareChecks bool
	LogLevel           string
}

RootFlags contains the flags registered on the root command and available to every subcommand via persistent inheritance.

type SetupResult

type SetupResult struct {
	Config         models.Config
	StateManager   state.Manager
	RealityChecker reality.Checkers
	Runtime        *rsl.RuntimeResolver
}

func Setup

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL