config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeyClientTimeout defines the viper configuration key used to define client timeout
	KeyClientTimeout = "client-timeout"
	// KeyOutput defines the viper configuration key used to define the output
	KeyOutput = "output"
	// ValueOutputHuman defines the viper configuration value used to define human-readable output
	ValueOutputHuman = "human"
	// ValueOutputYAML defines the viper configuration value used to define YAML output
	ValueOutputYAML = "yaml"
	// ValueOutputJSON defines the viper configuration value used to define JSON output
	ValueOutputJSON = "json"
)

Variables

View Source
var (
	// Version contains the current version.
	Version = "dev"
	// BuildDate contains a string with the build date.
	BuildDate = "unknown"
)

Functions

This section is empty.

Types

type Config

type Config struct {

	// TODO: remove this after refactored
	Service     internal.Wrapper
	GlobalFlags GlobalFlags
	// contains filtered or unexported fields
}

Config holds the configuration for running upctl

func New

func New() *Config

New returns a new instance of Config bound to the given viper instance

func (*Config) BoundFlags

func (s *Config) BoundFlags() []*pflag.Flag

BoundFlags returns the list of all the flags given to the config

func (*Config) ClientTimeout

func (s *Config) ClientTimeout() time.Duration

ClientTimeout is a convenience method that returns the user specified client timeout

func (*Config) ConfigBindFlagSet

func (s *Config) ConfigBindFlagSet(flags *pflag.FlagSet)

ConfigBindFlagSet sets the config flag set and binds them to the viper instance

func (*Config) CreateService

func (s *Config) CreateService() (internal.AllServices, error)

CreateService creates a new service instance and puts in the conf struct

func (*Config) FlagByKey

func (s *Config) FlagByKey(key string) *pflag.Flag

FlagByKey returns pflag.Flag associated with a key in config

func (*Config) Get

func (s *Config) Get(key string) interface{}

Get return the value of the key in the current namespace

func (*Config) GetString

func (s *Config) GetString(key string) string

GetString is a convenience method of getting a configuration value in the current namespace as a string

func (*Config) InteractiveUI

func (s *Config) InteractiveUI() bool

InteractiveUI is a convenience method that returns true if the user has requested human output and the terminal supports it.

func (*Config) IsSet

func (s *Config) IsSet(key string) bool

IsSet return true if the key is set in the current namespace

func (*Config) Load

func (s *Config) Load() error

Load loads config and sets up service

func (*Config) Output

func (s *Config) Output() string

Output is a convenience method for getting the user specified output

func (*Config) OutputHuman

func (s *Config) OutputHuman() bool

OutputHuman is a convenience method that returns true if the user specified human-readable output

func (*Config) Viper

func (s *Config) Viper() *viper.Viper

Viper returns a reference to the viper instance

type GlobalFlags

type GlobalFlags struct {
	ConfigFile    string        `valid:"-"`
	OutputFormat  string        `valid:"in(human|json|yaml)"`
	Colors        bool          `valid:"-"`
	ClientTimeout time.Duration `valid:"-"`
}

GlobalFlags holds information on the flags shared among all commands

Jump to

Keyboard shortcuts

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