Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

krane render: render templates in deterministic order #871

Merged
merged 2 commits into from
Feb 2, 2022

Conversation

JamesHageman
Copy link
Contributor

@JamesHageman JamesHageman commented Feb 1, 2022

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 by Dir.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 of Dir.foreach, it renders files in the same order on any OS. For completeness, I'm also sorting file_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.

@JamesHageman JamesHageman changed the title sort template filenames krane render: render templates in deterministic order Feb 1, 2022
@JamesHageman JamesHageman changed the title krane render: render templates in deterministic order krane render: render templates in deterministic order Feb 1, 2022
@JamesHageman JamesHageman marked this pull request as ready for review February 1, 2022 16:53
@JamesHageman JamesHageman requested a review from a team as a code owner February 1, 2022 16:53
@JamesHageman JamesHageman requested review from ethanaubuchon and camteasdale143 and removed request for a team and timothysmith0609 February 1, 2022 16:53
@jpfourny
Copy link
Contributor

jpfourny commented Feb 1, 2022

Given the nature of the change, it's not critical to roll this out everywhere. It would be prudent to test it at least with app runtimes (in gkrane) - I can take care of that.

@JamesHageman JamesHageman merged commit af9b3df into master Feb 2, 2022
@JamesHageman JamesHageman mentioned this pull request Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants