options

package
v0.0.0-...-738c23d Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package options holds the parsed CLI/runtime configuration for dhctl.

It replaces the package-level mutable globals previously kept in dhctl/pkg/app. Each domain has its own struct with field-level defaults; flag definitions in dhctl/pkg/app populate these structs instead of writing to package vars, so operations can be passed an explicit *Options.

Code generated by hack/gen_preflight_checks; DO NOT EDIT.

Index

Constants

View Source
const (
	UseStateCacheAsk = "ask"
	UseStateCacheYes = "yes"
	UseStateCacheNo  = "no"
)

Allowed values for CacheOptions.UseTfCache.

View Source
const DefaultDeckhouseDir = "/deckhouse"

DefaultDeckhouseDir is the directory where the dhctl binary expects to find version/edition metadata files when running inside the deckhouse container.

View Source
const DefaultSSHAgentPrivateKeys = "~/.ssh/id_rsa"

DefaultSSHAgentPrivateKeys is the default value used when --ssh-agent-private-keys is not provided.

Variables

View Source
var (
	AppVersion = "local"
	AppEdition = "local"
)

AppVersion and AppEdition are populated by the linker via "-X" build flags (see dhctl/Makefile). They must not be assigned at runtime.

Functions

func DefaultTmpDir

func DefaultTmpDir() string

DefaultTmpDir returns the default location for dhctl temporary state. It is derived from os.TempDir at call time so the value cannot be mutated from outside the package.

func GeneratedChecks

func GeneratedChecks() []string

GeneratedChecks returns a copy of the auto-generated preflight check names.

func ParseSSHPrivateKeyPaths

func ParseSSHPrivateKeyPaths(pathSets []string) ([]string, error)

ParseSSHPrivateKeyPaths expands tilde-prefixed paths, makes them absolute and verifies their existence.

The default agent key path is silently skipped if the file does not exist (preserving the previous pkg/app behavior).

Types

type AutoConvergeOptions

type AutoConvergeOptions struct {
	ApplyInterval   time.Duration
	ListenAddress   string
	RunningNodeName string
}

AutoConvergeOptions configures the periodical auto-converge service.

func NewAutoConvergeOptions

func NewAutoConvergeOptions() AutoConvergeOptions

NewAutoConvergeOptions returns AutoConvergeOptions with defaults.

func (*AutoConvergeOptions) ToSpanAttributes

func (o *AutoConvergeOptions) ToSpanAttributes() []otattribute.KeyValue

type BecomeOptions

type BecomeOptions struct {
	AskBecomePass bool
	BecomePass    string
}

BecomeOptions holds the sudo/become password prompt configuration. BecomePass is filled in at runtime by the interactive password prompt.

func (*BecomeOptions) ToSpanAttributes

func (o *BecomeOptions) ToSpanAttributes() []otattribute.KeyValue

type BootstrapOptions

type BootstrapOptions struct {
	InternalNodeIP string
	DevicePath     string

	ResourcesPath    string
	ResourcesTimeout time.Duration
	DeckhouseTimeout time.Duration

	PostBootstrapScriptTimeout time.Duration
	PostBootstrapScriptPath    string

	ForceAbortFromCache             bool
	DontUsePublicControlPlaneImages bool

	KubeadmBootstrap   bool
	MasterNodeSelector bool
}

BootstrapOptions covers everything specific to the bootstrap flow.

func NewBootstrapOptions

func NewBootstrapOptions() BootstrapOptions

NewBootstrapOptions returns BootstrapOptions with the previous package-level defaults.

func (*BootstrapOptions) ToSpanAttributes

func (o *BootstrapOptions) ToSpanAttributes() []otattribute.KeyValue

type BuildInfo

type BuildInfo struct {
	AppVersion string
	AppEdition string

	DeckhouseDir string
	VersionFile  string
	EditionFile  string
}

BuildInfo carries version/edition metadata loaded once at startup.

func LoadBuildInfo

func LoadBuildInfo(deckhouseDir string) BuildInfo

LoadBuildInfo populates BuildInfo using the linker-injected AppVersion/ AppEdition as defaults, then overrides them with the contents of the version/edition files under deckhouseDir if they exist.

