config

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 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

Overview

Package config loads and persists the proteos CLI's stored credentials and resolves the effective base URL + token for a command, applying the precedence the CLI documents: explicit flag > environment variable > stored file.

Index

Constants

View Source
const (
	EnvURL   = "PROTEOS_URL"
	EnvToken = "PROTEOS_TOKEN"
)

Environment overrides. These let an agent / CI run with no prior `auth login`.

Variables

This section is empty.

Functions

func Delete

func Delete() error

Delete removes the stored credential file (a no-op if it is absent).

func Path

func Path() (string, error)

Path returns the credential file path: $XDG_CONFIG_HOME/proteos/credentials.json, falling back to ~/.config/proteos/credentials.json.

func Save

func Save(c Credentials) error

Save writes credentials to disk with 0600 perms, creating the parent dir 0700.

Types

type Credentials

type Credentials struct {
	BaseURL string `json:"base_url"`
	Token   string `json:"token"`
	Login   string `json:"login,omitempty"`
}

Credentials is the on-disk credential file (mode 0600). Token is a personal access token minted from the browser Settings → CLI tokens page.

func Load

func Load() (Credentials, error)

Load reads the stored credentials. A missing file is not an error — it returns a zero Credentials so first-run / env-only callers work.

Neither is an unlocatable home. For reading, "there is nowhere a credentials file could be" and "there is no credentials file there" are the same answer, and failing the first case breaks the env-only path this CLI documents: callers that export PROTEOS_URL and PROTEOS_TOKEN never wanted the file, and a container or systemd unit that sets neither XDG_CONFIG_HOME nor HOME would otherwise fail every command with "locate home dir" before the variables it was given are even consulted. Save and Delete still surface it, because they genuinely need a path.

type Resolved

type Resolved struct {
	BaseURL   string
	Token     string
	Login     string
	URLSource string
	TokSource string
}

Resolved is the effective configuration for a command after applying precedence, with TokenSource/URLSource recording where each value came from (for `auth status` and diagnostics). Token is never echoed in full.

func Resolve

func Resolve(flagURL string) (Resolved, error)

Resolve computes the effective base URL + token. flagURL (from --url) wins over the environment, which wins over the stored file. The token has no flag in the general case — PROTEOS_TOKEN wins over the stored token.

Jump to

Keyboard shortcuts

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