config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMethodForHost added in v0.0.2

func AuthMethodForHost(host string) string

AuthMethodForHost returns the authentication method for a given host ("pat", "oauth", or "").

func ClientIDForHost added in v0.0.5

func ClientIDForHost(host string) string

ClientIDForHost returns the stored OAuth client ID for a given host.

func ConfigDir

func ConfigDir() string

ConfigDir returns the directory where config files are stored.

func DefaultHost

func DefaultHost() string

DefaultHost returns "gitlab.com" or the value of GITLAB_HOST env var.

func GetHostValue added in v0.0.5

func GetHostValue(host, key string) (string, error)

GetHostValue returns a per-host config value by key.

func HostKeys added in v0.0.5

func HostKeys() []string

HostKeys returns valid per-host config keys.

func Keys

func Keys() []string

Keys returns all valid config keys.

func OAuthScopesForHost added in v0.0.8

func OAuthScopesForHost(host string) string

OAuthScopesForHost returns the stored OAuth scopes for a given host.

func RedirectURIForHost added in v0.0.7

func RedirectURIForHost(host string) string

RedirectURIForHost returns the stored OAuth redirect URI for a given host.

func SaveHosts

func SaveHosts(hosts HostsConfig) error

SaveHosts writes the hosts configuration to disk.

func SetHostValue added in v0.0.5

func SetHostValue(host, key, value string) error

SetHostValue sets a per-host config value by key.

func TokenForHost

func TokenForHost(host string) (string, string)

TokenForHost returns the authentication token for a given host. Environment-variable tokens are scoped to the default host to prevent them from being forwarded to AI-supplied arbitrary host names.

Types

type Config

type Config struct {
	Editor      string `json:"editor,omitempty"`
	Pager       string `json:"pager,omitempty"`
	Browser     string `json:"browser,omitempty"`
	Protocol    string `json:"protocol,omitempty"` // "https" or "ssh"
	GitRemote   string `json:"git_remote,omitempty"`
	DefaultHost string `json:"default_host,omitempty"`
}

Config holds the application configuration.

func Load

func Load() (*Config, error)

Load reads the config file from disk.

func (*Config) Get

func (c *Config) Get(key string) (string, error)

Get returns a config value by key name.

func (*Config) Save

func (c *Config) Save() error

Save writes the config to disk.

func (*Config) Set

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

Set updates a config value by key name and persists it to disk.

type HostConfig

type HostConfig struct {
	Token          string `json:"token"`
	RefreshToken   string `json:"refresh_token,omitempty"`
	TokenExpiresAt int64  `json:"token_expires_at,omitempty"`
	TokenCreatedAt int64  `json:"token_created_at,omitempty"`
	User           string `json:"user,omitempty"`
	Protocol       string `json:"protocol,omitempty"`
	APIHost        string `json:"api_host,omitempty"`
	AuthMethod     string `json:"auth_method,omitempty"` // "pat" or "oauth"
	ClientID       string `json:"client_id,omitempty"`
	RedirectURI    string `json:"redirect_uri,omitempty"`
	OAuthScopes    string `json:"oauth_scopes,omitempty"`
	GitLabVersion  string `json:"gitlab_version,omitempty"`
}

HostConfig stores per-host authentication and settings.

type HostsConfig

type HostsConfig map[string]*HostConfig

HostsConfig maps hostnames to their configurations.

func LoadHosts

func LoadHosts() (HostsConfig, error)

LoadHosts reads the hosts configuration from disk.

Jump to

Keyboard shortcuts

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