config

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

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

type ConfigOptions = map[string]any

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

func NewManager(configPath string) (*Manager, error)

NewManager creates a new Manager

func NewManagerWithConfig added in v0.3.2

func NewManagerWithConfig(config *Config) *Manager

NewManagerWithConfig returns a new Manager with specified config

func (*Manager) DeleteContext

func (m *Manager) DeleteContext(name string) error

DeleteContext deletes a context by name.

func (*Manager) GetConfigValue

func (m *Manager) GetConfigValue(key string) any

GetConfigValue returns config value for default context or global value

func (*Manager) GetContext

func (m *Manager) GetContext(name string) (*Context, error)

GetContext returns a context by name

func (*Manager) GetContexts

func (m *Manager) GetContexts() []Context

GetContexts returns all contexts from the config

func (*Manager) GetDefaultContextName

func (m *Manager) GetDefaultContextName() string

GetDefaultContextName returns the name of the default context

func (*Manager) GetEndpoint

func (m *Manager) GetEndpoint(context string) string

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

func (m *Manager) GetResolvedBoolValue(cmd *cobra.Command, flagName string) (bool, error)

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

func (m *Manager) GetResolvedIntValue(cmd *cobra.Command, flagName string) (int, error)

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

func (m *Manager) GetResolvedStringValue(cmd *cobra.Command, flagName string) (string, error)

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

func (m *Manager) GetToken(context string) string

GetToken returns token for specified context or for default context if empty context passed

func (*Manager) GetVerbose

func (m *Manager) GetVerbose(cmd *cobra.Command) bool

GetVerbose reads verbose flag from cmd or from config

func (*Manager) IsDefaultContext

func (m *Manager) IsDefaultContext(name string) (bool, error)

IsDefaultContext checks if the given context is the default context

func (*Manager) Load

func (m *Manager) Load() error

Load loads config. If config file or config dir doesn't exist it will be created.

func (*Manager) Save

func (m *Manager) Save() error

Save saves current config to file

func (*Manager) SetConfig

func (m *Manager) SetConfig(config *Config)

SetConfig sets config for manager

func (*Manager) SetContext

func (m *Manager) SetContext(ctx Context) error

SetContext adds new context to config or updates existing one

func (*Manager) SetDefaultContext

func (m *Manager) SetDefaultContext(name string) error

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

Jump to

Keyboard shortcuts

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