Skip to content
YAML support for the Go language.
Go
Branch: v3
Clone or download
This branch is 9 commits ahead, 12 commits behind go-yaml:v3.

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml
LICENSE
NOTICE
README.md
apic.go
decode.go
decode_test.go
emitterc.go
encode.go
encode_test.go
example_embedded_test.go
go.mod
go.sum
limit_test.go
node_test.go
parserc.go
readerc.go
resolve.go
scannerc.go
sorter.go
suite_test.go
template.go
template_test.go
writerc.go
yaml.go
yamlh.go
yamlprivateh.go

README.md

Forked YAML library with templating support

flanksource/yaml is forked from go-yaml and adds templating support

Getting started

  1. Replace gopkg.in/yaml.v3 with gopkg.in/flanksource/yaml.v3

  2. Use the custom !!env and !!template tags anywhere in your YAML and they will be replaced by the parser

 ami_name: !!template image-builder-{{ (time.Now).Format "2006-01-02-150405" }}
 eula: !!template {{file.ReadFile \"eula.txt\" }}
 access_key: !!env AWS_ACCESS_KEY_ID
 secret_key: !!env AWS_SECRET_ACCESS_KEY

!!env

Reads the value from an environment variable

!!template

Run a go text template with all the functions from gomplate added.

Future Work

  • Add support for all of gomplates datsources e.g. Vault, Consul, S3, AWS SSM, Git etc..
  • Support emitting full YAML lists / dicts not just values.

Comparison to other templating tools

Text Based Templating (Jinga,envsubst,etc)

  • The resulting templates are still 100% valid YAML and editable / parseable by other YAML libraries / editors.

YTT / CUE

  • Drop-in replacement for gopkg.in/yaml.v3
  • Custom functions are written in Golang not Starlark/Python
  • Gomplate already has a large library of functions for text, crypto, network, file handling, etc
You can’t perform that action at this time.