DRYer configs with python#37
Open
keshto wants to merge 1 commit intogneisstech:bedrock-mainfrom
keshto:bedrock-main
Open
DRYer configs with python#37keshto wants to merge 1 commit intogneisstech:bedrock-mainfrom keshto:bedrock-main
keshto wants to merge 1 commit intogneisstech:bedrock-mainfrom
keshto:bedrock-main
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Intention
The yaml is mostly the same with only a few differences. This can be templated away to be easier to compare the differences as well as not repeating oneself (DRY). Possibly related to this issue #15
Requirements
Install python3 and python3-yaml
sudo apt install python3 python3-yamlon deb based systemschmod the script
chmod +x bedrock/configuration/environments/yaml_filler.pyUsage
Notes
Running
./yaml_filler.py ciwill output a file named'br_k8s_ci.yaml'and./yaml_filler.py devwill output thedevversion named'br_k8s_dev.yaml'.This is a quickly hacked together script and is more for a demo of possible options to explore rather than something that should be merged. There are more considerations to be made. Such as if one was to move forward with python should one use Jinja type templates instead? There is a POSIX bash + awk way of doing this https://www.starkandwayne.com/blog/bashing-your-yaml/ however that has other issues explained in the article.
Also, please note that the order of the yaml after running the script (this is cosmetic and does not affect the functionality) will be different than the original template as well as no comments preserved in the output file.