Documentation
¶
Index ¶
- Constants
- func DefaultConfigPath() string
- type Config
- func (c *Config) APIKey() string
- func (c *Config) AccountID() string
- func (c *Config) ActiveContext() string
- func (c *Config) BindPFlag(key string, flag *pflag.Flag)
- func (c *Config) ConfigFilePath() string
- func (c *Config) ContextNames() []string
- func (c *Config) CurrentContext() string
- func (c *Config) DeleteContext(name string)
- func (c *Config) Endpoint() string
- func (c *Config) GetContext(name string) (ContextEntry, bool)
- func (c *Config) JSONOutput() bool
- func (c *Config) Load(configPath string) error
- func (c *Config) SetAPIKey(k string)
- func (c *Config) SetAccountID(id string)
- func (c *Config) SetCurrentContext(name string)
- func (c *Config) UpsertContext(ctx ContextEntry)
- func (c *Config) WriteToFile() error
- type ContextEntry
- type File
Constants ¶
const ( // KeyAPIKey is the config key for the Management API key. KeyAPIKey = "api_key" // KeyAccountID is the config key for the account ID. KeyAccountID = "account_id" // KeyEndpoint is the config key for the API endpoint. KeyEndpoint = "endpoint" )
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigPath ¶
func DefaultConfigPath() string
DefaultConfigPath returns the default config file path (~/.config/qcloud/config.yaml). The config file can also be written as config.yaml or config.yml.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config wraps a viper instance to provide typed access to configuration values.
func New ¶
func New() *Config
New creates a new Config backed by a fresh viper instance with defaults applied. No I/O is performed.
func (*Config) ActiveContext ¶
ActiveContext returns the active context name: --context flag if set, else current_context.
func (*Config) ConfigFilePath ¶
ConfigFilePath returns the path to the loaded config file.
func (*Config) ContextNames ¶
ContextNames returns a sorted list of all context names.
func (*Config) CurrentContext ¶
CurrentContext returns the current_context value from the config file.
func (*Config) DeleteContext ¶
DeleteContext removes a named context from the file data. If the deleted context is the current_context, it is also cleared.
func (*Config) GetContext ¶
func (c *Config) GetContext(name string) (ContextEntry, bool)
GetContext returns the ContextEntry for the named context, or false if not found.
func (*Config) JSONOutput ¶
JSONOutput returns whether JSON output is enabled.
func (*Config) Load ¶
Load reads the config file. If configPath is non-empty it is used directly; otherwise QDRANT_CLOUD_CONFIG env var is checked (via viper), then the default ~/.config/qcloud/config.yaml location is used. A missing config file is not an error.
func (*Config) SetAPIKey ¶
SetAPIKey overrides the api key with the highest viper priority. FOR TESTING ONLY: this bypasses the normal config precedence (file → env var → flag) and should not be used in production code paths.
func (*Config) SetAccountID ¶
SetAccountID overrides the account ID with the highest viper priority. FOR TESTING ONLY: this bypasses the normal config precedence (file → env var → flag) and should not be used in production code paths.
func (*Config) SetCurrentContext ¶
SetCurrentContext sets the current_context in the file data.
func (*Config) UpsertContext ¶
func (c *Config) UpsertContext(ctx ContextEntry)
UpsertContext creates or updates a named context in the file data.
func (*Config) WriteToFile ¶
WriteToFile writes file data to the config file. If no file was loaded, it writes to DefaultConfigPath() as YAML.
type ContextEntry ¶
type ContextEntry struct {
Name string `mapstructure:"name" yaml:"name" json:"name"`
Endpoint string `mapstructure:"endpoint" yaml:"endpoint,omitempty" json:"endpoint,omitempty"`
APIKey string `mapstructure:"api_key" yaml:"api_key,omitempty" json:"api_key,omitempty"`
APIKeyCommand string `mapstructure:"api_key_command" yaml:"api_key_command,omitempty" json:"api_key_command,omitempty"`
AccountID string `mapstructure:"account_id" yaml:"account_id,omitempty" json:"account_id,omitempty"`
}
ContextEntry holds the configuration for a single named context.
type File ¶
type File struct {
CurrentContext string `mapstructure:"current_context" yaml:"current_context,omitempty" json:"current_context,omitempty"`
Contexts []ContextEntry `mapstructure:"contexts" yaml:"contexts,omitempty" json:"contexts,omitempty"`
}
File holds the top-level structure of the config file.