config

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 10 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 holds the CLI's per-machine state: the file `goship login` and `goship org use` write, and the GOSHIP_* environment variables that override it.

Index

Constants

View Source
const DefaultAPI = "https://api.goship.sh"

Variables

This section is empty.

Functions

func Path

func Path() (string, error)

Path is the config file location: $GOSHIP_CONFIG, else under $XDG_CONFIG_HOME, else ~/.config.

Types

type Config

type Config struct {
	// API is the GoShip API, the only thing the CLI talks to.
	API string `json:"api,omitempty"`
	Org string `json:"org,omitempty"`
	// Projects is the project `goship project use` selected, per org slug.
	Projects map[string]string `json:"projects,omitempty"`
	// Environments is the environment `goship environment use` selected, per
	// "org/project".
	Environments map[string]string `json:"environments,omitempty"`
	// Token is the credential; TokenID identifies it to the API when it is an
	// API token minted by `goship login`, so `goship logout` can revoke it.
	Token   string `json:"token,omitempty"`
	TokenID string `json:"token_id,omitempty"`
}

Config is what the config file holds, and nothing else: the process environment is read by Endpoint, SelectedOrg, SelectedProject, SelectedEnvironment and Credential, never stored here, so Save cannot write a GOSHIP_TOKEN meant for one CI job to disk.

func Load

func Load() (*Config, error)

Load reads the config file. A missing file is not an error.

func (*Config) Credential

func (c *Config) Credential() string

Credential is the token to send: GOSHIP_TOKEN, for CI and anywhere without a browser, wins over whatever `goship login` stored.

func (*Config) Endpoint

func (c *Config) Endpoint() string

Endpoint is the API to talk to: GOSHIP_API, else the file, else DefaultAPI.

func (*Config) ForgetEnvironment added in v0.14.0

func (c *Config) ForgetEnvironment(org, env string) bool

ForgetEnvironment drops every project of org that had env selected, for an environment that no longer exists, and says whether it dropped any.

func (*Config) ForgetOrgUnlessMember

func (c *Config) ForgetOrgUnlessMember(orgs []string) string

ForgetOrgUnlessMember clears the selected organization when the signed-in identity does not belong to it, returning what was dropped. A pin set under one account is meaningless under another.

func (*Config) Save

func (c *Config) Save() error

Save writes the config file, creating its directory. It holds a bearer token, so the file is owner-only.

func (*Config) SelectedEnvironment added in v0.14.0

func (c *Config) SelectedEnvironment(org, project string) string

SelectedEnvironment is GOSHIP_ENVIRONMENT, else what `goship environment use` persisted for the project.

func (*Config) SelectedOrg

func (c *Config) SelectedOrg() string

SelectedOrg is GOSHIP_ORG, else whatever `goship org use` persisted.

func (*Config) SelectedProject added in v0.5.0

func (c *Config) SelectedProject(org string) string

SelectedProject is GOSHIP_PROJECT, else what `goship project use` persisted for org.

func (*Config) UseEnvironment added in v0.14.0

func (c *Config) UseEnvironment(org, project, env string)

UseEnvironment persists env as the project's selected environment.

Jump to

Keyboard shortcuts

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