Documentation
¶
Index ¶
- type Config
- type ConfigOptions
- type Context
- type Manager
- func (m *Manager) DeleteContext(name string) error
- func (m *Manager) GetConfigValue(key string) any
- func (m *Manager) GetContext(name string) (*Context, error)
- func (m *Manager) GetContexts() []Context
- func (m *Manager) GetDefaultContextName() string
- func (m *Manager) GetEndpoint(context string) string
- func (m *Manager) GetGlobalConfig() ConfigOptions
- func (m *Manager) GetResolvedBoolValue(cmd *cobra.Command, flagName string) (bool, error)
- func (m *Manager) GetResolvedIntValue(cmd *cobra.Command, flagName string) (int, error)
- func (m *Manager) GetResolvedStringSliceValue(cmd *cobra.Command, flagName string) ([]string, error)
- func (m *Manager) GetResolvedStringValue(cmd *cobra.Command, flagName string) (string, error)
- func (m *Manager) GetToken(context string) string
- func (m *Manager) GetVerbose(cmd *cobra.Command) bool
- func (m *Manager) IsDefaultContext(name string) (bool, error)
- func (m *Manager) Load() error
- func (m *Manager) Save() error
- func (m *Manager) SetConfig(config *Config)
- func (m *Manager) SetContext(ctx Context) error
- func (m *Manager) SetDefaultContext(name string) error
- func (m *Manager) UpdateContextConfig(contextName string, configOptions ConfigOptions) error
- func (m *Manager) UpdateGlobalConfig(configOptions ConfigOptions)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
GlobalConfig ConfigOptions `yaml:"globalConfig"`
DefaultContext string `yaml:"defaultContext"`
Contexts []Context `yaml:"contexts"`
}
Config represents srvctl configuration
type ConfigOptions ¶
ConfigOptions represents a map of configuration options
type Context ¶
type Context struct {
Name string `yaml:"name"`
Endpoint string `yaml:"endpoint"`
Token string `yaml:"token"`
Config ConfigOptions `yaml:"config"`
}
Context manages srvctl configuration
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager represents a configuration manager
func NewManager ¶
NewManager creates a new Manager
func NewManagerWithConfig ¶ added in v0.3.2
NewManagerWithConfig returns a new Manager with specified config
func (*Manager) DeleteContext ¶
DeleteContext deletes a context by name.
func (*Manager) GetConfigValue ¶
GetConfigValue returns config value for default context or global value
func (*Manager) GetContext ¶
GetContext returns a context by name
func (*Manager) GetContexts ¶
GetContexts returns all contexts from the config
func (*Manager) GetDefaultContextName ¶
GetDefaultContextName returns the name of the default context
func (*Manager) GetEndpoint ¶
GetEndpoint returns endpoint for specified context or for default context if empty context passed
func (*Manager) GetGlobalConfig ¶
func (m *Manager) GetGlobalConfig() ConfigOptions
GetGlobalConfig returns global config options
func (*Manager) GetResolvedBoolValue ¶
GetResolvedBoolValue returns resolved bool value for a given config key. By resolved means value is taken from command line flag if provided or else from config file or default value.
func (*Manager) GetResolvedIntValue ¶
GetResolvedIntValue returns resolved int value for a given config key. By resolved means value is taken from command line flag if provided or else from config file or default value.
func (*Manager) GetResolvedStringSliceValue ¶ added in v0.2.0
func (m *Manager) GetResolvedStringSliceValue(cmd *cobra.Command, flagName string) ([]string, error)
GetResolvedStringSliceValue returns resolved slice of string value for a given config key. By resolved means value is taken from command line flag if provided or else from config file or default value.
func (*Manager) GetResolvedStringValue ¶
GetResolvedStringValue returns resolved string value for a given config key. By resolved means value is taken from command line flag if provided or else from config file or default value.
func (*Manager) GetToken ¶
GetToken returns token for specified context or for default context if empty context passed
func (*Manager) GetVerbose ¶
GetVerbose reads verbose flag from cmd or from config
func (*Manager) IsDefaultContext ¶
IsDefaultContext checks if the given context is the default context
func (*Manager) Load ¶
Load loads config. If config file or config dir doesn't exist it will be created.
func (*Manager) SetContext ¶
SetContext adds new context to config or updates existing one
func (*Manager) SetDefaultContext ¶
SetDefaultContext sets the default context
func (*Manager) UpdateContextConfig ¶
func (m *Manager) UpdateContextConfig(contextName string, configOptions ConfigOptions) error
UpdateContextConfig updates context config
func (*Manager) UpdateGlobalConfig ¶
func (m *Manager) UpdateGlobalConfig(configOptions ConfigOptions)
UpdateGlobalConfig updates global config