envconfig

package
v1.78.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package envconfig owns the environment-variable contract between the deckhouse-controller deployment manifest and the addon-operator / shell-operator runtime libraries.

addon-operator (and, transitively, shell-operator) historically read their configuration directly from env vars via their own ParseEnv. Starting with addon-operator v1.21 those env vars were namespaced under struct-tag prefixes (ADDON_OPERATOR, HELM, KUBE, ...): for example, the field formerly bound to the MODULES_DIR env var became bound to ADDON_OPERATOR_MODULES_DIR. That silently broke deckhouse — the long-standing MODULES_DIR set by the deployment was ignored, addon-operator fell back to its built-in "modules" default, and external modules under /deckhouse/downloaded/modules disappeared along with their ModuleReleases.

To prevent recurrence, deckhouse-controller now parses every env var it cares about in one place (this package) and explicitly populates the addon-operator *Config. The values then propagate down the chain: addon-operator.ApplyConfig copies them into addon-operator's package-level globals (app.ModulesDir, app.GlobalHooksDir, app.KubeContext, app.TempDir, app.DebugKeepTmpFiles, app.LogProxyHookJSON, app.DebugHTTPServerAddr, ...), and bridges the one shell-operator global it still owns directly (shapp.DebugUnixSocket). addon-operator's own ParseEnv is intentionally not called by the controller so that future upstream renames cannot silently change the deckhouse deployment contract.

Shell-operator audit (v1.16.6 kingpin -> v1.16.7+/v1.17.x cobra+envPrefix): shell-operator's own ParseEnv is never invoked from deckhouse-controller. addon-operator only registers shell-operator's Kube/ObjectPatcher/Log/Debug flags on its own cobra command, and v1.16.7+ kept every env name in that subset identical (KUBE_CONTEXT, OBJECT_PATCHER_KUBE_CLIENT_QPS, LOG_LEVEL, DEBUG_UNIX_SOCKET, ...). Those env vars now also live inside addon-operator's own *Config (Kube/ObjectPatcher/Log/Debug sub-structs) which we populate below, so the shell-operator refactor is invisible from this side.

SHELL_OPERATOR_* App-side fallbacks (HOOKS_DIR / TMP_DIR / LISTEN_ADDRESS / LISTEN_PORT / PROMETHEUS_METRICS_PREFIX / NAMESPACE) are honored as a lower-priority alias for the corresponding addon-operator App fields. This mirrors addon-operator's own applyShellOperatorEnv (introduced upstream in commit 3d42acf "handle shell operator env"): a deployment that still ships shell-operator-style names keeps working, but if both the SHELL_OPERATOR_* and the ADDON_OPERATOR_*/historical unprefixed name are set, the addon-operator-side value wins. Shell-operator's standalone webhook settings (VALIDATING_WEBHOOK_* / CONVERSION_WEBHOOK_*) are not wired up by addon-operator and therefore intentionally not part of this contract — deckhouse uses addon-operator's own ADDON_OPERATOR_ADMISSION_* for the admission server.

Index

Constants

