Documentation
¶
Overview ¶
Package providerconfig provides configuration types for providers.
Index ¶
- func DetectExistingToken(ctx context.Context, mgr ConfigManager, lc LoginConfig) (source, masked string)
- func MaskToken(token string) string
- func PrintTokenHelp(w io.Writer, lc LoginConfig)
- func PromptToken(r io.Reader, w io.Writer, lc LoginConfig) (string, error)
- type Config
- func (c Config) Get(key string) any
- func (c Config) GetBool(key string) bool
- func (c Config) GetInt(key string) int
- func (c Config) GetIntWithDefault(key string, defaultVal int) int
- func (c Config) GetString(key string) string
- func (c Config) GetStringSlice(key string) []string
- func (c Config) GetStringWithDefault(key, defaultVal string) string
- func (c Config) Has(key string) bool
- func (c Config) Keys() []string
- func (c Config) Set(key string, value any) Config
- type ConfigManager
- type ConfigReader
- type ConfigSource
- type ConfigWriter
- type LoginConfig
- type LoginOptions
- type LoginResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectExistingToken ¶
func DetectExistingToken(ctx context.Context, mgr ConfigManager, lc LoginConfig) (source, masked string)
DetectExistingToken checks if a token is already available from environment or config. Returns the source description and masked value, or empty strings if not found.
func PrintTokenHelp ¶
func PrintTokenHelp(w io.Writer, lc LoginConfig)
PrintTokenHelp displays formatted guidance for getting a token.
func PromptToken ¶
PromptToken interactively prompts the user for a token. Returns empty string if cancelled.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds provider configuration.
func (Config) GetIntWithDefault ¶
GetIntWithDefault gets an int option with a default value.
func (Config) GetStringSlice ¶
GetStringSlice gets a string slice option.
func (Config) GetStringWithDefault ¶
GetStringWithDefault gets a string option with a default value.
type ConfigManager ¶
type ConfigManager interface {
ConfigReader
ConfigWriter
ConfigSource
}
ConfigManager combines read and write capabilities. Providers implement this so external code (CLI/Web UI) can configure them.
type ConfigReader ¶
ConfigReader reads config from a source.
type ConfigSource ¶
ConfigSource locates and manages config files.
type ConfigWriter ¶
ConfigWriter writes config to a source.
type LoginConfig ¶
type LoginConfig struct {
Name string // Display name (e.g., "Wrike", "Jira")
EnvVar string // Environment variable name (e.g., "WRIKE_TOKEN")
TokenField string // Field name in config (e.g., "token")
HelpURL string // URL for getting a token
HelpSteps string // Navigation steps to get a token
Scopes string // Required permissions/scopes
TokenPrefix string // Optional token prefix for validation (e.g., "ghp_")
}
LoginConfig holds configuration for a provider's login flow.
type LoginOptions ¶
type LoginOptions struct {
Force bool // Override existing token without prompting
Stdin io.Reader // Input reader (defaults to os.Stdin)
Stdout io.Writer // Output writer (defaults to os.Stdout)
}
LoginOptions configures the login behavior.
type LoginResult ¶
type LoginResult struct {
Token string // The entered token
ConfigPath string // Path where config was saved
Cancelled bool // True if user cancelled
}
LoginResult contains the result of a login attempt.
func RunLogin ¶
func RunLogin(ctx context.Context, mgr ConfigManager, lc LoginConfig, opts LoginOptions) (*LoginResult, error)
RunLogin executes an interactive login flow for a provider.