cliconfig

package
v0.15.14 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Keys = []string{"dashboard_url", "api_url"}

Keys are all of the allowed keys in the Context section.

Functions

func IsConfigured

func IsConfigured() bool

IsConfigured returns true if a Common Fate config file exists and contains a non-empty current context.

config.Load() is called to load the config file.

func Save

func Save(cfg *Config) error

Types

type Config

type Config struct {
	CurrentContext string `toml:"current_context" json:"current_context"`
	// Contexts allows multiple Common Fate tenancies to be switched between easily.
	// We don't have official support for this yet in the CLI,
	// but the config structure supports it so that it can be easily added in future.
	Contexts map[string]Context `toml:"context" json:"context"`
}

func Default

func Default() *Config

Default returns an empty config.

func Load

func Load() (*Config, error)

func (Config) Current

func (c Config) Current() (*Context, error)

Current loads the current context as specified in the 'current_context' field in the config file. It returns an error if there are no contexts, or if the 'current_context' field doesn't match any contexts defined in the config file.

func (Config) CurrentOrEmpty

func (c Config) CurrentOrEmpty() Context

CurrentOrEmpty returns the current context, or an empty context if it can't be found.

func (Config) DashboardURLs

func (c Config) DashboardURLs() []string

DashboardURLs returns all of the dashboard URLs available across different contexts.

type Context

type Context struct {
	DashboardURL   string `toml:"dashboard_url" json:"dashboard_url"`
	APIURL         string `toml:"api_url,omitempty" json:"api_url,omitempty"`
	RegistryAPIURL string `toml:"registry_api_url,omitempty" json:"registry_api_url,omitempty"`
}

func CurrentContext

func CurrentContext() (*Context, error)

CurrentContext is a shorthand function which calls Load() to load the configuration, and then calls cfg.Current() to get the current API context. It returns an error if either method fails.

func (Context) FetchExports

func (c Context) FetchExports(ctx context.Context) (*Exports, error)

FetchExports fetches and parses the aws-exports.json from CloudFront.

type Exports

type Exports struct {
	AuthURL        string `toml:"auth_url" json:"auth_url"`
	TokenURL       string `toml:"token_url" json:"token_url"`
	APIURL         string `toml:"api_url" json:"api_url"`
	RegistryAPIURL string `toml:"registry_api_url" json:"registry_api_url"`
	ClientID       string `toml:"client_id" json:"client_id"`
	DashboardURL   string `toml:"dashboard_url" json:"dashboard_url"`
}

Exports are public configuration variables related to a Common Fate tenancy.

func (Exports) OAuthConfig

func (e Exports) OAuthConfig() *oauth2.Config

Jump to

Keyboard shortcuts

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