config

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIURL      = "https://api.cubepath.com"
	DefaultProfileName = "default"
)

Variables

This section is empty.

Functions

func APIURL

func APIURL(p *Profile) string

APIURL returns the base URL to hit for a given profile, honouring CUBE_API_URL.

func Dir

func Dir() string

func Path

func Path() string

func Save

func Save(cfg *Config) error

Types

type Config

type Config struct {
	CurrentProfile string              `json:"current_profile"`
	Profiles       map[string]*Profile `json:"profiles"`
}

func Load

func Load() (*Config, error)

Load reads and parses the config file, migrating the legacy format on the fly. Returns an error if the file is missing or empty; callers that want to fall back to env vars should use ActiveProfile instead.

func LoadOrEmpty added in v1.2.0

func LoadOrEmpty() *Config

LoadOrEmpty returns the parsed config or an empty one if no file exists yet.

func (*Config) ActiveProfile added in v1.2.0

func (c *Config) ActiveProfile(explicit string) (*Profile, string, error)

ActiveProfile returns the profile that should serve the current invocation. If CUBE_API_TOKEN is set, it synthesizes an ephemeral profile so env-based auth keeps working even without a config file.

func (*Config) ActiveProfileName added in v1.2.0

func (c *Config) ActiveProfileName(explicit string) string

ActiveProfileName resolves which profile should be used, in order: explicit name > CUBE_PROFILE env > cfg.CurrentProfile > "default".

func (*Config) ProfileNames added in v1.2.0

func (c *Config) ProfileNames() []string

type Profile added in v1.2.0

type Profile struct {
	APIToken string `json:"api_token"`
	APIURL   string `json:"api_url,omitempty"`
}

Jump to

Keyboard shortcuts

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