config

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var BuildTime = "unknown"
View Source
var ErrNotLoggedIn = errors.New("not logged in")
View Source
var GitCommit = "unknown"
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 GetConfigFile

func GetConfigFile(dir string) string

func GetDefaultConfigDir

func GetDefaultConfigDir() string

func GetServiceName

func GetServiceName() string

GetServiceName returns the appropriate service name for keyring operations

func SetTestServiceName

func SetTestServiceName(t *testing.T)

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

func ValidConfigOptionValues(key string) []string

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

func ValidOutputFormats(extra ...string) []string

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

func ValidateOutputFormat(format string, extra ...string) error

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

func Load(flags *pflag.FlagSet) (*Config, error)

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

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

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

func (c *Config) EnsureConfigDir() (string, error)

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 (c *Config) GetConfigFile() string

func (*Config) GetStoredCredentials

func (c *Config) GetStoredCredentials() (*Credentials, error)

func (*Config) RemoveCredentials

func (c *Config) RemoveCredentials() error

RemoveCredentials removes stored credentials from keyring and file fallback

func (*Config) Reset

func (c *Config) Reset() error

func (*Config) Set

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

func (*Config) StoreCredentials

func (c *Config) StoreCredentials(apiKey, projectID string) error

StoreCredentials stores a PAT credential.

func (*Config) StoreCredentialsToFile

func (c *Config) StoreCredentialsToFile(apiKey, projectID string) error

StoreCredentialsToFile stores credentials to file (test helper)

func (*Config) StoreOAuthCredentials

func (c *Config) StoreOAuthCredentials(token *oauth2.Token, projectID string) error

StoreOAuthCredentials stores an OAuth token (access + refresh + expiry) and project ID. Use this for the PKCE login path; use StoreCredentials for PAT.

func (*Config) Unset

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

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.

type Credentials

type Credentials struct {
	APIKey    string
	OAuth     *oauth2.Token
	ProjectID string
}

Credentials is the resolved form of what's in keyring/file. Exactly one of APIKey (PAT) or OAuth (PKCE) is populated.

Jump to

Keyboard shortcuts

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