config

package
v0.0.337-pre-1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileName denotes the name of the config file.
	FileName = "config.yml"

	AccessTokenEnvKey     = envKeyPrefix + "ACCESS_TOKEN"
	AccessTokenFileKey    = "access_token"
	WireGuardStateFileKey = "wire_guard_state"
	APITokenEnvKey        = envKeyPrefix + "API_TOKEN"
)

Variables

This section is empty.

Functions

func Clear

func Clear(path string) (err error)

Clear clears the access token and wireguard-related keys of the configuration file found at path.

func NewContext

func NewContext(ctx context.Context, cfg *Config) context.Context

NewContext derives a Context that carries the given Config from ctx.

func SetAccessToken

func SetAccessToken(path, token string) error

SetAccessToken sets the value of the access token at the configuration file found at path.

Types

type Config

type Config struct {

	// APIBaseURL denotes the base URL of the API.
	APIBaseURL string

	// RegistryHost denotes the docker registry host.
	RegistryHost string

	// VerboseOutput denotes whether the user wants the output to be verbose.
	VerboseOutput bool

	// JSONOutput denotes whether the user wants the output to be JSON.
	JSONOutput bool

	// LogGQLErrors denotes whether the user wants the log GraphQL errors.
	LogGQLErrors bool

	// Organization denotes the organizational slug the user has selected.
	Organization string

	// Region denotes the region slug the user has selected.
	Region string

	// LocalOnly denotes whether the user wants only local operations.
	LocalOnly bool

	// AccessToken denotes the user's access token.
	AccessToken string
	// contains filtered or unexported fields
}

Config wraps the functionality of the configuration file.

Instances of Config are safe for concurrent use.

func FromContext

func FromContext(ctx context.Context) *Config

FromContext returns the Config ctx carries. It panics in case ctx carries no Config.

func New

func New() *Config

New returns a new instance of Config populated with default values.

func (*Config) ApplyEnv

func (cfg *Config) ApplyEnv()

ApplyEnv sets the properties of cfg which may be set via environment variables to the values these variables contain.

ApplyEnv does not change the dirty state of config.

func (*Config) ApplyFile

func (cfg *Config) ApplyFile(path string) (err error)

ApplyFile sets the properties of cfg which may be set via configuration file to the values the file at the given path contains.

func (*Config) ApplyFlags

func (cfg *Config) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags sets the properties of cfg which may be set via command line flags to the values the flags of the given FlagSet may contain.

Jump to

Keyboard shortcuts

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