Documentation
¶
Index ¶
- Constants
- Variables
- func BindFlags(cfg *Config, rootCmd *cobra.Command, cmd *cobra.Command) func()
- func DefineDebugUnixSocketFlag(cmd *cobra.Command)
- func ParseEnv(cfg *Config) error
- func SetupLogging(level string, runtimeConfig Registerer, logger *log.Logger)
- func Validate(cfg *Config) error
- type AdmissionSettings
- type AppSettings
- type Config
- type ConversionSettings
- type DebugSettings
- type KubeSettings
- type LogSettings
- type ObjectPatcherSettings
- type Registerer
Constants ¶
const ( ForcedDurationForDebugLevel = 30 * time.Minute ProxyJsonLogKey = "proxyJsonLog" )
ForcedDurationForDebugLevel - force expiration for debug level.
Variables ¶
var ( AppName = "shell-operator" AppDescription = "Run your custom cluster-wide scripts in reaction to Kubernetes events or on schedule." AppStartMessage = "shell-operator" )
var DebugUnixSocket = "/var/run/shell-operator/debug.socket"
DebugUnixSocket is the default path for the debug unix socket. It is used as the binding target for the --debug-unix-socket flag on debug sub-commands (queue, hook, etc.) that connect to a running operator. For the start command, cfg.Debug.UnixSocket is preferred; see flags.go.
var KubeClientFieldManager = ""
KubeClientFieldManager is the field manager name for server-side apply operations. Set programmatically before Init; not configurable via env or CLI flags.
var Version = "v1.2.0-dev"
Functions ¶
func BindFlags ¶ added in v1.17.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. No env-var lookups are performed here; environment variables are handled exclusively by ParseEnv. An explicit CLI flag always wins.
The returned func must be called after cobra.Execute() to apply []string slice overrides that cannot be handled with a simple default binding.
func DefineDebugUnixSocketFlag ¶
DefineDebugUnixSocketFlag registers the --debug-unix-socket flag on cmd, binding it to the DebugUnixSocket global. Called by debug sub-commands that need to locate the operator's debug socket.
func ParseEnv ¶ added in v1.17.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. Call after NewConfig so the hardcoded defaults serve as the baseline.
func SetupLogging ¶
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.
Types ¶
type AdmissionSettings ¶ added in v1.17.0
type AdmissionSettings struct {
ConfigurationName string `env:"CONFIGURATION_NAME"`
ServiceName string `env:"SERVICE_NAME"`
ServerCert string `env:"SERVER_CERT"`
ServerKey string `env:"SERVER_KEY"`
CA string `env:"CA"`
ClientCA []string `env:"CLIENT_CA" envSeparator:","`
FailurePolicy string `env:"FAILURE_POLICY"`
ListenPort string `env:"LISTEN_PORT"`
ListenAddress string `env:"LISTEN_ADDRESS"`
}
AdmissionSettings holds settings for the validating-webhook server.
type AppSettings ¶ added in v1.17.0
type AppSettings struct {
HooksDir string `env:"HOOKS_DIR"`
TempDir string `env:"TMP_DIR"`
ListenAddress string `env:"LISTEN_ADDRESS"`
ListenPort string `env:"LISTEN_PORT"`
PrometheusMetricsPrefix string `env:"PROMETHEUS_METRICS_PREFIX"`
Namespace string `env:"NAMESPACE"`
}
AppSettings holds shell-operator's primary runtime settings. Defaults are set in NewConfig; env tags declare the variable name only.
type Config ¶ added in v1.17.0
type Config struct {
App AppSettings `envPrefix:"SHELL_OPERATOR_"`
Kube KubeSettings `envPrefix:"KUBE_"`
ObjectPatcher ObjectPatcherSettings `envPrefix:"OBJECT_PATCHER_"`
Admission AdmissionSettings `envPrefix:"VALIDATING_WEBHOOK_"`
Conversion ConversionSettings `envPrefix:"CONVERSION_WEBHOOK_"`
Debug DebugSettings `envPrefix:"DEBUG_"`
Log LogSettings `envPrefix:"LOG_"`
}
Config is the single source of truth for operator configuration. Populate it in stages: NewConfig sets hardcoded defaults, ParseEnv overrides with environment variables, BindFlags (in pkg/app/flags.go) 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 ConversionSettings ¶ added in v1.17.0
type ConversionSettings struct {
ServiceName string `env:"SERVICE_NAME"`
ServerCert string `env:"SERVER_CERT"`
ServerKey string `env:"SERVER_KEY"`
CA string `env:"CA"`
ClientCA []string `env:"CLIENT_CA" envSeparator:","`
ListenPort string `env:"LISTEN_PORT"`
ListenAddress string `env:"LISTEN_ADDRESS"`
}
ConversionSettings holds settings for the conversion-webhook server.
type DebugSettings ¶ added in v1.17.0
type DebugSettings struct {
UnixSocket string `env:"UNIX_SOCKET"`
HTTPServerAddr string `env:"HTTP_SERVER_ADDR"`
KeepTempFiles bool `env:"KEEP_TMP_FILES"`
KubernetesAPI bool `env:"KUBERNETES_API"`
}
DebugSettings holds settings for the debug server.
type KubeSettings ¶ added in v1.17.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"`
}
KubeSettings holds Kubernetes connection parameters.
type LogSettings ¶ added in v1.17.0
type LogSettings struct {
Level string `env:"LEVEL"`
Type string `env:"TYPE"`
NoTime bool `env:"NO_TIME"`
ProxyHookJSON bool `env:"PROXY_HOOK_JSON"`
}
LogSettings holds logging configuration.
type ObjectPatcherSettings ¶ added in v1.17.0
type ObjectPatcherSettings struct {
KubeClientQPS float32 `env:"KUBE_CLIENT_QPS"`
KubeClientBurst int `env:"KUBE_CLIENT_BURST"`
KubeClientTimeout time.Duration `env:"KUBE_CLIENT_TIMEOUT"`
}
ObjectPatcherSettings holds settings for the object-patcher Kubernetes client.