-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Move variable defaults to -var-file #1079
Conversation
After this change, possible usages include:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but let's update the README to explain how this works and how customers should override defaults.
@mmerkes and I discussed this -- we're going to try moving as many variables into the var-file as possible, to avoid confusion about where defaults are defined. All variables that have a default value that isn't a go template will be moved to the variable file. New rev coming. |
Packer allows multiple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change. It'll simplify a bunch of things.
eks-worker-al2.json
Outdated
@@ -1,42 +1,43 @@ | |||
{ | |||
"_comment": "All template variables are enumerated here; and most variables have their default values defined in eks-worker-al2-variables.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit in duplicating the variables here? Can't eks-worker-al2-variables.json
be the source of truth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR dynamically discovers the variables from the template using packer inspect
, so they need to be present in the template.
We could pull these out of the variables file with something else like jq
, but I'd prefer to use the Packer mechanism if it's reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the packer inspect
usage I'm referring to:
Line 2 in 8da3272
AVAILABLE_PACKER_VARIABLES := $(shell $(PACKER_BINARY) inspect -machine-readable eks-worker-al2.json | grep 'template-variable' | awk -F ',' '{print $$4}') |
|
||
Users have the following options for specifying their own values: | ||
|
||
1. Provide a variable file with the `PACKER_VARIABLE_FILE` argument to `make`. Values in this file will override values in the default variable file. Your variable file does not need to include all possible variables, as it will be merged with the default variable file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be possible to write tests for these behaviors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I saw your comment stating that packer is the one which does this so no point in testing that. Contents of that comment might be good for this section too. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd err on the side of fewer impl details in this doc, but I don't feel too strongly. Can totally add if you think it's necessary
Description of changes:
These variables appear in multiple templates internally, so this will centralize the values.
I also fixed a weird spacing issue with the
PACKER_VARIABLES
logic. Theforeach
function inmake
will join the expanded 3rd argument with a space character. When the loop evaluates for packer variables that aren't defined, it results in a ton of extra space being inserted. Example before this change:and after this change:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Testing Done
Succeeded: