config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 5 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

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