Documentation
¶
Overview ¶
Package gcloud is a thin wrapper around the gcloud CLI. Everything that touches gcloud goes through Runner so it can be faked in tests by pointing the binary at a stub on PATH.
Index ¶
- Constants
- func ActiveFromEnv() string
- type Configuration
- type Runner
- func (r Runner) Activate(name string) error
- func (r Runner) Create(name string) error
- func (r Runner) Exists(name string) (bool, error)
- func (r Runner) Get(name string) (Configuration, error)
- func (r Runner) List() ([]Configuration, error)
- func (r Runner) SetProperty(config, key, value string) error
Constants ¶
const EnvActiveConfig = "CLOUDSDK_ACTIVE_CONFIG_NAME"
EnvActiveConfig is the variable gcloud reads to pick the active configuration for a single invocation. Exporting it in a shell is how we switch profiles per-shell without mutating gcloud's global state.
Variables ¶
This section is empty.
Functions ¶
func ActiveFromEnv ¶
func ActiveFromEnv() string
ActiveFromEnv returns the profile selected via the environment, if any.
Types ¶
type Configuration ¶
type Configuration struct {
Name string `json:"name"`
IsActive bool `json:"is_active"`
Properties map[string]map[string]string `json:"properties"`
}
Configuration mirrors a single entry from `gcloud config configurations list --format=json`.
func (Configuration) Account ¶
func (c Configuration) Account() string
Account returns the core/account property, or "" if unset.
func (Configuration) Project ¶
func (c Configuration) Project() string
Project returns the core/project property, or "" if unset.
type Runner ¶
type Runner struct {
// Bin is the gcloud executable to run. Defaults to "gcloud".
Bin string
}
Runner executes gcloud commands. The zero value runs the "gcloud" binary found on PATH.
func (Runner) Get ¶
func (r Runner) Get(name string) (Configuration, error)
Get returns the named configuration.
func (Runner) List ¶
func (r Runner) List() ([]Configuration, error)
List returns all gcloud configurations.
func (Runner) SetProperty ¶
SetProperty sets a config property (e.g. "project", "account") on a specific configuration without changing the active one.