config

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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"
	// KeyConsoleURL is the config key for the web console base URL.
	KeyConsoleURL = "console_url"
)

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) APIKey

func (c *Config) APIKey() string

APIKey returns the management api key from config/env/flags.

func (*Config) AccountID

func (c *Config) AccountID() string

AccountID returns the account ID from config/env/flags.

func (*Config) ActiveContext

func (c *Config) ActiveContext() string

ActiveContext returns the active context name: --context flag if set, else current_context.

func (*Config) BindPFlag

func (c *Config) BindPFlag(key string, flag *pflag.Flag)

BindPFlag binds a viper key to a pflag.Flag.

func (*Config) ConfigFilePath

func (c *Config) ConfigFilePath() string

ConfigFilePath returns the path to the loaded config file.

func (*Config) ConsoleURL added in v0.25.0

func (c *Config) ConsoleURL() string

ConsoleURL returns the web console base URL from config/env/flags.

func (*Config) ContextNames

func (c *Config) ContextNames() []string

ContextNames returns a sorted list of all context names.

func (*Config) CurrentContext

func (c *Config) CurrentContext() string

CurrentContext returns the current_context value from the config file.

func (*Config) DeleteContext

func (c *Config) DeleteContext(name string)

DeleteContext removes a named context from the file data. If the deleted context is the current_context, it is also cleared.

func (*Config) Endpoint

func (c *Config) Endpoint() string

Endpoint returns the API endpoint from config/env/flags.

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

func (c *Config) JSONOutput() bool

JSONOutput returns whether JSON output is enabled.

func (*Config) Load

func (c *Config) Load(configPath string) error

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

func (c *Config) SetAPIKey(k string)

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

func (c *Config) SetAccountID(id string)

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

func (c *Config) SetCurrentContext(name string)

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

func (c *Config) WriteToFile() error

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.

Jump to

Keyboard shortcuts

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