config

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MPL-2.0 Imports: 9 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 stores named profiles in ~/.config/gyro/config.toml (0600), aws-style.

default_profile = "default"

[profiles.default]
api_url = "https://www.gyrohosting.com/api/v1/client"
token = "wck_..."            # or token_storage = "keyring" (token lives in the OS keychain)
output = "table"
lang = "tr"

Precedence: command-line flag > environment (GYRO_TOKEN, GYRO_PROFILE, GYRO_API_URL, GYRO_OUTPUT, GYRO_LANG) > profile > built-in default.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path() string

Path returns the config file location (GYRO_CONFIG_FILE overrides).

Types

type File

type File struct {
	DefaultProfile string              `toml:"default_profile,omitempty"`
	Profiles       map[string]*Profile `toml:"profiles"`
	// contains filtered or unexported fields
}

File is the whole config file.

func Load

func Load() (*File, error)

Load reads the config file; a missing file yields an empty config.

func (*File) ActiveName

func (f *File) ActiveName(flag string) string

ActiveName resolves the profile name: flag > GYRO_PROFILE > default_profile > "default".

func (*File) Delete

func (f *File) Delete(name string)

Delete removes a profile (and its keychain entry).

func (*File) FilePath

func (f *File) FilePath() string

FilePath is where Save writes.

func (*File) Get

func (f *File) Get(name string) *Profile

Get returns a profile, creating an empty one in memory when missing.

func (*File) InsecurePerms

func (f *File) InsecurePerms() bool

InsecurePerms reports a config file readable by group/others (unix only).

func (*File) ProfileNames

func (f *File) ProfileNames() []string

ProfileNames returns the sorted profile names.

func (*File) Save

func (f *File) Save() error

Save writes the file atomically with mode 0600 (directory 0700).

func (*File) SetToken

func (f *File) SetToken(name, token string, useKeyring bool) error

SetToken stores a token in the file or in the OS keychain.

func (*File) TokenFor

func (f *File) TokenFor(name string) (token, source string, err error)

TokenFor returns the stored token of a profile (file or keychain) and where it came from.

type Profile

type Profile struct {
	APIURL       string `toml:"api_url,omitempty"`
	Token        string `toml:"token,omitempty"`
	TokenStorage string `toml:"token_storage,omitempty"` // "" / "file" | "keyring"
	Output       string `toml:"output,omitempty"`
	Lang         string `toml:"lang,omitempty"`
	SSHUser      string `toml:"ssh_user,omitempty"`
	SSHIdentity  string `toml:"ssh_identity,omitempty"`
}

Profile is one named set of credentials and preferences.

Jump to

Keyboard shortcuts

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