View Source
const (
	// EnvBundle selects the always-on module set: Default, Minimal or Managed.
	EnvBundle = "DECKHOUSE_BUNDLE"

	// EnvHA holds "true"/"false". HA is the default; "false" forces single-replica
	// mode and is honored only in dev builds.
	EnvHA = "DECKHOUSE_HA"

	// Pod identity from the downward API (EnvPod=metadata.name,
	// EnvNamespace=metadata.namespace, EnvListenAddress=status.podIP), combined
	// into the leader-election lease identity. EnvListenAddress is the operator
	// listen address, which the manifest wires to the pod IP, so it doubles as one.
	EnvPod           = "DECKHOUSE_POD"
	EnvNamespace     = "ADDON_OPERATOR_NAMESPACE"
	EnvListenAddress = "ADDON_OPERATOR_LISTEN_ADDRESS"
	EnvListenPort    = "ADDON_OPERATOR_LISTEN_PORT"
	EnvClusterDomain = "KUBERNETES_CLUSTER_DOMAIN"

	// EnvNodeName is the node the pod runs on (downward API spec.nodeName).
	EnvNodeName = "DECKHOUSE_NODE_NAME"

	// EnvSkipEntrypoint is set when the controller re-execs itself on a restart
	// signal, so the one-time entrypoint setup (chroot, symlinks) runs only once.
	EnvSkipEntrypoint = "SKIP_ENTRYPOINT_EXECUTION"

	// EnvShellChrootDir and EnvModulesDir belong to the addon-operator config
	// contract (Config.ShellChrootDir, Config.ModulesDir). They are read directly
	// in the entrypoint, to prepare the shell chroot and locate modules before the
	// operator starts.
	EnvShellChrootDir = "ADDON_OPERATOR_SHELL_CHROOT_DIR"
	EnvModulesDir     = "MODULES_DIR"

	// OTLP tracing exporter settings.
	EnvTracingOTLPEndpoint      = "TRACING_OTLP_ENDPOINT"
	EnvTracingOTLPAuthToken     = "TRACING_OTLP_AUTH_TOKEN"
	EnvTracingOTLPInsecure      = "TRACING_OTLP_INSECURE"
	EnvTracingOTLPTLSSkipVerify = "TRACING_OTLP_TLS_SKIP_VERIFY"

	// Options forwarded to the embedded dhctl CLI.
	EnvLoggerType          = "DECKHOUSE_LOGGER_TYPE"
	EnvEditor              = "DECKHOUSE_EDITOR"
	EnvKubeConfigInCluster = "DECKHOUSE_KUBE_CONFIG_IN_CLUSTER"
	EnvTmpDir              = "DECKHOUSE_TMP_DIR"

	// Helm engine settings the nelm client picks up. EnvKubeContext is also
	// Config.KubeContext.
	EnvHelmDriver  = "HELM_DRIVER"
	EnvKubeContext = "KUBE_CONTEXT"

	// Endpoints the "deckhouse-controller debug" subcommands talk to.
	// EnvDebugHTTPServerAddr is also Config.DebugHTTPServerAddr;
	// EnvPackagesDebugUnixSocket is the packages-side socket and is the default of
	// the --debug-unix-socket flag.
	EnvDebugHTTPServerAddr     = "DEBUG_HTTP_SERVER_ADDR"
	EnvPackagesDebugUnixSocket = "PACKAGES_DEBUG_UNIX_SOCKET"

	// EnvIsTestsEnvironment holds "true" in test runs, where it pins values that
	// would otherwise vary per run (e.g. measured durations).
	EnvIsTestsEnvironment = "D8_IS_TESTS_ENVIRONMENT"

	// EnvPackageNelmTimeout bounds each nelm release operation on the packages
	// path (render, apply, uninstall). A Go duration string (e.g. "30m").
	EnvPackageNelmTimeout = "PACKAGE_NELM_TIMEOUT"
)

Environment variable names the deckhouse controller reads directly, outside the addon-operator *Config that Load builds. They are the same contract with the controller Deployment manifest (modules/002-deckhouse/templates/deployment.yaml), so they live in this package alongside it.

A few names also appear as Config fields in envconfig.go. Those are read twice on purpose: Load parses them into addon-operator's config, while the entrypoint and the pod-identity helpers below need them before that config exists, or from code that never sees it. Go struct tags take literals only, so the Config fields cannot reference these constants — when a name changes, both places have to change.

Variables

This section is empty.

Functions

func ClusterDomain added in v1.78.0

func ClusterDomain() string

ClusterDomain is the Kubernetes cluster domain.

func EnabledHA added in v1.78.0

func EnabledHA() bool

EnabledHA reports whether HA is enabled. HA is the default; it is off only when DECKHOUSE_HA is explicitly "false". The caller honors "off" only in dev builds.

func EnvBoolOr added in v1.78.0

func EnvBoolOr(name string, defaultValue bool) bool

EnvBoolOr parses the env var as a bool (per strconv.ParseBool), or returns defaultValue when unset, empty, or unparseable.

func EnvDurationOr added in v1.78.0