func (BuildInfo) ToSpanAttributes

func (o BuildInfo) ToSpanAttributes() []otattribute.KeyValue

type CacheOptions

type CacheOptions struct {
	Dir        string
	UseTfCache string
	DropCache  bool

	KubeConfig          string
	KubeConfigContext   string
	KubeConfigInCluster bool
	KubeNamespace       string
	KubeName            string
	KubeLabels          map[string]string

	// ResourceManagementTimeout overrides infrastructure resource-management
	// timeouts (string passed unparsed to the underlying tooling).
	ResourceManagementTimeout string
}

CacheOptions groups infrastructure (terraform/tofu) state cache settings.

func NewCacheOptions

func NewCacheOptions() CacheOptions

NewCacheOptions returns CacheOptions with defaults.

func (*CacheOptions) ToSpanAttributes

func (o *CacheOptions) ToSpanAttributes() []otattribute.KeyValue

type ControlPlaneOptions

type ControlPlaneOptions struct {
	Hostname string
	IP       string
}

ControlPlaneOptions configures the test-control-plane sub-commands.

func (*ControlPlaneOptions) ToSpanAttributes

func (o *ControlPlaneOptions) ToSpanAttributes() []otattribute.KeyValue

type ConvergeOptions

type ConvergeOptions struct {
	MetricsPath   string
	ListenAddress string
	CheckInterval time.Duration
	OutputFormat  string

	CheckHasTerraformStateBeforeMigrateToTofu bool
}

ConvergeOptions covers the converge / converge-exporter / migration commands.

func NewConvergeOptions

func NewConvergeOptions() ConvergeOptions

NewConvergeOptions returns ConvergeOptions with the previous package-level defaults.

func (*ConvergeOptions) ToSpanAttributes

func (o *ConvergeOptions) ToSpanAttributes() []otattribute.KeyValue

type DestroyOptions

type DestroyOptions struct {
	SkipResources bool
}

DestroyOptions covers the destroy command.

func (*DestroyOptions) ToSpanAttributes

func (o *DestroyOptions) ToSpanAttributes() []otattribute.KeyValue

type GlobalOptions

type GlobalOptions struct {
	TmpDir                 string
	LoggerType             string
	IsDebug                bool
	DoNotWriteDebugLogFile bool
	DebugLogFilePath       string
	ProgressFilePath       string
	DownloadDir            string
	DownloadCacheDir       string
	ConfigPaths            []string
	SanityCheck            bool
	ShowProgress           bool
}

GlobalOptions holds settings shared by every dhctl command.

func NewGlobalOptions

func NewGlobalOptions() GlobalOptions

NewGlobalOptions returns GlobalOptions with defaults applied.

The DHCTL_DEBUG environment variable is honored here so commands receive the same IsDebug behavior the previous package init() used to set.

func (GlobalOptions) ToSpanAttributes

func (o GlobalOptions) ToSpanAttributes() []otattribute.KeyValue

type KubeOptions

type KubeOptions struct {
	Config        string
	ConfigContext string
	InCluster     bool
}

KubeOptions describes how dhctl reaches the Kubernetes API.

func (*KubeOptions) IsDefined

func (o *KubeOptions) IsDefined() bool

IsDefined reports whether any of the kube flags were explicitly set. Replaces the previous pkg/app.KubeFlagsDefined helper.

func (*KubeOptions) ToSpanAttributes

func (o *KubeOptions) ToSpanAttributes() []otattribute.KeyValue

type Options

type Options struct {
	Global       GlobalOptions
	BuildInfo    BuildInfo
	SSH          SSHOptions
	Become       BecomeOptions
	Kube         KubeOptions
	Cache        CacheOptions
	Bootstrap    BootstrapOptions
	Preflight    PreflightOptions
	Converge     ConvergeOptions
	AutoConverge AutoConvergeOptions
	Server       ServerOptions
	Render       RenderOptions
	ControlPlane ControlPlaneOptions
	Destroy      DestroyOptions
	Registry     RegistryOptions
}

Options aggregates every domain-specific options struct used by dhctl.

func New

