Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertEnv(env map[string]string) []string
- func ConvertFromEnv(env []string) map[string]string
- func ConvertStringToHumanFriendly(str string) string
- func ConvertStringToMachineFriendly(str string) string
- func ConvertToMapOfStrings(m map[string]interface{}) map[string]string
- func FileExists(file string) bool
- func GetFullPath(path string) string
- func IsExitError(err error) bool
- func IsURL(s string) bool
- func LastLine(r io.Reader) (l string)
- func MapKeys(m interface{}) (keys []string)
- func MustGetUserHomeDir() string
- func MustGetwd() string
- func ReadEnvFile(r io.ReadCloser) (map[string]string, error)
- func RenderString(tmpl string, variables map[string]interface{}) (string, error)
- type Binary
- type EnvFileOpts
- type Envfile
- type ModifyEnv
Constants ¶
const REPLACE_CHAR_DEFAULT = " "
Variables ¶
var ErrInvalidOptionsEnvFile = errors.New("invalid options on envfile")
Functions ¶
func ConvertEnv ¶
ConvertEnv converts map representing the environment to array of strings in the form "key=value"
func ConvertFromEnv ¶
ConvertFromEnv takes a string array and coverts it to a map of strings since an env variable can only really be a string it's safe to convert to string and not interface downstream programs need to cast values to what they expect
func ConvertStringToHumanFriendly ¶
ConvertStringToHumanFriendly takes a ConvertStringToMachineFriendly generated string and and converts it back to its original human friendly form
func ConvertStringToMachineFriendly ¶
ConvertStringToMachineFriendly takes astring and replaces any occurrence of non machine friendly chars with machine friendly ones
func ConvertToMapOfStrings ¶
ConvertToMapOfStrings converts map of interfaces to map of strings
func IsExitError ¶
IsExitError checks if given error is an instance of exec.ExitError
func MustGetUserHomeDir ¶
func MustGetUserHomeDir() string
MustGetUserHomeDir returns current working directory. Panics is os.UserHomeDir() returns error
func MustGetwd ¶
func MustGetwd() string
MustGetwd returns current working directory. Panics is os.Getwd() returns error
func ReadEnvFile ¶
func ReadEnvFile(r io.ReadCloser) (map[string]string, error)
ReadEnvFile reads env file inv `k=v` format
Types ¶
type Binary ¶
type Binary struct {
IsContainer bool `jsonschema:"-"`
// Bin is the name of the executable to run
// it must exist on the path
// If using a default mvdn.sh context then
// ensure it is on your path as symlink if you are only using aliases.
Bin string `mapstructure:"bin" yaml:"bin" json:"bin"`
Args []string `mapstructure:"args" yaml:"args,omitempty" json:"args,omitempty"`
// contains filtered or unexported fields
}
Binary is a structure for storing binary file path and arguments that should be passed on binary's invocation
func (*Binary) BuildArgsWithEnvFile ¶
BuildArgsWithEnvFile returns all args with correctly placed --env-file parameter for context binary
func (*Binary) WithBaseArgs ¶
func (*Binary) WithContainerArgs ¶
func (*Binary) WithShellArgs ¶
type Envfile ¶
type Envfile struct {
// Generate will toggle the creation of the envFile
// this "envFile" is only used in executables of type `docker|podman`
Generate bool `mapstructure:"generate" yaml:"generate,omitempty" json:"generate,omitempty"`
// list of variables to be excluded
// from the injection into container runtimes
//
// Currently this is based on a prefix
//
// Example:
// HOME=foo,HOMELAB=bar
//
// Both of these will be skipped
Exclude []string `mapstructure:"exclude" yaml:"exclude,omitempty" json:"exclude,omitempty"`
Include []string `mapstructure:"include" yaml:"include,omitempty" json:"include,omitempty"`
// Path is generated using task name and current timestamp
// TODO: include additional graph info about the execution
// e.g. owning pipeline (if any) execution number
Path string `mapstructure:"path" yaml:"path,omitempty" json:"path,omitempty"`
ReplaceChar string `mapstructure:"replace_char" yaml:"replace_char,omitempty" json:"replace_char,omitempty"`
Quote bool `mapstructure:"quote" yaml:"quote,omitempty" json:"quote,omitempty"`
// Modify specifies the modifications to make to each env var and whether it meets the criteria
// example:
// - pattern: "^(?P<keyword>TF_VAR_)(?P<varname>.*)"
// operation: lower
// the inputs are validated at task/pipeline build time and will fail if the
// <keyword> and <varname> sub expressions are not present in the `pattern`
Modify []ModifyEnv `mapstructure:"modify" yaml:"modify,omitempty" json:"modify,omitempty"`
// defaults to .taskctl in the current directory
// again this should be hidden from the user...
GeneratedDir string `mapstructure:"generated_dir" yaml:"generated_dir,omitempty" json:"generated_dir,omitempty"`
}
Envile is a structure for storing the information required to generate an envfile which can be consumed by the specified binary
func NewEnvFile ¶
func NewEnvFile(opts ...EnvFileOpts) *Envfile
NewEnvFile creates a new instance of the EnvFile initializes it with some defaults