Commit graph

33 commits

Author SHA1 Message Date
Martin Lehmann
54db9785d6 feat(main): Support specifying kubectl args in ResourceSets 2018-12-11 10:58:52 +01:00
Phillip Johnsen
ab059ad41c feat(templater): override sprig default function with guarded alternative
These changes overrides the `default` function provided by sprig with
an alternative to retrieve variable values from variables that might
not have been declared at all.

Referencing a variable in a template that is not declared, will lead
to the underlying templating functionality raising an error, causing
kontemplate to exit.

The override alternative to `default` accepts a second string argument
with the variable name. If the variable in question has not been
declared the first argument's value would be returned, just as the
original `default` function does.
2018-07-14 23:21:36 +02:00
Vincent Ambo
c91cb21f70 feat(templater): Support single-template resource sets
Supports resource sets in which the `path` is pointed at a single
template file.

The example has been updated with ... an example of this.

This closes #81.
2018-06-09 21:23:48 +02:00
Vincent Ambo
b33c353233 refactor(context): Implement more explicit merging of variables
The hierarchy for loading variables was previously not expressed
explicitly.

This commit refactors the logic for merging variables to explicitly
set the different layers of variables as values on the context object
and merge them for each resource set in `mergeContextValues`.
2018-06-09 19:16:23 +02:00
noqcks
3ea3bed7ac fix(templater): add baseDir to gitHead cmd so that directory is overwritten
This makes it so that when gitHead is called in a template the git hash
that is returned is the hash of the folder containing the template, not
the hash of the folder where kontemplate is called.
2018-05-05 10:29:47 +02:00
noqcks
ac445d5235 refactor(templater) Refactor templator to use exec.Command directly instead of executing in sh 2018-03-29 20:05:30 +02:00
noqcks
e1c2c19330 feat(templater) Add a template function to insert surrounding repo's Git hash
A template function has been added that allows one to template the
Git hash of the surrounding repo. This is useful to be able to inspect the
deployment revision of an object in Kubernetes.
2018-03-29 20:05:30 +02:00
Vincent Ambo
3aa2cb8d3e refactor: Remove old error handling library
Removes the old error handling library and switches to plain
fmt.Errorf calls.

There are several reasons for this:

* There are no useful types or handling here anyways, so output format
  is the only priority.
* Users don't care about getting stacktraces.
* My emotional wellbeing.

Fin de siècle.
2018-03-09 15:23:57 +01:00
Vincent Ambo
b8722ce83b refactor(templater): Pass resource set path to insertFile function
This is actually several refactors in one:

* rename "fileContent" function to "insertFile"
* pass the resource set path to the "insetFile" function
* update docs and example with a pipeline including indentation
  adjustments for the inserted file
2018-03-09 14:54:20 +01:00
Niklas Wik
bafb792339 feat(templater): Added support for file include
Adds a 'fileContent' template function to insert the literal contents
of a file specified in the template.

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>
2018-03-09 14:54:20 +01:00
Vincent Ambo
bfad4a3932 feat(license): Relicense under GPLv3
All further kontemplate source code changes and releases will happen under the GPLv3.

Previous releases are still available under the MIT license.
2017-11-21 11:46:27 +01:00
Vincent Ambo
9cffd3d1d4 refactor templater: Add explicit note about empty-rs warnings
Due to an interesting combination of an error not being handled and Go
initialising everything with what it thinks should be the default,
non-existent resource sets have been gracefully handled already.

This makes this accidental fix explicit.

Fixes #90
2017-10-27 02:55:41 +02:00
Stefan Magnus Landrø
68e2f99062 feat templater: Add IP lookup function
This introduces support for looking up IP addresses using local DNS resolver.

Function will return a list of all IP addresses associated with hostname.
Further processing can be achieved using supported list template functions.
2017-10-20 09:43:02 +02:00
Vincent Ambo
b20bc5f57a fix templater: Don't template default.yml files
After the change from #84 default variable files with the '.yml'
extension got templated as resource set templates accidentally.

This resolves the issue by moving the list reserved default file names
to a common place and reusing it in both the templater and context pkg.

