-
Notifications
You must be signed in to change notification settings - Fork 42
fix: stacker convert should include ENV vars into the runtime config. #784
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
Open
jmblatten
wants to merge
1
commit into
project-stacker:main
Choose a base branch
from
geico:fix-convert-ENV
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
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 don't quite follow two things.
I apologize here, I should study the test case here; but if you already know I'd appreciate some background on what this change is doing.
Lastly; I was hoping to see a test that demonstrates the failure so it's easy to reason about the fix.
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.
Hi!
First, this testcase tests that "ENV FOO" will error out since it is syntactically incorrect. convertCommand() checks len(cmd.Value) < 3 for env and should error out.
It should be something like "ENV FOO=something". This patch does not change that behaviour.
This patch permits including the env vars defined in ENV(s) to be included into the runtime config for the image.
convertCommand() has a case stmt that handles conversions. A FROM conversion defines (declares and initializes) a layer and sets c.currLayer and c.output[c.currLayer]. Thus permitting subsequent convertCommand() calls to use that layer definition to add to runtime config if needed.
(i.e. ENV conversion sets layer.Environment)
So the invalid testcases sends data thru the convertCommand(). Before this patch, that particular testcase only needed a converter struct (NewConverter) to put the env vars into c.env for inclusion into the resulting stacker.yaml file. Now, with this patch, it also needs to add to runtime config using layer.Environment.
But, there isn't a FROM in the testcase data to set a layer definition.
To prevent a segfault, the invalid testcases whose conversions in convertCommand() use a layer definition for runtime config, set c.currLayer and c.output[c.currLayer] in the testcase's converter struct. Thus those first 3 lines in convertCommand() will result in setting a layer definition for the conversions to use.
Thus that extra chunk of code for that testcase. Otherwise, the testcase's behaviour should not change.