config

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 15 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        = ReadOnlyOff
	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"
)
View Source
const (
	// KeyringServiceName is the service name for all Tiger CLI keyring
	// entries (stored credentials here, saved service passwords in
	// internal/common).
	KeyringServiceName = "tiger-cli"
)

Keyring parameters

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

ValidConfigOptions returns every settable config key, sorted: shells present completion candidates in the order they are given, so an unsorted list would reshuffle on every keystroke.

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 ValidReadOnlyModes added in v0.23.0

func ValidReadOnlyModes() []string

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        ReadOnlyMode `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 (*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) (string, error)

Set writes a config value and returns it as stored, which isn't always the input: read_only normalizes legacy booleans into modes. Echo the return value to the user, not the argument.

func (*Config) StoreCredentials

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

StoreCredentials stores a PAT credential.

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 {
	Analytics       *bool         `mapstructure:"analytics" json:"analytics,omitempty"`
	APIURL          *string       `mapstructure:"api_url" json:"api_url,omitempty"`
	Color           *bool         `mapstructure:"color" json:"color,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        *ReadOnlyMode `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.

type ReadOnlyMode added in v0.23.0

type ReadOnlyMode string

ReadOnlyMode selects which services read-only mode protects from mutating operations. The legacy booleans map onto it: true is ReadOnlyAll, false is ReadOnlyOff.

const (
	ReadOnlyAll  ReadOnlyMode = "all"  // every service
	ReadOnlyProd ReadOnlyMode = "prod" // only services tagged PROD
	ReadOnlyOff  ReadOnlyMode = "off"  // none
)

func (ReadOnlyMode) BlocksAll added in v0.23.0

func (m ReadOnlyMode) BlocksAll() bool

BlocksAll reports whether the mode blocks writes to every service. It's the only verdict reachable without knowing the target.

Jump to

Keyboard shortcuts

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