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
- func Path() (string, error)
- type Config
- func (c *Config) Credential() string
- func (c *Config) Endpoint() string
- func (c *Config) ForgetEnvironment(org, env string) bool
- func (c *Config) ForgetOrgUnlessMember(orgs []string) string
- func (c *Config) Save() error
- func (c *Config) SelectedEnvironment(org, project string) string
- func (c *Config) SelectedOrg() string
- func (c *Config) SelectedProject(org string) string
- func (c *Config) UseEnvironment(org, project, env string)
Constants ¶
const DefaultAPI = "https://api.goship.sh"
Variables ¶
This section is empty.
Functions ¶
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 (*Config) Credential ¶
Credential is the token to send: GOSHIP_TOKEN, for CI and anywhere without a browser, wins over whatever `goship login` stored.
func (*Config) Endpoint ¶
Endpoint is the API to talk to: GOSHIP_API, else the file, else DefaultAPI.
func (*Config) ForgetEnvironment ¶ added in v0.14.0
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 ¶
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 ¶
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
SelectedEnvironment is GOSHIP_ENVIRONMENT, else what `goship environment use` persisted for the project.
func (*Config) SelectedOrg ¶
SelectedOrg is GOSHIP_ORG, else whatever `goship org use` persisted.
func (*Config) SelectedProject ¶ added in v0.5.0
SelectedProject is GOSHIP_PROJECT, else what `goship project use` persisted for org.
func (*Config) UseEnvironment ¶ added in v0.14.0
UseEnvironment persists env as the project's selected environment.