Resolving of files (for `insertFile` and `insertTemplate`) should
always be relative to the resource set location, the previous
behaviour was considered a bug.
This is fixed by ensuring that resource set paths are absolute at
context loading time.
An advantage of this method over the previous one is that any edits to
the ConfigMap yaml file will also trigger a rolling update.
It also keeps knowledge of what the ConfigMap contains inside its yaml
file instead of the Deployment needing to know which variables to hash.
Similar to insertFile, but runs the templating against the file before
inserting.
This is useful for sharing common config between yaml files, e.g. volume
mounts in a deployment.yaml and cronjob.yaml, and it's useful to be able
to use the `configHash` annotation pattern with a templated
configmap.yaml
Changes in the Go build environment for Nix have caused the parallel
vetting to run in a subshell which does not have the required function
definitions.
This commit fixes the error by not running vet in parallel (there's no
point to that anyways as the project is tiny).
Updates a few build dependencies, most notably Go to 1.11. The chosen
commit is the current stable `nixos-18.09` tag in nixpkgs-channels.
While doing this I also checked whether it is now possible to remove
the exception for allowing references, but it's not.
Go may in the future gain support for fully reproducible builds, see
for example issue #16860 on their compiler. At that point maybe we can
drop a few settings here.
CI builds for `master` track unstable nixpkgs releases, in which
parallel is no longer part of the standard build environment.
However, this tool is required for executing some of the tests.
Updates the following dependencies to latest:
* Masterminds/semver
* Masterminds/sprig
* ghodss/yaml
* satori/go.uuid -> google/uuid
* huandu/xstrings
* imdario/mergo
* crypto
* alecthomas/kingpin.v2
* yaml.v2
As usual Go libraries are YOLO-versioned, so who knows what changed
here. I'll be going through `sprig` at least to add that to the
changelog.
This relates to #152.
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.
Introduces a test which will merge variables defined at every possible
layer together and ensure that the loaded context configuration is as
expected.
The test data provides an actual resource set template that can be
tested locally from a kontemplate source checkout:
kontemplate template context/testdata/merging/context.yaml --var cliVar=cliVar
Changes the logic for merging context values to be unambiguous and
easy to follow.
* loadDefaultVars returns the default vars directly instead of
performing merging in addition
* all merging is performed in `mergeContextValues` using explicit
explanations for every step of the merge.
After this commit the order of merging goes from least to most
"specific", please read the explanatory comments for more information.
This relates to #142.
This lets users choose the executable (either by full path or via a
$PATH-entry) to be used when executing `kubectl`.
This is useful in, for example, OpenShift based setups.
This fixes#143
In some cases the value of a variable may contain an equals sign,
which would not work in the previous version.
This uses `SplitN` to split the variable specifier into a
pre-determined number (2) of sub-slices. Further `=`-symbols will then
be included in the second substring.
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.
This lets users specify the paths from which to import additional
variables using absolute paths in addition to relative paths.
This enables both loading of configuration files placed outside of the
resource set folder (if desired), as well as special use-cases such as
specifying `/dev/stdin` as an input path to read variables from
standard input.
This change supersedes #131
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`.
These changes allows variables to be defined when executing
`kontemplate` via one or more `--variable` arguments.
With this in place one can either define new variables or override
existing variables loaded from a file:
```
$ kontemplate apply --variable version=v1.0 example/fancy-app.yaml
```
This avoids the need to write variables into a temporary file that is
only needed to provide "external variables" into resource sets.
Closes https://github.com/tazjin/kontemplate/issues/122
This document is intended to provide some information about how to
contribute to the project, from basic sanity checks and code quality
to information about how to structure git commits.
These are the most common things that I encounter in pull requests
sent to my projects.
This does several changes to the new "template to directory" feature
introduced in the previous commit:
1. Errors are now "handled". In classic Go-style, it is of course all
too easy to do absolutely nothing with errors, but we can't have
that. I'm onto you, Renee French's husband!
2. Resource sets containing similarly named files are now templated
correctly by prepending the resource set name to the filename.
3. In the same vein as the previous point, nested resource sets are
now also output correctly by replacing slashes (`/`) with
dashes (`-`) to guarantee that the output files are a flat list.
Some minor cosmetic fixes have also been applied.
This introduces a new command line flag `--output` (or `-o` for short)
which makes it possible to template all specified resource sets into a
folder (instead of to stdout) when using `kontemplate template`.
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.
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.
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.
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
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>
Pin the nixpkgs-commit used for building the Kontemplate release to a
specific commit.
Kontemplate builds should now be fully repeatable (and most likely
reproducible!) on any machine running Nix.