krane render
: render templates in deterministic order
#871
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are you trying to accomplish with this PR?
I'm using
krane render -f some.yaml.erb > fixtures/some.yaml.lock
in my (private) repo to produce a set of "fixtures", so I know the full yaml generated by our ERBs and partials, and can clearly diff how a partial change will affect multiple different deployments.Right now,
krane render
can produce different outputs on MacOS versus linux, based on the order of filenames returned byDir.foreach
. This causes the fixtures generated on my Mac to differ from the fixtures expected in CI on linux, causing CI to fail. I want to render templates in a deterministic order.How is this accomplished?
If I
.sort
the output ofDir.foreach
, it renders files in the same order on any OS. For completeness, I'm also sortingfile_paths
.What could go wrong?
This only impacts the order of template generation, so it shouldn't impact the order that resources are actually deployed. Still there could be unexpected consequences that I'm not aware of.