Documentation
¶
Index ¶
- Constants
- Variables
- func GetConfigFile(dir string) string
- func GetDefaultConfigDir() string
- func GetServiceName() string
- func SetTestServiceName(t *testing.T)
- func ValidConfigOptionValues(key string) []string
- func ValidConfigOptions() []string
- func ValidOutputFormats(extra ...string) []string
- func ValidPasswordStorageOptions() []string
- func ValidateOutputFormat(format string, extra ...string) error
- type Config
- func (c *Config) EnsureConfigDir() (string, error)
- func (c *Config) GetConfigFile() string
- func (c *Config) GetStoredCredentials() (*Credentials, error)
- func (c *Config) RemoveCredentials() error
- func (c *Config) Reset() error
- func (c *Config) Set(key, value string) error
- func (c *Config) StoreCredentials(apiKey, projectID string) error
- func (c *Config) StoreCredentialsToFile(apiKey, projectID string) error
- func (c *Config) StoreOAuthCredentials(token *oauth2.Token, projectID string) error
- func (c *Config) Unset(key string) error
- type ConfigOutput
- type Credentials
Constants ¶
const ( ConfigFileName = "config.yaml" DefaultAPIURL = "https://console.cloud.tigerdata.com/public/api/v1" DefaultAnalytics = true DefaultColor = true DefaultConsoleURL = "https://console.cloud.tigerdata.com" DefaultDocsMCP = true DefaultDocsMCPURL = "https://mcp.tigerdata.com/docs?disabled_skills=ghost-database" DefaultGatewayURL = "https://console.cloud.tigerdata.com/api" DefaultMCPMaxRows = 100 DefaultOutput = "table" DefaultPasswordStorage = "keyring" DefaultReadOnly = false DefaultReleasesURL = "https://cli.tigerdata.com" DefaultVersionCheck = true // TigerCLIClientID is the OAuth client identifier registered with // savannah-gateway's /idp/external/cli/token endpoint. Used for both the // initial PKCE flow and refresh-token grants. TigerCLIClientID = "45e1b16d-e435-4049-97b2-8daad150818c" )
Variables ¶
var BuildTime = "unknown"
var ErrNotLoggedIn = errors.New("not logged in")
var GitCommit = "unknown"
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 GetConfigFile ¶
func GetDefaultConfigDir ¶
func GetDefaultConfigDir() string
func GetServiceName ¶
func GetServiceName() string
GetServiceName returns the appropriate service name for keyring operations
func SetTestServiceName ¶
SetTestServiceName sets a unique service name for testing based on the test name This allows tests to use unique service names to avoid conflicts when running in parallel The cleanup is automatically registered with t.Cleanup()
func ValidConfigOptionValues ¶
ValidConfigOptionValues returns known completion values for a config key's value, or nil if the key doesn't have a fixed set of values.
func ValidConfigOptions ¶
func ValidConfigOptions() []string
func ValidOutputFormats ¶
ValidOutputFormats returns the universally supported output formats plus any command-specific extras (`env`, `bare`).
func ValidPasswordStorageOptions ¶
func ValidPasswordStorageOptions() []string
ValidPasswordStorageOptions returns the accepted values for password_storage.
func ValidateOutputFormat ¶
ValidateOutputFormat checks format against the universally supported formats plus any command-specific extras.
Types ¶
type Config ¶
type Config struct {
APIURL string `mapstructure:"api_url"`
Analytics bool `mapstructure:"analytics"`
Color bool `mapstructure:"color"`
ConsoleURL string `mapstructure:"console_url"`
DocsMCP bool `mapstructure:"docs_mcp"`
DocsMCPURL string `mapstructure:"docs_mcp_url"`
GatewayURL string `mapstructure:"gateway_url"`
MCPMaxRows int `mapstructure:"mcp_max_rows"`
Output string `mapstructure:"output"`
PasswordStorage string `mapstructure:"password_storage"`
ReadOnly bool `mapstructure:"read_only"`
ReleasesURL string `mapstructure:"releases_url"`
ServiceID string `mapstructure:"service_id"`
VersionCheck bool `mapstructure:"version_check"`
ConfigDir string `mapstructure:"-"`
// contains filtered or unexported fields
}
Config holds the effective configuration for a single command invocation, resolved through viper's normal precedence (flag > env > file > default).
func Load ¶
Load creates a new Config instance. The provided flag set is used to resolve the effective config directory (via the config-dir flag) and to bind the CLI flags in flagBindings so they override file/env values. It may be nil for callers that have no flags to apply.
func UseTestConfig ¶
UseTestConfig writes only the specified key-value pairs to the config file in the given directory and returns a Config instance loaded from it. 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) EnsureConfigDir ¶
EnsureConfigDir creates the config directory if it does not already exist and returns the path to the config file within it.
func (*Config) GetConfigFile ¶
func (*Config) GetStoredCredentials ¶
func (c *Config) GetStoredCredentials() (*Credentials, error)
func (*Config) RemoveCredentials ¶
RemoveCredentials removes stored credentials from keyring and file fallback
func (*Config) StoreCredentials ¶
StoreCredentials stores a PAT credential.
func (*Config) StoreCredentialsToFile ¶
StoreCredentialsToFile stores credentials to file (test helper)
func (*Config) StoreOAuthCredentials ¶
StoreOAuthCredentials stores an OAuth token (access + refresh + expiry) and project ID. Use this for the PKCE login path; use StoreCredentials for PAT.
type ConfigOutput ¶
type ConfigOutput struct {
APIURL *string `mapstructure:"api_url" json:"api_url,omitempty"`
Analytics *bool `mapstructure:"analytics" json:"analytics,omitempty"`
Color *bool `mapstructure:"color" json:"color,omitempty"`
ConfigDir *string `mapstructure:"-" json:"config_dir,omitempty"`
ConsoleURL *string `mapstructure:"console_url" json:"console_url,omitempty"`
DocsMCP *bool `mapstructure:"docs_mcp" json:"docs_mcp,omitempty"`
DocsMCPURL *string `mapstructure:"docs_mcp_url" json:"docs_mcp_url,omitempty"`
GatewayURL *string `mapstructure:"gateway_url" json:"gateway_url,omitempty"`
MCPMaxRows *int `mapstructure:"mcp_max_rows" json:"mcp_max_rows,omitempty"`
Output *string `mapstructure:"output" json:"output,omitempty"`
PasswordStorage *string `mapstructure:"password_storage" json:"password_storage,omitempty"`
ReadOnly *bool `mapstructure:"read_only" json:"read_only,omitempty"`
ReleasesURL *string `mapstructure:"releases_url" json:"releases_url,omitempty"`
ServiceID *string `mapstructure:"service_id" json:"service_id,omitempty"`
VersionCheck *bool `mapstructure:"version_check" json:"version_check,omitempty"`
}
ConfigOutput is the shape `tiger config show` renders. Every field is a pointer so unset values can be omitted when defaults are suppressed.
func LoadForOutput ¶
func LoadForOutput(configDir string, withEnv bool, noDefaults bool) (*ConfigOutput, error)
LoadForOutput loads config values for display purposes using a fresh viper instance, independent of CLI flags. This keeps `tiger config show -o json` from reporting the flag's format as the configured `output` value.