config

package
v1.99.4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: Apache-2.0 Imports: 17 Imported by: 1

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"
	AutostartTray           = "autostart-tray"
	KubeAdminPassword       = "kubeadmin-password"
	Preset                  = "preset"
)

Variables

This section is empty.

Functions

func GetNetworkMode added in v1.28.0

func GetNetworkMode(config Storage) network.Mode

func GetPreset added in v1.99.2

func GetPreset(config Storage) preset.Preset

func RegisterSettings added in v1.28.0

func RegisterSettings(cfg *Config)

func RequiresCRCSetup added in v1.23.0

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

func RequiresDeleteAndSetupMsg added in v1.99.2

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

func RequiresDeleteMsg added in v1.99.2

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

func RequiresRestartMsg

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

func SuccessfullyApplied

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

func UpdateDefaults added in v1.99.2

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

func ValidateBundlePath added in v1.23.0

func ValidateBundlePath(value interface{}, preset crcpreset.Preset) (bool, string)

ValidateBundlePath checks if the provided bundle path is valid

func ValidateCPUs

func ValidateCPUs(value interface{}, preset crcpreset.Preset) (bool, string)

ValidateCPUs checks if provided cpus count is valid in the config

func ValidateDiskSize added in v1.20.0

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

ValidateDiskSize checks if provided disk size is valid in the config

func ValidateHTTPProxy added in v1.33.0

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

ValidateHTTPProxy checks if given URI is valid for a HTTP proxy

func ValidateHTTPSProxy added in v1.33.0

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

ValidateHTTPSProxy checks if given URI is valid for a HTTPS proxy

func ValidateIPAddress added in v1.14.0

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

ValidateIP checks if provided IP is valid

func ValidateMemory

func ValidateMemory(value interface{}, preset crcpreset.Preset) (bool, string)

ValidateMemory checks if provided memory is valid in the config

func ValidateNoProxy

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

ValidateNoProxy checks if the NoProxy string has the correct format

func ValidatePath

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

ValidatePath checks if provided path is exist

func ValidateString added in v1.28.0

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

func ValidateYesNo added in v1.21.0

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

Types

type Config added in v1.17.0

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

func New added in v1.17.0

func New(storage RawStorage) *Config

func (*Config) AddSetting added in v1.17.0

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 added in v1.17.0

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 added in v1.23.0

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

func (*Config) Get added in v1.17.0

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

func (*Config) Set added in v1.17.0

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

Set sets the value for a given config key

func (*Config) Unset added in v1.17.0

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

Unset unsets a given config key

type InMemoryStorage added in v1.17.0

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

func NewEmptyInMemoryStorage added in v1.17.0

func NewEmptyInMemoryStorage() *InMemoryStorage

func NewInMemoryStorage added in v1.17.0

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

func (*InMemoryStorage) Get added in v1.17.0

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

func (*InMemoryStorage) Set added in v1.17.0

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

func (*InMemoryStorage) Unset added in v1.17.0

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

type RawStorage added in v1.17.0

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 added in v1.17.0

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

type SetFn

type SetFn func(string, interface{}) string

type Setting added in v1.14.0

type Setting struct {
	Name string

	Help string
	// contains filtered or unexported fields
}

type SettingValue added in v1.17.0

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

func (SettingValue) AsBool added in v1.17.0

func (v SettingValue) AsBool() bool

func (SettingValue) AsInt added in v1.17.0

func (v SettingValue) AsInt() int

func (SettingValue) AsString added in v1.17.0

func (v SettingValue) AsString() string

type Storage added in v1.17.0

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 ViperStorage added in v1.17.0

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

func NewViperStorage added in v1.17.0

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

func (*ViperStorage) BindFlagSet added in v1.17.0

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

BindFlagset binds a flagset to their respective config properties

func (*ViperStorage) Get added in v1.17.0

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

func (*ViperStorage) Set added in v1.17.0

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

func (*ViperStorage) Unset added in v1.17.0

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