config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config resolves runtime configuration for the sectors CLI.

Precedence (highest first):

  1. an explicit value passed on the command line (--api-key / --base-url)
  2. environment variables (SECTORS_API_KEY / SECTORS_BASE_URL)
  3. the config file at <user-config-dir>/sectors/config.yaml

The config file is intentionally tiny YAML so `sectors auth login` can write it and humans can hand-edit it.

Index

Constants

View Source
const (
	EnvAPIKey  = "SECTORS_API_KEY"
	EnvBaseURL = "SECTORS_BASE_URL"
)

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir returns the directory holding the sectors config file.

func Path

func Path() (string, error)

Path returns the full path to config.yaml.

func ResolveAPIKey

func ResolveAPIKey(flagVal string) (string, error)

ResolveAPIKey applies the precedence rules for the API key. flagVal is the value of --api-key ("" if unset).

func ResolveBaseURL

func ResolveBaseURL(flagVal string) (string, error)

ResolveBaseURL applies precedence for the base URL, returning "" if none is configured (the client then uses its built-in default).

func Save

func Save(f File) (string, error)

Save writes the config file, creating the directory if needed (0700, since it holds a secret).

Types

type File

type File struct {
	APIKey  string `yaml:"api_key,omitempty"`
	BaseURL string `yaml:"base_url,omitempty"`
}

File is the on-disk config shape.

func Load

func Load() (File, error)

Load reads the config file. A missing file is not an error — it returns an empty File so callers can still fall back to flags and env vars.

Jump to

Keyboard shortcuts

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