func New() *Options

New returns Options with built-in defaults applied. It is intentionally side-effect free apart from reading well-known environment variables (DHCTL_DEBUG, USER) and the build metadata files under DefaultDeckhouseDir.

func (*Options) DirConfig

func (o *Options) DirConfig() *directoryconfig.DirectoryConfig

DirConfig returns the directory configuration consumed by pkg/config and pkg/template. It bundles the download directories (from GlobalOptions) with the version-file path (from BuildInfo) so callers do not need to reach into both sub-structs.

func (*Options) ToSpanAttributes

func (o *Options) ToSpanAttributes() []otattribute.KeyValue

type PreflightOptions

type PreflightOptions struct {
	SkipAll    bool
	SkipChecks []string
}

PreflightOptions describes which preflight checks should be skipped.

func (*PreflightOptions) ApplySkips

func (o *PreflightOptions) ApplySkips(skipsList []string)

ApplySkips appends the given skip names to SkipChecks, normalizing legacy aliases.

func (*PreflightOptions) DisabledChecks

func (o *PreflightOptions) DisabledChecks() []string

DisabledChecks returns the full set of disabled checks. When SkipAll is set every known check is included.

func (*PreflightOptions) IsCheckDisabled

func (o *PreflightOptions) IsCheckDisabled(name string) bool

IsCheckDisabled reports whether the named check is currently disabled.

func (*PreflightOptions) ToSpanAttributes

func (o *PreflightOptions) ToSpanAttributes() []otattribute.KeyValue

func (*PreflightOptions) Validate

func (o *PreflightOptions) Validate() error

Validate ensures every entry in SkipChecks matches a known check name. Used as a kingpin PreAction in pkg/app.

type PrivateKeyFileToPassphrase

type PrivateKeyFileToPassphrase = map[string]string

PrivateKeyFileToPassphrase maps an SSH private key file path to its passphrase.

type RegistryOptions

type RegistryOptions struct {
	ImgBundlePath string
}

type RenderOptions

type RenderOptions struct {
	BashibleBundleDir string
	ParseInputFile    string
	ParseOutput       string
	Editor            string
}

RenderOptions covers the `dhctl config render ...` and `config parse ...` commands.

func NewRenderOptions

func NewRenderOptions() RenderOptions

NewRenderOptions returns RenderOptions with defaults.

func (*RenderOptions) ToSpanAttributes

func (o *RenderOptions) ToSpanAttributes() []otattribute.KeyValue

type SSHOptions

type SSHOptions struct {
	PrivateKeys []string

	ConnectionConfigPath string
	AgentPrivateKeys     []string
	BastionHost          string
	BastionPort          string
	BastionUser          string
	BastionPass          string
	User                 string
	Hosts                []session.Host
	HostsRaw             []string
	Port                 string
	ExtraArgs            string

	AskBastionPass bool

	LegacyMode bool
	ModernMode bool

	// PrivateKeysToPassPhrasesFromConfig is populated by the connection-config parser.
	PrivateKeysToPassPhrasesFromConfig PrivateKeyFileToPassphrase
}

SSHOptions groups all SSH-related runtime configuration.

func NewSSHOptions

func NewSSHOptions() SSHOptions

NewSSHOptions returns SSHOptions with defaults derived from $USER.

func (*SSHOptions) ProcessConnectionConfigFlags

func (o *SSHOptions) ProcessConnectionConfigFlags() error

ProcessConnectionConfigFlags fills PrivateKeys from AgentPrivateKeys, applying the default agent key when no key is configured. It used to live in pkg/app as the unexported processConnectionConfigFlags.

func (*SSHOptions) ToSpanAttributes

func (o *SSHOptions) ToSpanAttributes() []otattribute.KeyValue

type ServerOptions

type ServerOptions struct {
	Network                    string
	Address                    string
	ParallelTasksLimit         int
	RequestsCounterMaxDuration time.Duration
}

ServerOptions configures the dhctl gRPC server.

func (*ServerOptions) ToSpanAttributes

func (o *ServerOptions) ToSpanAttributes() []otattribute.KeyValue

Jump to

Keyboard shortcuts

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