This fixes #85
2017-08-31 18:41:57 +02:00
Vincent Ambo
5e7bb55e00 refactor templater: Use resource set 'path' field when loading files 2017-07-13 16:07:08 +02:00
Vincent Ambo
a7781b169d fix templater: Ignore slash-suffixes on includes/excludes
To prevent situations where a shell auto-appends a slash to an
include/exclude specification on the CLI, trailing slashes in those
string lists are now trimmed.

This fixes #54
2017-06-11 22:33:07 +02:00
Vincent Ambo
3cba344fbe fix main: Fix 'kontemplate template' output 2017-06-11 22:09:10 +02:00
Vincent Ambo
f3264329b9 refactor templater: Add intermediate type to represent rendered RSes
As a first step in resolving #51 this refactors the `templater`
package to return rendered resource sets as a distinct type.

This also fixes #56
2017-06-11 22:09:10 +02:00
Vincent Ambo
32ca64c50a feat templater: Warn if no valid resource sets are included
After filtering resource sets, check whether any resource sets "survived".

Otherwise it can be assumed that the user specified invalid exclude/include
combinations and should be warned about that.

Fixes #35
2017-05-04 18:45:03 +02:00
Vincent Ambo
746e733cbb fix templater: Don't try to template default value files 2017-04-04 20:06:15 +02:00
Vincent Ambo
3b0f41e71d feat templater: Fail if values are missing
Golang's template package now has an option for failing if template variables
are missing: https://golang.org/pkg/text/template/#Template.Option

This updates the templater code to make use of that option and return the
errors encountered during templating.

This fixes #1
2017-04-04 11:05:09 +02:00
Vincent Ambo
f81fe551bc chore templater: Use new util.Merge func 2017-02-14 19:12:53 +01:00
Vincent Ambo
2f6e008121 feat templater: Add 'pass' lookup function
This introduces support for looking up secret values in the 'pass' command line
tool (https://www.passwordstore.org/).

Values like passwords can be interpolated from pass and even more complex
structures like certificates for Kubernetes Secrets can be retrieved and base64-
encoded as necessary.

Fixes #2
2017-02-09 15:44:18 +01:00
Vincent Ambo
4713d565d3 fix templater: Don't fail with two identical stack traces 2017-02-09 15:44:18 +01:00
Vincent Ambo
dd2fdd63e5 fix templater & ctx: Correctly check resource set parent 2017-02-08 17:42:06 +01:00
Vincent Ambo
756a4c745d fix templater: Guard against empty parent reference 2017-02-08 17:34:49 +01:00
Vincent Ambo
4e8223ef34 feat context: Add support for resource set collections
A resource set collection is a resource set with an addition 'include' array
configured. It is a short-hand for importing multiple resource sets from the
same folder and for excluding/including them as a group.

See https://github.com/tazjin/kontemplate/issues/9 for more information.

Closes #9
2017-02-08 17:34:49 +01:00
Vincent Ambo
8e08a282eb feat templater: Add ability to exclude resource sets
* renamed --limit to --include (-i)
* added --exclude (-e)

Kontemplate users can now explicitly include and exclude certain resource sets.
Excludes always override includes.

Closes #11
2017-02-08 16:53:38 +01:00
Vincent Ambo
25f2a1616c feat template: Add additional template functions
This adds the Go template functions from [sprig][] as well as a custom `json`
function that can interpolate any data as a JSON object - very useful for adding
arrays of data in JSON format into a variable:

```
certificateDomains:
  - oslo.pub
  - tazj.in

annotations:
  acme/certificate: {{ .certificateDomains | json }}

annotations:
  acme/certificate: ["oslo.pub", "tazj.in"]
```

[sprig]: https://godoc.org/github.com/Masterminds/sprig
2017-02-08 14:40:45 +01:00
Vincent Ambo
3ef0f35bfe fix templater: Guard against empty values map 2017-02-08 13:47:56 +01:00
Vincent Ambo
7ac63613fb feat main: Add proper CLI support
Adds a basic CLI structure with a single "run" command that takes a --file (-f)
and --limit (-l) flag.

--limit can be used to only output certain resource sets.

Closes #4
2017-02-08 12:58:53 +01:00
Vincent Ambo
8fac7c1a41 chore: Better example & gofmt 2017-02-08 11:55:59 +01:00
Vincent Ambo
9e3ee3f2bb feat templater: Add initial templating support 2017-02-08 11:50:49 +01:00