config

package
v0.0.259 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func NewContext

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

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

Types

type Config

type Config struct {
	APIBaseURL   string `yaml:"-"`
	RegistryHost string `yaml:"-"`

	AccessToken   string `yaml:"access_token"`
	VerboseOutput bool   `yaml:"-"`
	JSONOutput    bool   `yaml:"-"`
	LogGQLErrors  bool   `yaml:"-"`
	Organization  string `yaml:"-"`
	LocalOnly     bool   `yaml:"-"`
}

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.

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