Documentation
¶
Index ¶
- Constants
- Variables
- func GetAPIKey() (string, error)
- func GetAPIKeyFromFile() (string, error)
- func GetAPIKeyFromKeyring() (string, error)
- func GetConfigDir() string
- func GetConfigFile(dir string) string
- func GetDefaultConfigDir() string
- func GetEffectiveConfigDir(configDirFlag *pflag.Flag) string
- func GetServiceName() string
- func RemoveAPIKey() error
- func RemoveAPIKeyFromFile() error
- func RemoveAPIKeyFromKeyring() error
- func ResetGlobalConfig()
- func SetupViper(configDir string) error
- func StoreAPIKey(apiKey string) error
- func StoreAPIKeyToFile(apiKey string) error
- func StoreAPIKeyToKeyring(apiKey string) error
- func ValidateOutputFormat(format string) error
- type Config
Constants ¶
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 ¶
var BuildTime = "unknown"
var ErrNotLoggedIn = errors.New("not logged in")
var GitCommit = "unknown"
var ValidOutputFormats = []string{"json", "yaml", "table"}
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 GetAPIKeyFromFile ¶
GetAPIKeyFromFile retrieves API key from ~/.config/tiger/api-key
func GetAPIKeyFromKeyring ¶
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 GetDefaultConfigDir ¶
func GetDefaultConfigDir() string
func GetEffectiveConfigDir ¶
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 ¶
SetupViper configures the global Viper instance with defaults, env vars, and config file
func StoreAPIKey ¶
storeAPIKey stores the API key using keyring with file fallback
func StoreAPIKeyToFile ¶
StoreAPIKeyToFile stores API key to ~/.config/tiger/api-key with restricted permissions
func StoreAPIKeyToKeyring ¶
func ValidateOutputFormat ¶ added in v0.2.0
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:"-"`
}