config

package
v0.1.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllAccounts = "all"
)

Variables

This section is empty.

Functions

func CacheDir

func CacheDir() string

func ConfigDir

func ConfigDir() string

func StateDir

func StateDir() string

Types

type Config

type Config struct {
	BaseURL   string `json:"base_url"`
	AccountID string `json:"account_id,omitempty"`
	// contains filtered or unexported fields
}

func Load

func Load() (*Config, error)

func (*Config) LocalConfig

func (c *Config) LocalConfig() *LocalConfig

LocalConfig returns the discovered local configuration and its trust status.

func (*Config) SaveAccountID

func (c *Config) SaveAccountID(accountID string) error

SaveAccountID stores the default linked-account filter for the effective server without replacing settings for any other server.

func (*Config) SaveBaseURL

func (c *Config) SaveBaseURL(baseURL string) error

SaveBaseURL stores the global server URL while preserving account defaults for every server.

func (*Config) SetFromFlag

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

func (*Config) SourceOf

func (c *Config) SourceOf(key string) Source

func (*Config) TrustLocalConfig

func (c *Config) TrustLocalConfig() error

TrustLocalConfig trusts the current security-sensitive values in the discovered local configuration. A later change produces a different digest and requires trust again.

func (*Config) UntrustLocalConfig

func (c *Config) UntrustLocalConfig() error

UntrustLocalConfig removes trust for the discovered local configuration.

func (*Config) UntrustedLocalConfig

func (c *Config) UntrustedLocalConfig() *LocalConfig

UntrustedLocalConfig returns the local configuration when one of its values is effective for this invocation and the user has not trusted its current contents.

func (*Config) Values

func (c *Config) Values() []Value

type LocalConfig

type LocalConfig struct {
	Path         string `json:"path"`
	BaseURL      string `json:"base_url,omitempty"`
	AccountID    string `json:"account_id,omitempty"`
	ServerOrigin string `json:"server_origin"`
	Digest       string `json:"digest"`
	Trusted      bool   `json:"trusted"`
}

LocalConfig describes the security-sensitive settings supplied by the nearest repository-local .hey/config.json file.

type OldConfig

type OldConfig struct {
	BaseURL       string `json:"base_url"`
	AccessToken   string `json:"access_token,omitempty"`
	RefreshToken  string `json:"refresh_token,omitempty"`
	TokenExpiry   int64  `json:"token_expiry,omitempty"`
	ClientID      string `json:"client_id,omitempty"`
	ClientSecret  string `json:"client_secret,omitempty"`
	InstallID     string `json:"install_id,omitempty"`
	SessionCookie string `json:"session_cookie,omitempty"`
}

OldConfig represents the legacy config format with embedded credentials. Used only for migration.

func LoadOld

func LoadOld() (*OldConfig, error)

LoadOld reads the config file as the old format (with embedded credentials). Used only during migration.

type Source

type Source string
const (
	SourceDefault Source = "default"
	SourceGlobal  Source = "global"
	SourceLocal   Source = "local"
	SourceEnv     Source = "env"
	SourceFlag    Source = "flag"
)

type TrustedLocalConfig

type TrustedLocalConfig struct {
	Path         string `json:"path"`
	ServerOrigin string `json:"server_origin"`
	BaseURL      string `json:"base_url,omitempty"`
	AccountID    string `json:"account_id,omitempty"`
	Digest       string `json:"digest"`
}

TrustedLocalConfig identifies a repository-local configuration trusted by this user.

func TrustedLocalConfigs

func TrustedLocalConfigs() ([]TrustedLocalConfig, error)

TrustedLocalConfigs returns the local configurations trusted in user-level config.

type Value

type Value struct {
	Value  string `json:"value"`
	Source Source `json:"source"`
}

Jump to

Keyboard shortcuts

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