func EnvDurationOr(name string, defaultValue time.Duration) time.Duration

EnvDurationOr parses the env var as a Go duration (per time.ParseDuration), or returns defaultValue when unset, empty, or unparseable.

func EnvOr added in v1.78.0

func EnvOr(name, defaultValue string) string

EnvOr returns the value of the env var name, or defaultValue when it is unset or empty.

func IsTestsEnvironment added in v1.78.0

func IsTestsEnvironment() bool

IsTestsEnvironment reports whether the process runs under the test harness.

func ListenAddress added in v1.78.0

func ListenAddress() string

ListenAddress is the api server listen address.

func ListenPort added in v1.78.0

func ListenPort() string

ListenPort is the api server listen port.

func Load

func Load(cfg *app.Config) error

Load is the single entry point for env-driven configuration of addon-operator (and the shell-operator globals addon-operator manages).

It seeds a Config from cfg so that addon-operator's hardcoded defaults from app.NewConfig stay in place when an env var is absent, then applies the SHELL_OPERATOR_* fallbacks (lower priority), then overlays the ADDON_OPERATOR_*/historical unprefixed env vars (higher priority — they always win on conflict), then copies everything back into cfg. Callers should follow this with app.BindFlags so CLI flags still win over env values.

func NodeName added in v1.78.0

func NodeName() string

NodeName is the name of the node the controller pod runs on.

func PackageNelmTimeout added in v1.78.0

func PackageNelmTimeout() time.Duration

PackageNelmTimeout is the timeout the packages path applies to one nelm release operation. Defaults to 30m when PACKAGE_NELM_TIMEOUT is unset, unparseable, or not positive.

func PodIP added in v1.78.0

func PodIP() string

PodIP is the controller pod IP. It reads the operator listen-address env, which the Deployment wires to status.podIP.

func PodName added in v1.78.0

func PodName() string

PodName is the controller pod name, used as the leader-election identity.

func PodNamespace added in v1.78.0

func PodNamespace() string

PodNamespace is the controller pod namespace.

func TracingOTLPAuthToken added in v1.78.0

func TracingOTLPAuthToken() string

TracingOTLPAuthToken is the OTLP trace exporter auth token.

func TracingOTLPEndpoint added in v1.78.0

func TracingOTLPEndpoint() string

TracingOTLPEndpoint is the OTLP trace exporter endpoint.

func TracingOTLPInsecure added in v1.78.0

func TracingOTLPInsecure() bool

TracingOTLPInsecure reports whether the OTLP exporter uses an insecure transport.

func TracingOTLPTLSSkipVerify added in v1.78.0

func TracingOTLPTLSSkipVerify() bool

TracingOTLPTLSSkipVerify reports whether OTLP exporter TLS verification is skipped.

Types

type Config

