config

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns the path to the configuration file. It checks the JR_CONFIG_PATH environment variable first; otherwise it falls back to an OS-specific default location.

func SaveTo

func SaveTo(cfg *Config, path string) error

SaveTo serialises cfg as indented JSON and writes it to path with 0o600 permissions, creating any missing parent directories.

Types

type AuthConfig

type AuthConfig struct {
	Type         string `json:"type"`
	Username     string `json:"username,omitempty"`
	Token        string `json:"token,omitempty"`
	ClientID     string `json:"client_id,omitempty"`
	ClientSecret string `json:"client_secret,omitempty"`
	TokenURL     string `json:"token_url,omitempty"`
	Scopes       string `json:"scopes,omitempty"`
}

AuthConfig holds authentication credentials for a profile.

type Config

type Config struct {
	Profiles       map[string]Profile `json:"profiles"`
	DefaultProfile string             `json:"default_profile"`
}

Config is the top-level configuration structure persisted to disk.

func LoadFrom

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

LoadFrom reads and parses the config file at path. If the file does not exist, an empty (non-nil) Config is returned without error.

type FlagOverrides

type FlagOverrides struct {
	BaseURL  string
	AuthType string
	Username string
	Token    string
}

FlagOverrides carries values supplied via CLI flags. Empty string means "not set by flag".

type Profile

type Profile struct {
	BaseURL string     `json:"base_url"`
	Auth    AuthConfig `json:"auth"`
}

Profile holds the configuration for a named Jira instance.

type ResolvedConfig

type ResolvedConfig struct {
	BaseURL string
	Auth    AuthConfig
}

ResolvedConfig is the final, merged configuration ready for use.

func Resolve

func Resolve(configPath, profileName string, flags *FlagOverrides) (*ResolvedConfig, error)

Resolve builds a ResolvedConfig by merging sources in priority order: CLI flags > environment variables > config file profile.

The profileName argument selects which profile to load from the config file; an empty string falls back to the DefaultProfile, then "default".

Jump to

Keyboard shortcuts

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