Documentation ¶
Overview ¶
Package config is the YAML parser of the task file for Dunner.
For more information on how to write a task file for Dunner, please refer to the following link of an article on Dunner repository's Wiki: https://github.com/leopardslab/dunner/dunner/wiki/User-Guide#how-to-write-a-dunner-file
Usage ¶
You can use the library by creating a dunner task file. For example,
# .dunner.yaml prepare: - image: node commands: - ["node", "--version"] - image: node commands: - ["npm", "install"] - image: mvn commands: - ["mvn", "package"]
Use `GetConfigs` method to parse the dunner task file, and `ParseEnv` method to parse environment variables file, or the host environment variables. The environment variables are used by invoking in the task file using backticks(`$var`).
Index ¶
- func DecodeMount(mounts []string, step *docker.Step) error
- func ParseEnv(configs *Configs) error
- func ParseMountDir(ctx context.Context, fl validator.FieldLevel) bool
- func ValidateFollowTaskPresent(ctx context.Context, fl validator.FieldLevel) bool
- func ValidateMountDir(ctx context.Context, fl validator.FieldLevel) bool
- type Configs
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeMount ¶
DecodeMount parses mount format for directories to be mounted as bind volumes. The format to configure a mount is
<source>:<destination>:<mode>
By _mode_, the file permission level is defined in two ways, viz., _read-only_ mode(`r`) and _read-write_ mode(`wr` or `w`)
func ParseEnv ¶
ParseEnv parses the `.env` file as well as the host environment variables. If the same variable is defined in both the `.env` file and in the host environment, priority is given to the .env file.
Note: You can change the filename of environment file (default: `.env`) using `--env-file/-e` flag in the CLI.
func ParseMountDir ¶
ParseMountDir verifies that source directory exists and parses the environment variables used in the config
func ValidateFollowTaskPresent ¶
ValidateFollowTaskPresent verifies that referenceed task exists
func ValidateMountDir ¶
ValidateMountDir verifies that mount values are in proper format
<source>:<destination>:<mode>
Format should match, <mode> is optional which is `readOnly` by default and `src` directory exists in host machine
Types ¶
type Configs ¶
type Configs struct {
Tasks map[string][]Task `validate:"required,min=1,dive,keys,required,endkeys,required,min=1,required"`
}
Configs describes the parsed information from the dunner file. It is a map of task name as keys and the list of tasks associated with it.
func GetConfigs ¶
GetConfigs reads and parses tasks from the dunner task file. The task file is unmarshalled to an object of struct `Config` The default filename that is being read by Dunner during the time of execution is `dunner.yaml`, but it can be changed using `--task-file` flag in the CLI.
type Task ¶
type Task struct { // Name given as string to identify the task Name string `yaml:"name"` // Image is the repo name on which Docker containers are built Image string `yaml:"image" validate:"required"` // SubDir is the primary directory on which task is to be run SubDir string `yaml:"dir"` // The command which runs on the container and exits Command []string `yaml:"command" validate:"omitempty,dive,required"` // The list of commands that are to be run in sequence Commands [][]string `yaml:"commands" validate:"omitempty,dive,omitempty,dive,required"` // The list of environment variables to be exported inside the container Envs []string `yaml:"envs"` // The directories to be mounted on the container as bind volumes Mounts []string `yaml:"mounts" validate:"omitempty,dive,min=1,mountdir,parsedir"` // The next task that must be executed if this does go successfully Follow string `yaml:"follow" validate:"omitempty,follow_exist"` // The list of arguments that are to be passed Args []string `yaml:"args"` }
Task describes a single task to be run in a docker container