Skip to content

DRYer configs with python#37

Open
keshto wants to merge 1 commit intogneisstech:bedrock-mainfrom
keshto:bedrock-main
Open

DRYer configs with python#37
keshto wants to merge 1 commit intogneisstech:bedrock-mainfrom
keshto:bedrock-main

Conversation

@keshto
Copy link
Copy Markdown

@keshto keshto commented Mar 20, 2021

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-yaml on deb based systems

chmod the script

  • chmod +x bedrock/configuration/environments/yaml_filler.py

Usage

./yaml_filler.py 
Invalid option or number of arguments.

Usage: yaml_filler.py [OPTION]
Fill in the template.yaml with values depending on deployment option.

Options:
  ci     fill out the template using the ci values
  dev    fill out the template using the dev values

Notes
Running ./yaml_filler.py ci will output a file named 'br_k8s_ci.yaml' and ./yaml_filler.py dev will output the dev version 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.

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.

1 participant