Documentation
¶
Index ¶
- Variables
- func Generate(envName, cogPath string, outputType Format) (map[string]interface{}, error)
- func IsEnvFile(path string) bool
- func IsJSONFile(path string) bool
- func IsTOMLFile(path string) bool
- func IsYAMLFile(path string) bool
- func OutputCfg(cfg *Cfg, format Format) (interface{}, error)
- type Cfg
- type Format
- type Gear
- type RawEnv
- type Resolver
- type Visitor
Constants ¶
This section is empty.
Variables ¶
var EnvSubst bool = false
EnvSubst decides whether to use environmental substitution or not
var NoEnc bool = false
NoEnc decides whether to output encrypted variables or now
Functions ¶
func Generate ¶
Generate is a top level command that takes an env argument and cogfilepath to return a string map
func IsEnvFile ¶ added in v0.6.0
IsEnvFile returns true if a given file path corresponds to a .env file
func IsJSONFile ¶ added in v0.6.0
IsJSONFile returns true if a given file path corresponds to a JSON file
func IsTOMLFile ¶ added in v0.6.0
IsTOMLFile returns true if a given file path corresponds to a TOML file
func IsYAMLFile ¶ added in v0.6.0
IsYAMLFile returns true if a given file path corresponds to a YAML file
Types ¶
type Cfg ¶
type Cfg struct { Name string // defaults to key name in cog file unless var.name="other_name" is used Value string // Cfg.ComplexValue should be nil if Cfg.Value is a non-empty string("") ComplexValue interface{} // Cfg.Value should be empty string("") if Cfg.ComplexValue is non-nil Path string // filepath string where Cfg can be resolved SubPath string // object traversal string used to resolve Cfg if not at top level of document (yq syntax) // contains filtered or unexported fields }
Cfg holds all the data needed to generate one string key value pair
type Format ¶ added in v0.6.0
type Format string
Format represents the final marshalled k/v output type from a resolved Gear
const ( JSON Format = "json" YAML Format = "yaml" TOML Format = "toml" Dotenv Format = "dotenv" Raw Format = "raw" )
Formats for respective object notation
func FormatForCfg ¶ added in v0.6.0
FormatForCfg returns the correct format given the readType
func FormatForPath ¶ added in v0.6.0
FormatForPath returns the correct format given the path to a file
type Gear ¶
type Gear struct { Name string // contains filtered or unexported fields }
Gear represents one of the contexts in a cog manifest. The term "gear" is used to refer to the operating state of a machine (similar to how a microservice can operate locally or in a remote environment) rather than a gear object. The term "switching gears" is an apt representation of how one Cog manifest file can have many contexts/environments
func (*Gear) ResolveMap ¶
ResolveMap outputs the flat associative string, resolving potential filepath pointers held by Cfg objects by calling the .ResolveValue() method
type RawEnv ¶
type RawEnv map[string]interface{}
RawEnv is meant to represent the topmost untraversed level of a cog environment
type Resolver ¶
Resolver is meant to define an object that returns the final string map to be used in a configuration resolving any paths and sub paths defined in the underling config map
type Visitor ¶ added in v0.6.0
Visitor allows a query path to return the underlying value for a given visitor
func NewDotenvVisitor ¶ added in v0.6.0
NewDotenvVisitor returns a visitor object that satisfies the Visitor interface attempting to turn a supposed dotenv byte slice into a *yaml.Node object
func NewJSONVisitor ¶ added in v0.5.0
NewJSONVisitor returns a visitor object that satisfies the Visitor interface attempting to turn a supposed JSON byte slice into a *yaml.Node object
func NewTOMLVisitor ¶ added in v0.6.0
NewTOMLVisitor returns a visitor object that satisfies the Visitor interface attempting to turn a supposed TOML byte slice into a *yaml.Node object
func NewYAMLVisitor ¶ added in v0.6.0
NewYAMLVisitor returns a visitor object that satisfies the Visitor interface