Simple go template renderer for nomad and other generic groups of templates (i.e. a light-weight Helm for purely templating).
Pull a parcel given the git source URI
parcel pull [options] [SOURCE]
-f --force # (optional) force pull parcelExamples:
# pull from remote repository
parcel pull git::ssh://git@github.com/bbckr/parcel//example
# pull from local repository
parcel pull git::file://${PROJECT_ROOT}/.git//example
# pull from repository ref
parcel pull git::ssh://git@github.com/bbckr/parcel//example?ref=${GIT_REF}Render template output for a parcel given the parcel identifiers. The parcel must be pulled before it can be referenced.
parcel render [options] [OWNER] [NAME] [VERSION]
-v --values # (optional) path to values yaml file
-o --output # directory to output rendered files (default: .)Examples:
# render to output directory
parcel render -o .output bbckr example 1.0.0
# override default values
parcel render -v myvalues.yaml bbckr example 1.0.0Each parcel requires the following directory structure:
folder_name
|_ static/ # place static files to reference in templates here
|_ templates/ # place all your templates here
...|_ job_1.hcl # go template, any name/ext
...|_ job_2.hcl # go template, any name/ext
|_ values.yaml # default values to feed parcel templates
|_ manifest.yaml # parcel manifestParcel uses basic Go templating with no added helper functions.
For a full example of how the values.yaml should look and how to reference the values and other injected variables in a template, checkout this example.
For quick reference:
# templates/sample-job.hcl
job "sample-jon" {
group "sample-group" {
task "sample-task" {
config {
image = "{{ .Values.image.name }}:{{ .Values.image.tag }}"
}
}
}
}# values.yaml
image:
name: nginx
tag: latestOutput:
job "sample-jon" {
group "sample-group" {
task "sample-task" {
config {
image = "nginx:latest"
}
}
}
}.Meta.nameParcel name, taken from manifest.Meta.ownerParcel owner, taken from manifest.Meta.versionParcel version, taken from manifest.Values.*Merged values from default Parcel values and values passed during render.Static.pathPath to static directory to reference static resources in templates
Uses Go template as a base and adds the following functions:
toJSONMarshal to JSON stringreplaceAn alias for strings.ReplacereplaceAllAn alias for strings.ReplaceAllquoteSurround with double quotation marksb64encodeBase64 encode stringb64decodeBase64 decode string