type Config struct {
	// App settings.
	ModulesDir              string `env:"MODULES_DIR"`
	GlobalHooksDir          string `env:"GLOBAL_HOOKS_DIR"`
	TempDir                 string `env:"ADDON_OPERATOR_TMP_DIR"`
	Namespace               string `env:"ADDON_OPERATOR_NAMESPACE"`
	ListenAddress           string `env:"ADDON_OPERATOR_LISTEN_ADDRESS"`
	ListenPort              string `env:"ADDON_OPERATOR_LISTEN_PORT"`
	ConfigMapName           string `env:"ADDON_OPERATOR_CONFIG_MAP"`
	PrometheusMetricsPrefix string `env:"ADDON_OPERATOR_PROMETHEUS_METRICS_PREFIX"`
	UnnumberedModuleOrder   int    `env:"UNNUMBERED_MODULES_ORDER"`
	ShellChrootDir          string `env:"ADDON_OPERATOR_SHELL_CHROOT_DIR"`
	StrictModeEnabled       bool   `env:"STRICT_CHECK_VALUES_MODE_ENABLED"`
	AppliedExtenders        string `env:"ADDON_OPERATOR_APPLIED_MODULE_EXTENDERS"`
	ExtraLabels             string `env:"ADDON_OPERATOR_CRD_EXTRA_LABELS"`
	CRDsFilters             string `env:"ADDON_OPERATOR_CRD_FILTER_PREFIXES"`

	// Helm settings.
	HelmHistoryMax             int32         `env:"HELM_HISTORY_MAX"`
	HelmTimeout                time.Duration `env:"HELM_TIMEOUT"`
	HelmIgnoreRelease          string        `env:"HELM_IGNORE_RELEASE"`
	HelmMonitorKubeClientQPS   float32       `env:"HELM_MONITOR_KUBE_CLIENT_QPS"`
	HelmMonitorKubeClientBurst int           `env:"HELM_MONITOR_KUBE_CLIENT_BURST"`

	// Admission settings.
	AdmissionServerListenPort string `env:"ADDON_OPERATOR_ADMISSION_SERVER_LISTEN_PORT"`
	AdmissionServerCertsDir   string `env:"ADDON_OPERATOR_ADMISSION_SERVER_CERTS_DIR"`
	AdmissionServerEnabled    bool   `env:"ADDON_OPERATOR_ADMISSION_SERVER_ENABLED"`

	// Kube settings.
	KubeContext     string  `env:"KUBE_CONTEXT"`
	KubeConfig      string  `env:"KUBE_CONFIG"`
	KubeServer      string  `env:"KUBE_SERVER"`
	KubeClientQPS   float32 `env:"KUBE_CLIENT_QPS"`
	KubeClientBurst int     `env:"KUBE_CLIENT_BURST"`

	// Object patcher settings (separate Kubernetes client).
	ObjectPatcherKubeClientQPS     float32       `env:"OBJECT_PATCHER_KUBE_CLIENT_QPS"`
	ObjectPatcherKubeClientBurst   int           `env:"OBJECT_PATCHER_KUBE_CLIENT_BURST"`
	ObjectPatcherKubeClientTimeout time.Duration `env:"OBJECT_PATCHER_KUBE_CLIENT_TIMEOUT"`

	// Debug settings (shared between addon-operator and shell-operator
	// — addon-operator copies DebugUnixSocket into the shapp global).
	DebugUnixSocket     string `env:"DEBUG_UNIX_SOCKET"`
	DebugHTTPServerAddr string `env:"DEBUG_HTTP_SERVER_ADDR"`
	DebugKeepTmpFiles   bool   `env:"DEBUG_KEEP_TMP_FILES"`
	DebugKubernetesAPI  bool   `env:"DEBUG_KUBERNETES_API"`

	// Log settings (shared between addon-operator and shell-operator).
	LogLevel         string `env:"LOG_LEVEL"`
	LogType          string `env:"LOG_TYPE"`
	LogNoTime        bool   `env:"LOG_NO_TIME"`
	LogProxyHookJSON bool   `env:"LOG_PROXY_HOOK_JSON"`
}

Config mirrors the leaf settings of addon-operator's *Config with env tags that match the historical addon-operator v1.20.9 / shell-operator v1.16.6 contract — the names that the deckhouse-controller deployment manifest (modules/002-deckhouse/templates/deployment.yaml) and the existing shell hooks have always used. addon-operator v1.21 namespaced several of these under ADDON_OPERATOR_; that breaking change is what motivated this package.

Two env vars in particular kept their historical unprefixed names here:

  • UNNUMBERED_MODULES_ORDER (addon-operator v1.21 renamed to ADDON_OPERATOR_UNNUMBERED_MODULES_ORDER)
  • STRICT_CHECK_VALUES_MODE_ENABLED (addon-operator v1.21 renamed to ADDON_OPERATOR_STRICT_CHECK_VALUES_MODE_ENABLED)

Adding a new env var to the manifest also requires adding the corresponding field here and a matching assignment in Apply — keeping the contract explicit by design.

func (*Config) Apply

func (c *Config) Apply(cfg *app.Config)

Apply copies parsed env values into cfg, overwriting whatever was there. Exposed for tests and for callers that want to drive a *Config directly (e.g. when seeding addon-operator from a non-env source).

Jump to

Keyboard shortcuts

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