config

package
v2.36.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bundle                   = "bundle"
	CPUs                     = "cpus"
	Memory                   = "memory"
	DiskSize                 = "disk-size"
	NameServer               = "nameserver"
	PullSecretFile           = "pull-secret-file"
	DisableUpdateCheck       = "disable-update-check"
	ExperimentalFeatures     = "enable-experimental-features"
	NetworkMode              = "network-mode"
	HostNetworkAccess        = "host-network-access"
	HTTPProxy                = "http-proxy"
	HTTPSProxy               = "https-proxy"
	NoProxy                  = "no-proxy"
	ProxyCAFile              = "proxy-ca-file"
	ConsentTelemetry         = "consent-telemetry"
	EnableClusterMonitoring  = "enable-cluster-monitoring"
	KubeAdminPassword        = "kubeadmin-password"
	Preset                   = "preset"
	EnableSharedDirs         = "enable-shared-dirs"
	SharedDirPassword        = "shared-dir-password" // #nosec G101
	IngressHTTPPort          = "ingress-http-port"
	IngressHTTPSPort         = "ingress-https-port"
	EmergencyLogin           = "enable-emergency-login"
	PersistentVolumeSize     = "persistent-volume-size"
	EnableBundleQuayFallback = "enable-bundle-quay-fallback"
)

Variables

View Source
var ErrSecretsNotAccessible = errors.New("secret store is not accessible")

Functions

func BundleHelpMsg

func BundleHelpMsg(cfg *Config) string

func GetNetworkMode

func GetNetworkMode(config Storage) network.Mode

func GetPreset

func GetPreset(config Storage) preset.Preset

func RegisterSettings

func RegisterSettings(cfg *Config)

func RequiresCRCSetup

func RequiresCRCSetup(key string, _ interface{}) string

func RequiresCleanupAndSetupMsg

func RequiresCleanupAndSetupMsg(key string, _ interface{}) string

func RequiresDeleteAndSetupMsg

func RequiresDeleteAndSetupMsg(key string, _ interface{}) string

func RequiresDeleteMsg

func RequiresDeleteMsg(key string, _ interface{}) string

func RequiresHTTPPortChangeWarning

func RequiresHTTPPortChangeWarning(key string, value interface{}) string

func RequiresHTTPSPortChangeWarning

func RequiresHTTPSPortChangeWarning(key string, value interface{}) string

func RequiresRestartMsg

func RequiresRestartMsg(key string, _ interface{}) string

func SuccessfullyApplied

func SuccessfullyApplied(key string, value interface{}) string

func UpdateDefaults

func UpdateDefaults(cfg *Config)

func ValidateBool

func ValidateBool(value interface{}) (bool, string)

ValidateBool is a fail safe in the case user makes a typo for boolean config values

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func New

func New(storage, secretStorage RawStorage) *Config

func (*Config) AddSetting

func (c *Config) AddSetting(name string, defValue interface{}, validationFn ValidationFnType, callbackFn SetFn, help string)

AddSetting returns a filled struct of ConfigSetting takes the config name and default value as arguments

func (*Config) AllConfigs

func (c *Config) AllConfigs() map[string]SettingValue

AllConfigs returns all the known configs A known config is one which was registered through AddSetting - config with a default value - config with a value set - config with no value set

func (*Config) AllSettings

func (c *Config) AllSettings() []Setting

func (*Config) Get

func (c *Config) Get(key string) SettingValue

func (*Config) RegisterNotifier

func (c *Config) RegisterNotifier(key string, changeNotifier ValueChangedFunc) error

func (*Config) Set

func (c *Config) Set(key string, value interface{}) (string, error)

Set sets the value for a given config key

func (*Config) Unset

func (c *Config) Unset(key string) (string, error)

Unset unsets a given config key

type InMemoryStorage

type InMemoryStorage struct {
	// contains filtered or unexported fields
}

func NewEmptyInMemoryStorage

func NewEmptyInMemoryStorage() *InMemoryStorage

func NewInMemoryStorage

func NewInMemoryStorage(init map[string]interface{}) *InMemoryStorage

func (*InMemoryStorage) Get

func (s *InMemoryStorage) Get(key string) interface{}

func (*InMemoryStorage) Set

func (s *InMemoryStorage) Set(key string, value interface{}) error

func (*InMemoryStorage) Unset

func (s *InMemoryStorage) Unset(key string) error

type Path added in v2.29.0

type Path string

type Path is used for a setting which is a file path

func (Path) String added in v2.29.0

func (p Path) String() string

type RawStorage

type RawStorage interface {
	Get(key string) interface{}
	Set(key string, value interface{}) error
	Unset(key string) error
}

RawStorage stores any key-value pair without validation

type Schema

type Schema interface {
	AddSetting(name string, defValue interface{}, validationFn ValidationFnType, callbackFn SetFn, help string)
}

type Secret

type Secret string

func (Secret) String

func (s Secret) String() string

type SecretStorage

type SecretStorage struct {
	// contains filtered or unexported fields
}

func NewEmptyInMemorySecretStorage

func NewEmptyInMemorySecretStorage() *SecretStorage

func NewSecretStorage

func NewSecretStorage() *SecretStorage

func (*SecretStorage) Get

func (c *SecretStorage) Get(key string) interface{}

func (*SecretStorage) Set

func (c *SecretStorage) Set(key string, value interface{}) error

func (*SecretStorage) Unset

func (c *SecretStorage) Unset(key string) error

type SetFn

type SetFn func(string, interface{}) string

type Setting

type Setting struct {
	Name string

	Help string
	// contains filtered or unexported fields
}

type SettingValue

type SettingValue struct {
	Value     interface{}
	Invalid   bool
	IsDefault bool
	IsSecret  bool
}

func (SettingValue) AsBool

func (v SettingValue) AsBool() bool

func (SettingValue) AsInt

func (v SettingValue) AsInt() int

func (SettingValue) AsString

func (v SettingValue) AsString() string

func (SettingValue) AsUInt

func (v SettingValue) AsUInt() uint

type Storage

type Storage interface {
	Get(key string) SettingValue
	Set(key string, value interface{}) (string, error)
	Unset(key string) (string, error)
	AllConfigs() map[string]SettingValue
}

type ValidationFnType

type ValidationFnType func(interface{}) (bool, string)

validationFnType takes the key, value as args and checks if valid

type ValueChangedFunc

type ValueChangedFunc func(config *Config, key string, value interface{})

type ViperStorage

type ViperStorage struct {
	// contains filtered or unexported fields
}

func NewViperStorage

func NewViperStorage(configFile, envPrefix string) (*ViperStorage, error)

func (*ViperStorage) BindFlagSet

func (c *ViperStorage) BindFlagSet(flagSet *pflag.FlagSet) error

BindFlagset binds a flagset to their respective config properties

func (*ViperStorage) Get

func (c *ViperStorage) Get(key string) interface{}

func (*ViperStorage) Set

func (c *ViperStorage) Set(key string, value interface{}) error

func (*ViperStorage) Unset

func (c *ViperStorage) Unset(key string) error

Jump to

Keyboard shortcuts

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