Documentation
¶
Index ¶
Constants ¶
const LocalBrokerURL = "http://127.0.0.1:8080"
LocalBrokerURL is where `mercator serve` listens unless told otherwise, so it is also where the CLI looks when nothing else names a broker.
const LocalContextName = "local"
LocalContextName is the context `mercator serve` writes for a loopback broker whose token it generated itself.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigPath ¶ added in v0.3.0
DefaultConfigPath resolves where the CLI config lives: MERCATOR_CONFIG, else $XDG_CONFIG_HOME/mercator/config.json, else ~/.config/mercator/config.json.
func WriteLocalContext ¶ added in v0.5.0
WriteLocalContext records how to reach a loopback broker the operator never configured a credential for, so the CLI on the same machine needs no exports to talk to the server they just started. It reports whether the file changed.
It only claims current_context when nothing else has: silently redirecting commands away from an operator's chosen deployment would be far worse than asking them to run `mercator context use local`.
Types ¶
type Config ¶
type Config struct {
// BaseURL, Token, and WorkspaceID are the environment-derived values
// (MERCATOR_API_URL / MERCATOR_API_TOKEN / MERCATOR_WORKSPACE_ID). They
// win over the config file's current context, so CI setups keep working
// with no config file at all.
BaseURL string
Token string
// WorkspaceID is the default workspace applied to run subcommands when
// --workspace-id is not passed. An explicit --workspace-id flag always
// overrides it.
WorkspaceID string
// ConfigPath is where named contexts live (see DefaultConfigPath).
ConfigPath string
Args []string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Client *http.Client
// OpenBrowser overrides how `mercator login` launches the browser
// (injected in tests).
OpenBrowser func(url string) error
}
type ContextConfig ¶ added in v0.3.0
type ContextConfig struct {
APIURL string `json:"api_url,omitempty"`
WorkspaceID string `json:"workspace_id,omitempty"`
APIToken string `json:"api_token,omitempty"`
CLIToken string `json:"cli_token,omitempty"`
CLITokenEmail string `json:"cli_token_email,omitempty"`
CLITokenExpiresAt string `json:"cli_token_expires_at,omitempty"`
}
ContextConfig names one Mercator deployment: where it is, the default workspace, and a credential — either a static API token or a login-minted CLI token tied to a user identity.
type FileConfig ¶ added in v0.3.0
type FileConfig struct {
CurrentContext string `json:"current_context,omitempty"`
Contexts map[string]*ContextConfig `json:"contexts,omitempty"`
}
FileConfig is the on-disk CLI configuration: named contexts (a server plus how to talk to it) and which one is current. Environment variables always win over the file so CI keeps working unchanged.