config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIURL          = "https://console.cloud.timescale.com/public/api/v1"
	DefaultConsoleURL      = "https://console.cloud.timescale.com"
	DefaultGatewayURL      = "https://console.cloud.timescale.com/api"
	DefaultDocsMCP         = true
	DefaultDocsMCPURL      = "https://mcp.tigerdata.com/docs"
	DefaultOutput          = "table"
	DefaultAnalytics       = true
	DefaultPasswordStorage = "keyring"
	DefaultDebug           = false
	ConfigFileName         = "config.yaml"
)

Variables

View Source
var BuildTime = "unknown"
View Source
var ErrNotLoggedIn = errors.New("not logged in")
View Source
var GitCommit = "unknown"
View Source
var ValidOutputFormats = []string{"json", "yaml", "table"}
View Source
var Version = "dev"

These variables are set at build time via ldflags in the GoReleaser pipeline for production releases. Default values are used for local development builds.

Functions

func GetAPIKey

func GetAPIKey() (string, error)

GetAPIKey retrieves the API key from keyring or file fallback

func GetAPIKeyFromFile

func GetAPIKeyFromFile() (string, error)

GetAPIKeyFromFile retrieves API key from ~/.config/tiger/api-key

func GetAPIKeyFromKeyring

func GetAPIKeyFromKeyring() (string, error)

func GetConfigDir

func GetConfigDir() string

TODO: This function is currently used to get the directory that the API key fallback file should be stored in (see api_key.go). But ideally, those functions would take a Config struct and use the ConfigDir field instead.

func GetConfigFile

func GetConfigFile(dir string) string

func GetDefaultConfigDir

func GetDefaultConfigDir() string

func GetEffectiveConfigDir

func GetEffectiveConfigDir(configDirFlag *pflag.Flag) string

func GetServiceName

func GetServiceName() string

GetServiceName returns the appropriate service name for keyring operations Uses a test-specific service name when running in test mode to avoid polluting the real keyring

func RemoveAPIKey

func RemoveAPIKey() error

RemoveAPIKey removes the API key from keyring and file fallback

func RemoveAPIKeyFromFile

func RemoveAPIKeyFromFile() error

RemoveAPIKeyFromFile removes the API key file

func RemoveAPIKeyFromKeyring

func RemoveAPIKeyFromKeyring() error

func ResetGlobalConfig

func ResetGlobalConfig()

ResetGlobalConfig clears the global viper state for testing This is mainly used to reset viper configuration between test runs

func SetupViper

func SetupViper(configDir string) error

SetupViper configures the global Viper instance with defaults, env vars, and config file

func StoreAPIKey

func StoreAPIKey(apiKey string) error

storeAPIKey stores the API key using keyring with file fallback

func StoreAPIKeyToFile

func StoreAPIKeyToFile(apiKey string) error

StoreAPIKeyToFile stores API key to ~/.config/tiger/api-key with restricted permissions

func StoreAPIKeyToKeyring

func StoreAPIKeyToKeyring(apiKey string) error

func ValidateOutputFormat added in v0.2.0

func ValidateOutputFormat(format string) error

Types

type Config

type Config struct {
	APIURL          string `mapstructure:"api_url" yaml:"api_url"`
	ConsoleURL      string `mapstructure:"console_url" yaml:"console_url"`
	GatewayURL      string `mapstructure:"gateway_url" yaml:"gateway_url"`
	DocsMCP         bool   `mapstructure:"docs_mcp" yaml:"docs_mcp"`
	DocsMCPURL      string `mapstructure:"docs_mcp_url" yaml:"docs_mcp_url"`
	ProjectID       string `mapstructure:"project_id" yaml:"project_id"`
	ServiceID       string `mapstructure:"service_id" yaml:"service_id"`
	Output          string `mapstructure:"output" yaml:"output"`
	Analytics       bool   `mapstructure:"analytics" yaml:"analytics"`
	PasswordStorage string `mapstructure:"password_storage" yaml:"password_storage"`
	Debug           bool   `mapstructure:"debug" yaml:"debug"`
	ConfigDir       string `mapstructure:"config_dir" yaml:"-"`
}

func Load

func Load() (*Config, error)

Load creates a new Config instance from the current viper state This function should be called after SetupViper has been called to initialize viper

func UseTestConfig added in v0.5.1

func UseTestConfig(configDir string, values map[string]any) (*Config, error)

UseTestConfig writes only the specified key-value pairs to the config file and returns a Config instance with those values set. This function is intended for testing purposes only, where you need to set up specific config file state without writing default values for unspecified keys.

func (*Config) GetConfigFile added in v0.5.1

func (c *Config) GetConfigFile() string

func (*Config) Reset

func (c *Config) Reset() error

func (*Config) Set

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

func (*Config) Unset

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

Jump to

Keyboard shortcuts

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