config

package
v2.5.2-0...-ba37c77 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSessionValidity = 1800

DefaultSessionValidity is the default for the --session-validity flag

View Source
const VarsDescription = `` /* 899-byte string literal not displayed */

VarsDescription is text suitable for inclusion in commands that manipulate config variables.

Variables

This section is empty.

Functions

func IsConfigVar

func IsConfigVar(name string) bool

IsConfigVar checks to see if the named variable is actually one of the settable configVars.

Types

type CannotLoadDefinitionsError

type CannotLoadDefinitionsError struct {
	Err error
}

CannotLoadDefinitionsError is unused. Planned to be used if bytemark-client starts caching definitions, but it doesn't at the moment.

func (*CannotLoadDefinitionsError) Error

type DirInvalidError

type DirInvalidError struct {
	Path string
}

DirInvalidError is returned when the path specified as the config dir was not a directory.

func (*DirInvalidError) Error

func (e *DirInvalidError) Error() string

type InvalidVarError

type InvalidVarError struct {
	Var string
}

InvalidVarError is used to inform the user that they variable they attempted to set / get doesn't exist

func (InvalidVarError) Error

func (e InvalidVarError) Error() string

type Manager

type Manager interface {
	Get(string) (string, error)
	GetIgnoreErr(string) string
	GetBool(string) (bool, error)
	GetV(string) (Var, error)
	GetSessionValidity() (int, error)
	GetVirtualMachine() lib.VirtualMachineName
	GetGroup() lib.GroupName
	GetAll() (Vars, error)
	Set(string, string, string)
	SetPersistent(varname string, value string, source string) error
	Unset(string) error
	GetDebugLevel() int
	EndpointName() string
	PanelURL() string
	ConfigDir() string

	ImportFlags(*flag.FlagSet) []string
}

Manager is an interface defining a key->value store that also knows where the values were set from.

func New

func New(configDir string) (manager Manager, err error)

New sets up a new config struct. Pass in an empty string to default to ~/.bytemark

type ReadError

type ReadError struct {
	Name string
	Path string
	Err  error
}

ReadError is returned when a file containing a value for a Var couldn't be read.

func (*ReadError) Error

func (e *ReadError) Error() string

type Var

type Var struct {
	Name   string
	Value  string
	Source string
}

Var is a struct which contains a name-value-source triplet Source is up to two words separated by a space. The first word is the source type: FLAG, ENV, DIR, CODE. The second is the name of the flag/file/environment var used.

func (Var) DefaultFields

func (v Var) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Var) PrettyPrint

func (v Var) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a nice human-readable overview of the server to the given writer.

func (*Var) SourceBaseName

func (v *Var) SourceBaseName() string

SourceBaseName returns the basename of the configVar's source. it's a bit stupid and so its output is only valid for configVars with SourceType() of DIR

func (*Var) SourceType

func (v *Var) SourceType() string

SourceType returns one of the following: INTERACTION for a configVar set by some interaction with the user FLAG for a configVar whose value was set by passing a flag on the command line ENV for a configVar whose value was set from an environment variable DIR for a configVar whose value was set from a file in the config dir CODE for the default hardcoded into bytemark-client

func (*Var) SourceTypeAtLeast

func (v *Var) SourceTypeAtLeast(min string) bool

SourceTypeAtLeast ensures that this Var's SourceType is at least as 'good' as the one specified. The ranking is currently INTERACTION > FLAG > ENV > DIR > FLAG

type Vars

type Vars []Var

Vars is a list of configuration variables

func (Vars) DefaultFields

func (vs Vars) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type, which is the same as VirtualMachine.DefaultFields.

func (Vars) PrettyPrint

func (vs Vars) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the virtual machines to writer at the given detail level.

type WriteError

type WriteError struct {
	Name string
	Path string
	Err  error
}

WriteError is returned when a file containing a value for a Var couldn't be written to.

func (*WriteError) Error

func (e *WriteError) Error() string

Jump to

Keyboard shortcuts

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