providerconfig

package
v0.0.0-...-7f9a76f Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: BSD-3-Clause Imports: 7 Imported by: 2

Documentation

Overview

Package providerconfig provides configuration types for providers.

Index

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 MaskToken

func MaskToken(token string) string

MaskToken returns a masked version of a token for display.

func PrintTokenHelp

func PrintTokenHelp(w io.Writer, lc LoginConfig)

PrintTokenHelp displays formatted guidance for getting a token.

func PromptToken

func PromptToken(r io.Reader, w io.Writer, lc LoginConfig) (string, error)

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 NewConfig

func NewConfig() Config

NewConfig creates a new config.

func (Config) Get

func (c Config) Get(key string) any

Get gets an option.

func (Config) GetBool

func (c Config) GetBool(key string) bool

GetBool gets a bool option.

func (Config) GetInt

func (c Config) GetInt(key string) int

GetInt gets an int option.

func (Config) GetIntWithDefault

func (c Config) GetIntWithDefault(key string, defaultVal int) int

GetIntWithDefault gets an int option with a default value.

func (Config) GetString

func (c Config) GetString(key string) string

GetString gets a string option.

func (Config) GetStringSlice

func (c Config) GetStringSlice(key string) []string

GetStringSlice gets a string slice option.

func (Config) GetStringWithDefault

func (c Config) GetStringWithDefault(key, defaultVal string) string

GetStringWithDefault gets a string option with a default value.

func (Config) Has

func (c Config) Has(key string) bool

Has checks if a key exists.

func (Config) Keys

func (c Config) Keys() []string

Keys returns all keys.

func (Config) Set

func (c Config) Set(key string, value any) Config

Set sets an option and returns the config for chaining.

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

type ConfigReader interface {
	Read(ctx context.Context) (Config, error)
}

ConfigReader reads config from a source.

type ConfigSource

type ConfigSource interface {
	Path() string
	Exists() bool
}

ConfigSource locates and manages config files.

type ConfigWriter

type ConfigWriter interface {
	Write(ctx context.Context, cfg Config) error
}

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.

Jump to

Keyboard shortcuts

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