Masterminds / sprig

Useful template functions for Go templates.
http://masterminds.github.io/sprig/
MIT License
4.07k stars 423 forks source link

(feat): Add tar.gz support #355

Open secat opened 1 year ago

secat commented 1 year ago

Summary

It would be great to have a tar and gzip functions in order archive and compress string content to a tar.gz binary. This would mostly be useful to embed string content that is over the Kubernetes ConfigMap size limit of 1MBytes.

Proposal

The tar function would take as input a map[string][]byte where the key represents a file name and the value represents the file content.

The gzip function would take an array of bytes as input.

Usage Example

It could be used as follow in a Helm chart template:

my_compressed_files.tar.gz: |
  {{ .Files.Glob("foo/**") | tar | gzip }}

NOTE: The go standard library already provides a "archive/tar" package and a "compress/gzip" package.