app

package
v1.21.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultTempDir         = "/tmp/addon-operator"
	DefaultDebugUnixSocket = "/var/run/addon-operator/debug.socket"
)

Variables

View Source
var (
	AppName        = "addon-operator"
	AppDescription = ""
	Version        = "dev"

	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

func BindFlags(cfg *Config, rootCmd *cobra.Command, cmd *cobra.Command)

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 DefineDebugCommands(rootCmd *cobra.Command)

func ParseEnv added in v1.21.0

func ParseEnv(cfg *Config) error

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.

Types

type AdmissionSettings added in v1.21.0

type AdmissionSettings struct {
	ListenPort string `env:"ADMISSION_SERVER_LISTEN_PORT"`
	CertsDir   string `env:"ADMISSION_SERVER_CERTS_DIR"`
	Enabled    bool   `env:"ADMISSION_SERVER_ENABLED"`
}

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.

func NewConfig added in v1.21.0

func NewConfig() *Config

type DebugSettings added in v1.21.0

type DebugSettings struct {
	UnixSocket     string `env:"UNIX_SOCKET"`
	HTTPServerAddr string `env:"HTTP_SERVER_ADDR"`
	KeepTmpFiles   bool   `env:"KEEP_TMP_FILES"`
	KubernetesAPI  bool   `env:"KUBERNETES_API"`
}

type HelmSettings added in v1.21.0

type HelmSettings struct {
	HistoryMax    int32         `env:"HISTORY_MAX"`
	Timeout       time.Duration `env:"TIMEOUT"`
	IgnoreRelease string        `env:"IGNORE_RELEASE"`

	MonitorKubeClientQps   float32 `env:"MONITOR_KUBE_CLIENT_QPS"`
	MonitorKubeClientBurst int     `env:"MONITOR_KUBE_CLIENT_BURST"`
}

type KubeSettings added in v1.21.0

type KubeSettings struct {
	Context     string  `env:"CONTEXT"`
	Config      string  `env:"CONFIG"`
	Server      string  `env:"SERVER"`
	ClientQPS   float32 `env:"CLIENT_QPS"`
	ClientBurst int     `env:"CLIENT_BURST"`
}

type LogSettings added in v1.21.0

type LogSettings struct {
	Level         string `env:"LEVEL"`
	Type          string `env:"TYPE"`
	NoTime        bool   `env:"NO_TIME"`
	ProxyHookJSON bool   `env:"PROXY_HOOK_JSON"`
}

type ObjectPatcherSettings added in v1.21.0

type ObjectPatcherSettings struct {
	KubeClientQPS     float32       `env:"KUBE_CLIENT_QPS"`
	KubeClientBurst   int           `env:"KUBE_CLIENT_BURST"`
	KubeClientTimeout time.Duration `env:"KUBE_CLIENT_TIMEOUT"`
}

Jump to

Keyboard shortcuts

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