Documentation
¶
Index ¶
- Constants
- Variables
- func CascadeName(parents []string, current string) string
- func ConvertEnv(env map[string]string) []string
- func ConvertFromEnv(env []string) map[string]string
- func ConvertToMachineFriendly(str string) string
- func ConvertToMapOfStrings(m map[string]interface{}) map[string]string
- func DecodeBase62(str string) string
- func DefaultTaskctlEnv() *variables.Variables
- func EncodeBase62(str 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 NormalizeHome(v string) string
- func ReadEnvFile(r io.ReadCloser) (map[string]string, error)
- func ReaderFromPath(envfile *Envfile) (io.ReadCloser, bool)
- func RenderString(tmpl string, variables map[string]interface{}) (string, error)
- func TailExtract(v string) string
- type Binary
- type Container
- type EnvFileOpts
- type Envfile
- type ModifyEnv
Constants ¶
const EIRCTL_ENV_FILE string = "eirctl.env"
EIRCTL_ENV_FILE is the default location of env file ingested by eirctl for every run.
const PipelineDirectionChar string = "->"
const REPLACE_CHAR_DEFAULT = " "
Variables ¶
var ( ErrInvalidOptionsEnvFile = errors.New("invalid options on envfile") ErrEnvfileFormatIncorrect = errors.New("envfile incorrect") )
Functions ¶
func CascadeName ¶
CascadeName builds the name using the ancestors with a pipeline separator
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 ConvertToMachineFriendly ¶
ConvertToMachineFriendly converts a string containing characters that would not play nice key names e.g. `->` or `|` `/` `\\` `:` To make it easier to decipher the names we replace these characters with a map to a known sequence.
replaceSequence := []string{ "->", "__a__", `|`, "__b__", `/`, "__c__", `\`, "__d__", `:`, "__e__", ` `, "__f__", // space sequence }
func ConvertToMapOfStrings ¶
ConvertToMapOfStrings converts map of interfaces to map of strings
func DecodeBase62 ¶
DecodeBase62 takes a EncodeBase62 generated string and and converts it back to its original human friendly form
func DefaultTaskctlEnv ¶
DefaultTaskctlEnv checks if there is a file in the current directory `eirctl.env` if we ingest it into the Env variable giving preference to the `eirctl.env` specified K/V.
Or should this be done once on start up?
func EncodeBase62 ¶
EncodeBase62 takes a string and converts it to base62 format - this is safer than using regex or strings replace.
func IsExitError ¶
IsExitError checks if given error is an instance of exec.ExitError
func MustGetUserHomeDir ¶
func MustGetUserHomeDir() string
MustGetUserHomeDir returns current user's home directory. Panics is os.UserHomeDir() returns error
func MustGetwd ¶
func MustGetwd() string
MustGetwd returns current working directory. Panics is os.Getwd() returns error
func NormalizeHome ¶ added in v0.7.1
func ReadEnvFile ¶
func ReadEnvFile(r io.ReadCloser) (map[string]string, error)
ReadEnvFile reads env file inv `k=v` format
func ReaderFromPath ¶
func ReaderFromPath(envfile *Envfile) (io.ReadCloser, bool)
ReaderFromPath returns an io.ReaderCloser from provided path Returning false if the file does not exist or is unable to read it
func RenderString ¶
RenderString parses given string as a template and executes it with provided params
func TailExtract ¶
TailExtract takes the last possible node from a pipeline string
Types ¶
type Binary ¶
type Binary struct { // 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"` }
Binary is a structure for storing binary file path and arguments that should be passed on binary's invocation
func (*Binary) WithBaseArgs ¶
func (*Binary) WithContainerArgs ¶
func (*Binary) WithShellArgs ¶
type Container ¶
type Container struct { // Name is the name of the container // // can be specified in the following formats // // - <image-name> (Same as using <image-name> with the latest tag) // // - <image-name>:<tag> // // - <image-name>@<digest> // // If the known runtime is podman it should include the registry domain // e.g. `docker.io/alpine:latest` Name string `mapstructure:"name" yaml:"name" json:"name"` // Entrypoint Overwrites the default ENTRYPOINT of the image Entrypoint schema.StringSlice `mapstructure:"entrypoint" yaml:"entrypoint,omitempty" json:"entrypoint,omitempty" jsonschema:"oneof_type=string;array"` // EnableDinD mounts the docker sock... // // > highly discouraged EnableDinD bool `mapstructure:"enable_dind" yaml:"enable_dind,omitempty" json:"enable_dind,omitempty"` // EnableBindMount signifies whether to use the --volume or --mount specification. // Default false. // will use --volume as a default EnableBindMount bool `mapstructure:"enable_mount" yaml:"enable_mount,omitempty" json:"enable_mount,omitempty"` // ContainerArgs are additional args used for the container supplied by the user // // e.g. dcoker run (EIRCTL_ARGS...) (CONTAINER_ARGS...) image (command) // The internals will strip out any unwanted/forbidden args // // Args like the switch --privileged and the --volume|-v flag with the value of /var/run/docker.sock:/var/run/docker.sock // will be removed. // // Currently the only the -v|--volume and -u|--user -p|--port args get parsed. ContainerArgs []string `mapstructure:"container_args" yaml:"container_args,omitempty" json:"container_args,omitempty"` // Shell will be used to run the command in a specific shell on the container // // Must exist in the container Shell string `mapstructure:"shell" yaml:"shell,omitempty" json:"shell,omitempty"` // Args are additional args to pass to the shell if provided. // Once you provide the ShellArgs, you must also specify the Shell as well, as there is no reliable way to ensure the default `sh` accepts provided shell arguments // // Default Shell and ShellArgs are `sh -c` // // e.g. docker run (EIRCTL_ARGS...) (CONTAINER_ARGS...) image (shell) (SHELL_ARGS...) (command) // // Example: with powershell could be: `-Command -NonInteractive` along with a custom shell of `pwsh` would result in `pwsh -Command -NonInteractive (command)` ShellArgs []string `mapstructure:"shell_args" yaml:"shell_args,omitempty" json:"shell_args,omitempty"` }
Container is the specific context for containers only available to docker API compliant implementations
e.g. docker and podman
The aim is to remove some of the boilerplate away from the existing more generic context and introduce a specific context for tasks run in containers.
type Envfile ¶
type Envfile struct { // 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"` // PathValue points to the file to read in and compute using the modify/include/exclude instructions. PathValue 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 .eirctl 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"` // contains filtered or unexported fields }
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