Documentation ¶
Index ¶
- Constants
- func CreateMetadataFile(o MetadataOptions) error
- func DocumentTemplate(name, template string, overwrite, print bool) error
- func FileFinder(filename string) (string, error)
- func InterpolateKVStrings(args []string, context EnvMap, expand bool) []string
- func IsErrorRunningCommand(v interface{}) bool
- func IsFileNotFound(v interface{}) bool
- func IsSectionNotFound(v interface{}) bool
- func Print(environment, name string, isolated, expand bool) error
- func Run(environment string, options RunOptions) error
- type EnvFile
- type EnvKey
- type EnvMap
- type EnvSection
- type EnvSlice
- type ErrorRunningCommand
- type MetadataOptions
- type RunOptions
Constants ¶
const DefaultSection = ini.DEFAULT_SECTION
DefaultSection is the name of the default ini section
Variables ¶
This section is empty.
Functions ¶
func CreateMetadataFile ¶
func CreateMetadataFile(o MetadataOptions) error
CreateMetadataFile will create or update metadata file
func DocumentTemplate ¶
DocumentTemplate will create or update a document template e.g. envset.tpl that we use to document and to check in our repo so we can keep track of the variables and sections.
func FileFinder ¶
FileFinder will find the file and return its full path
func InterpolateKVStrings ¶
InterpolateKVStrings replace ${VAR} in the executable cmd arguments
func IsErrorRunningCommand ¶
func IsErrorRunningCommand(v interface{}) bool
ErrorRunningCommand will return true if v is section not found
func IsFileNotFound ¶
func IsFileNotFound(v interface{}) bool
IsFileNotFound will return true if v is file not found
func IsSectionNotFound ¶
func IsSectionNotFound(v interface{}) bool
IsSectionNotFound will return true if v is section not found
func Print ¶
Print will show the current environment We don't need to do variable replacement if we print since the idea is to use it as a source
func Run ¶
func Run(environment string, options RunOptions) error
Run will run the given command after loading the environment
Types ¶
type EnvFile ¶
type EnvFile struct { //TODO: make relative to executable Path string `json:"-"` File *ini.File `json:"-"` Filename string `json:"envfile,omitempty"` //TODO: should we have https, git and id? if someone checks using //https and other ssh this will change!! Project string `json:"project,omitempty"` Alg string `json:"algorithm"` //TODO: make custom marshaller to ignore DEFAULT section Sections []*EnvSection `json:"sections"` }
EnvFile struct
func (*EnvFile) AddSection ¶
func (e *EnvFile) AddSection(name string) *EnvSection
AddSection will add a section to a EnvFile
func (*EnvFile) GetSection ¶
func (e *EnvFile) GetSection(name string) (*EnvSection, error)
GetSection will return a EnvSection by name or an error if is not found
type EnvKey ¶
type EnvKey struct { Name string `json:"key"` Value string `json:"value,omitempty"` Hash string `json:"hash"` Comment string `json:"comment,omitempty"` }
EnvKey is a single entry in our file
type EnvMap ¶
EnvMap type to hold envset map
func LoadIniSection ¶
func LoadIniSection(sec *ini.Section) EnvMap
LoadIniSection returns a new EnvMap from a ini section
func (EnvMap) GetMissingKeys ¶
GetMissingKeys will compare the keys present in `keys` with the keys present in the EnvMap instance and return a list of missing keys.
func (EnvMap) ToExpandedKVStrings ¶
ToExpandedKVStrings returns an expanded list of key=value strings
func (EnvMap) ToKVStrings ¶
ToKVStrings will return an slice of `key=values`
type EnvSection ¶
type EnvSection struct { Name string `json:"name"` Comment string `json:"comment,omitempty"` Keys []*EnvKey `json:"values"` }
EnvSection is a top level section
func CompareSections ¶
func CompareSections(s1, s2 EnvSection) EnvSection
CompareSections will compare two sections and return diff
func (*EnvSection) AddKey ¶
func (e *EnvSection) AddKey(key, value, secret string) (*EnvKey, error)
AddKey adds a new key to the section
func (*EnvSection) IsEmpty ¶
func (e *EnvSection) IsEmpty() bool
IsEmpty will return true if we have no keys in our section
type ErrorRunningCommand ¶
type ErrorRunningCommand struct {
// contains filtered or unexported fields
}
func (ErrorRunningCommand) Error ¶
func (e ErrorRunningCommand) Error() string