Implemented Rain::Env for pkg command #140
Merged
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.
Description of Changes:
I find it very useful to inject environmental variables into the template. Some use cases would include injecting a default AMI name into a template based on what environment the template is being packaged for (staging/production). For me this happens during CI/CD.
Expected Behavior
The name of the environmental variable is passed as the only argument to
Rain::Env
.If the environmental variable does not exist, then an error is returned, otherwise the value of the environmental variable is injected into the template as a string.
Example
Given a file named
template.yaml
with the following contents:Running the following command:
export AMI_IMAGE=ami-1234567890 rain pkg template.yml
Should result in a template that looks like this:
Additional Changes
I added some tests to for #136 as promised :)
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.