config

package
v1.260331.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidConfig = errors.New("invalid configuration")

ErrInvalidConfig is returned when config values fail validation.

View Source
var ErrInvalidPath = errors.New("invalid config path")

ErrInvalidPath is returned when the config path is invalid.

View Source
var ErrNotFound = fmt.Errorf("configuration not found")

ErrNotFound is returned when the config file doesn't exist

Functions

func GlobalPath

func GlobalPath() (string, error)

GlobalPath returns the global configuration file path.

func LocalPath

func LocalPath() (string, error)

LocalPath returns the local configuration file path.

func Path

func Path() (string, error)

Path returns the active configuration file path.

func Remove

func Remove() error

Remove removes the config file

func RemoveAt

func RemoveAt(path string) error

RemoveAt removes the config file at the provided path.

func Save

func Save(cfg *Config) error

Save saves the configuration to the config file

func SaveAt

func SaveAt(path string, cfg *Config) error

SaveAt saves the configuration to the provided path.

Types

type Config

type Config struct {
	KeyID            string             `json:"key_id"`
	IssuerID         string             `json:"issuer_id"`
	PrivateKeyPath   string             `json:"private_key_path"`
	PrivateKeyPEM    string             `json:"-"`
	DefaultKeyName   string             `json:"default_key_name"`
	Keys             []Credential       `json:"keys,omitempty"`
	KeychainMetadata []KeychainMetadata `json:"keychain_metadata,omitempty"`
	AppID            string             `json:"app_id"`

	VendorNumber          string `json:"vendor_number"`
	AnalyticsVendorNumber string `json:"analytics_vendor_number"`
	SkillsCheckedAt       string `json:"skills_checked_at,omitempty"`

	Timeout              DurationValue `json:"timeout"`
	TimeoutSeconds       DurationValue `json:"timeout_seconds"`
	UploadTimeout        DurationValue `json:"upload_timeout"`
	UploadTimeoutSeconds DurationValue `json:"upload_timeout_seconds"`
	MaxRetries           string        `json:"max_retries"`
	BaseDelay            string        `json:"base_delay"`
	MaxDelay             string        `json:"max_delay"`
	RetryLog             string        `json:"retry_log"`
	Debug                string        `json:"debug"`
}

Config holds the application configuration

func Load

func Load() (*Config, error)

Load loads the configuration from the config file

func LoadAt

func LoadAt(path string) (*Config, error)

LoadAt loads the configuration from the provided path.

func (*Config) Validate

func (c *Config) Validate() error

Validate ensures configuration values are parseable and within safe bounds.

type Credential

type Credential struct {
	Name           string `json:"name"`
	KeyID          string `json:"key_id"`
	IssuerID       string `json:"issuer_id"`
	PrivateKeyPath string `json:"private_key_path"`
}

Credential stores a named API credential in config.json.

type DurationValue

type DurationValue struct {
	Duration time.Duration
	Raw      string
}

DurationValue stores a duration with its raw string representation. It marshals to/from JSON as a string to preserve config compatibility.

func ParseDurationValue

func ParseDurationValue(raw string) (DurationValue, error)

ParseDurationValue parses a duration string or seconds value into a DurationValue.

func (DurationValue) MarshalJSON

func (d DurationValue) MarshalJSON() ([]byte, error)

MarshalJSON stores the raw string when available, preserving the config format.

func (DurationValue) String

func (d DurationValue) String() string

String returns the raw string when available, falling back to the duration value.

func (*DurationValue) UnmarshalJSON

func (d *DurationValue) UnmarshalJSON(data []byte) error

UnmarshalJSON parses duration strings or seconds values from JSON.

func (DurationValue) Value

func (d DurationValue) Value() (time.Duration, bool)

Value returns the parsed duration if it's positive.

type KeychainMetadata

type KeychainMetadata struct {
	Name       string `json:"name"`
	KeyID      string `json:"key_id"`
	IssuerID   string `json:"issuer_id"`
	ModifiedAt string `json:"modified_at,omitempty"`
}

KeychainMetadata stores non-secret metadata for keychain-backed credentials.

Jump to

Keyboard shortcuts

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