Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyConfig(cfg *Config)
- func BindFlags(cfg *Config, rootCmd *cobra.Command, cmd *cobra.Command)
- func DefineDebugCommands(rootCmd *cobra.Command)
- func DefineDebugUnixSocketFlag(cmd *cobra.Command)
- func ParseEnv(cfg *Config) error
- func SetupLogging(level string, runtimeConfig Registerer, logger *log.Logger)
- type AdmissionSettings
- type AppSettings
- type Config
- type DebugSettings
- type HelmSettings
- type KubeSettings
- type LogSettings
- type ObjectPatcherSettings
- type Registerer
Constants ¶
const ( DefaultTempDir = "/tmp/addon-operator" DefaultDebugUnixSocket = "/var/run/addon-operator/debug.socket" )
const ( ForcedDurationForDebugLevel = 30 * time.Minute ProxyJsonLogKey = "proxyJsonLog" )
ForcedDurationForDebugLevel - force expiration for debug level.
Variables ¶
var ( AppName = "addon-operator" AppDescription = "" Version = "dev" // AppStartMessage is the line logged at the start of the operator. The // binary entrypoint can override it (e.g. to embed the version). // Mirrors what shell-operator exposes as app.AppStartMessage so callers // no longer have to write into shell-operator globals. AppStartMessage = AppName ListenAddress = "0.0.0.0" ListenPort = "9650" DefaultPrometheusMetricsPrefix = "addon_operator_" PrometheusMetricsPrefix = DefaultPrometheusMetricsPrefix Helm3HistoryMax int32 = 10 Helm3Timeout = 20 * time.Minute HelmIgnoreRelease = "" HelmMonitorKubeClientQpsDefault = "5" HelmMonitorKubeClientQps float32 HelmMonitorKubeClientBurstDefault = "10" HelmMonitorKubeClientBurst int Namespace = "" ConfigMapName = "addon-operator" GlobalHooksDir = "global-hooks" ModulesDir = "modules" TempDir = "" ShellChrootDir = "" UnnumberedModuleOrder = 1 AdmissionServerListenPort = "9651" AdmissionServerCertsDir = "" AdmissionServerEnabled = false // StrictModeEnabled fail with error if MODULES_DIR/values.yaml does not exist StrictModeEnabled = false // AppliedExtenders defines the list and the order of applied module extenders AppliedExtenders = "" // ExtraLabels defines strings for CRDs label selector ExtraLabels = "heritage=addon-operator" // CRDsFilters defines filters for CRD files, example `doc-,_` CRDsFilters = "doc-,_" // NumberOfParallelQueues defines the number of precreated parallel queues for parallel execution NumberOfParallelQueues = 20 ParallelQueuePrefix = "parallel_queue" ParallelQueueNamePattern = ParallelQueuePrefix + "_%d" // Kube client settings (previously from shell-operator globals) KubeContext string KubeConfig string KubeServer string KubeClientQPS float32 KubeClientBurst int ObjectPatcherKubeClientQPS float32 ObjectPatcherKubeClientBurst int ObjectPatcherKubeClientTimeout time.Duration // Debug settings (previously from shell-operator globals) DebugUnixSocket string DebugHTTPServerAddr string DebugKeepTmpFiles bool DebugKubernetesAPI bool // Log settings (previously from shell-operator globals) LogLevel string LogType string LogNoTime bool LogProxyHookJSON bool )
Functions ¶
func ApplyConfig ¶ added in v1.21.0
func ApplyConfig(cfg *Config)
ApplyConfig copies Config values into package-level variables for backward compatibility with code that reads them directly (e.g. module_manager).
func BindFlags ¶ added in v1.21.0
BindFlags registers all operator CLI flags on cmd, using the current cfg values (already merged with env vars and hardcoded defaults) as flag defaults. An explicit CLI flag always wins.
func DefineDebugCommands ¶
func DefineDebugUnixSocketFlag ¶ added in v1.21.2
DefineDebugUnixSocketFlag registers the --debug-unix-socket flag on cmd, binding it to the package-level DebugUnixSocket variable. Debug sub-commands (queue, hook, config, etc.) use this to locate the operator's debug socket without depending on shell-operator's app globals.
func ParseEnv ¶ added in v1.21.0
ParseEnv overrides cfg fields with values from environment variables. Fields whose env var is not set retain their current values, so hardcoded defaults from NewConfig are preserved when no env var is present.
Both addon-operator's own variables (ADDON_OPERATOR_*, HELM_*, shared KUBE_*, OBJECT_PATCHER_*, DEBUG_*, LOG_*) and the shell-operator-side variables that have no ADDON_OPERATOR_* counterpart (SHELL_OPERATOR_* HOOKS_DIR / TMP_DIR / LISTEN_ADDRESS / LISTEN_PORT / PROMETHEUS_METRICS_PREFIX / NAMESPACE) are recognized. ADDON_OPERATOR_* wins when both are set because it is applied last and overlays whatever shell-operator envs put in cfg.
IMPORTANT: ParseEnv must only be invoked on the binary/CLI path, never on a caller-supplied *Config (see addon_operator.resolveConfig). Library users who pass WithConfig rely on env vars being ignored.
func SetupLogging ¶ added in v1.21.2
func SetupLogging(level string, runtimeConfig Registerer, logger *log.Logger)
SetupLogging sets the log level and registers a runtime config hook so the level can be changed without restarting the operator. It mirrors the helper previously provided by shell-operator's app package so addon-operator no longer depends on shell-operator globals for log setup.
Types ¶
type AdmissionSettings ¶ added in v1.21.0
type AppSettings ¶ added in v1.21.0
type AppSettings struct {
ModulesDir string `env:"MODULES_DIR"`
GlobalHooksDir string `env:"GLOBAL_HOOKS_DIR"`
TempDir string `env:"TMP_DIR"`
Namespace string `env:"NAMESPACE"`
ListenAddress string `env:"LISTEN_ADDRESS"`
ListenPort string `env:"LISTEN_PORT"`
ConfigMapName string `env:"CONFIG_MAP"`
PrometheusMetricsPrefix string `env:"PROMETHEUS_METRICS_PREFIX"`
UnnumberedModuleOrder int `env:"UNNUMBERED_MODULES_ORDER"`
ShellChrootDir string `env:"SHELL_CHROOT_DIR"`
StrictModeEnabled bool `env:"STRICT_CHECK_VALUES_MODE_ENABLED"`
AppliedExtenders string `env:"APPLIED_MODULE_EXTENDERS"`
ExtraLabels string `env:"CRD_EXTRA_LABELS"`
CRDsFilters string `env:"CRD_FILTER_PREFIXES"`
}
type Config ¶ added in v1.21.0
type Config struct {
App AppSettings `envPrefix:"ADDON_OPERATOR_"`
Helm HelmSettings `envPrefix:"HELM_"`
Admission AdmissionSettings `envPrefix:"ADDON_OPERATOR_"`
Kube KubeSettings `envPrefix:"KUBE_"`
ObjectPatcher ObjectPatcherSettings `envPrefix:"OBJECT_PATCHER_"`
Debug DebugSettings `envPrefix:"DEBUG_"`
Log LogSettings `envPrefix:"LOG_"`
}
Config is the single source of truth for addon-operator configuration. Populate it in stages: NewConfig sets hardcoded defaults, ParseEnv overrides with environment variables, BindFlags registers CLI flags whose defaults are the current cfg values so that an explicit flag always wins. Priority: CLI flags > env vars > hardcoded defaults.
type DebugSettings ¶ added in v1.21.0
type HelmSettings ¶ added in v1.21.0
type KubeSettings ¶ added in v1.21.0
type LogSettings ¶ added in v1.21.0
type ObjectPatcherSettings ¶ added in v1.21.0
type Registerer ¶ added in v1.21.2
type Registerer interface {
Register(key string, help string, defaultValue string,
setter func(key string, newValue string) error,
expirer func(key string, newValue string) time.Duration)
}
Registerer is the minimal runtime-config surface SetupLogging needs to register a hook that updates the log level on the fly. shell-operator's runtime config package implements this interface.