-
Notifications
You must be signed in to change notification settings - Fork 36
Separate documents issue. #51
Comments
This can become an issue when users split resources across multiple files and don't start the resources with Inside of a single file containing multiple resources I expect people to be aware of this, but a good thing to do here would be to issue a warning to users. What I'm thinking is logic such as the following (pseudocode):
|
Note that I'd prefer not to add any logic to actually parse & validate YAML itself in Kontemplate. |
Agree with not adding logic for validating the YAML. |
No, inside of a file it's up to the user to write valid YAML ;-) |
Ok, maybe it's just me then :) - I didn't know you had to start every YAML file with |
You don't, but it's only Kontemplate's responsibility to warn the user if it's at the start of the file (because it's kontemplate that concatenates the files). |
Other fix idea: What happens if kubectl is sent something like this ---
# no actual resource here
--- ? If that is valid then I can apply an actual "fix" of just prefixing each YAML file with |
How about just checking if the document contains multiple objects seperated by |
I'm really not so sure anymore - as I guess this would be a validator's job ... |
This can still cause the same issue if people include multiple resource sets in one run that have one YAML file with one resource each (without In fact that makes this a bug. |
heh, good that got cleared out then 👍 |
Yep, thanks for noticing! |
Multiple object separators seem to work without any issues:
|
Then that seems to be the easiest fix |
In cases where users have multiple resource sets, or a single resource set that contains multiple YAML files they may run into issues if they forget to start their resource files with `---`. This fix inserts an additional `---` at the beginning of each YAML template. In cases where the user started their file YAML file "properly" this will result in an empty resource being templated / passed to kubectl, however that does not seem to cause any issues. This fixes #51
I've decided agains the "easy" fix. @heavenlyhash suggested that That's enough to fix the specific bug I have and in addition error messages could potentially be a bit nicer! |
The new plan is as follows (and I hope to implement it in the next days because vacation is freeing up my time atm!):
type RenderedResource struct {
Filename string
Output string // rendered template
}
type RenderedResourceSet struct {
Name string // Resource set name/path (for output)
Resources []RenderedResource
} The As a sanity check particular to the problem described in this issue I may get around to adding logic that checks if multiple YAML-files are in a single resource set and, if yes, whether they contain |
Instead of passing the rendered output of all resource sets to kubectl simultaneously, build upon the previous commit and pass resource sets individually to new instances of kubectl. This resolves #51
Instead of passing the rendered output of all resource sets to kubectl simultaneously, build upon the previous commit and pass resource sets individually to new instances of kubectl. This resolves #51
This release features some cleanup and under-the-hood changes, as well as "ecosystem-features" that don't directly affect the way Kontemplate itself functions. * Resource-sets are now passed on to kubectl in individual invocations. This means that kubectl errors can be scoped to individual resource set files and issues such as #51 are less of a problem. * A Dockerfile is provided and published at `tazjin:kontemplate` on Docker Hub. This image contains `kontemplate`, `kubectl` and `pass` and can be used - for example - as an image for a step in a CI system. * Kontemplate is now available on Homebrew, check the README for installation instructions. * If different resource sets don't contain `---` separators in YAML, `kubectl` calls will no longer fail. (#51) * Autocompleted trailing slashes in shells are now filtered from include & exclude lists to enhance the CLI experience slightly.
This release features some cleanup and under-the-hood changes, as well as "ecosystem-features" that don't directly affect the way Kontemplate itself functions. * Resource-sets are now passed on to kubectl in individual invocations. This means that kubectl errors can be scoped to individual resource set files and issues such as #51 are less of a problem. * A Dockerfile is provided and published at `tazjin:kontemplate` on Docker Hub. This image contains `kontemplate`, `kubectl` and `pass` and can be used - for example - as an image for a step in a CI system. * Kontemplate is now available on Homebrew, check the README for installation instructions. * If different resource sets don't contain `---` separators in YAML, `kubectl` calls will no longer fail. (#51) * Autocompleted trailing slashes in shells are now filtered from include & exclude lists to enhance the CLI experience slightly.
kubectl apply
accepts yaml documents with multiple docs without---
in head.But without this seperator in head of each template the generated template from kontemplate becomes invalid.
The text was updated successfully, but these errors were encountered: