-
Notifications
You must be signed in to change notification settings - Fork 167
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
Fix parameter handling for diffs #540
Conversation
Codecov Report
@@ Coverage Diff @@
## master #540 +/- ##
==========================================
- Coverage 87.53% 87.51% -0.03%
==========================================
Files 94 94
Lines 6072 6077 +5
==========================================
+ Hits 5315 5318 +3
- Misses 757 759 +2
Continue to review full report at Codecov.
|
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.
Can you rebase this in top of b795e47? That commit adds a failing test for the diff command.
stacker/actions/diff.py
Outdated
parameters = self.build_parameters(stack) | ||
new_params = dict() | ||
for p in parameters: | ||
new_params[p['ParameterKey']] = p['ParameterValue'] | ||
new_template = stack.blueprint.to_json(new_params) |
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'm not sure this is the correct behavior. to_json
takes a dict of variables, not necessarily parameters. This change would make the behavior in _diff_stack
significantly different from _launch_stack. I think it's important that these use similar code paths or we're gonna run into these types of problems.
I think the root of the problem is the change from blueprint.rendered
to blueprint.to_json
in 4d0fad8#diff-1a5240c955da6d0e576a399c23c44953L215. to_json
apparently has too many side effects to really rely on it here.
I think this should probably just be switched back to using rendered
, which is what we use in _launch_stack
. It would mean diffing a JSON template against a YAML template will be garbage, but I think that's fine. Thoughts @troyready?
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 think calling .rendered
sounds like right thing to do. (bfe0343)
RE: diffing YAML against JSON. On a related note, I was just talking to a coworker yesterday about adding support to stacker to use YAML as the final representation instead of JSON. IMO, diffs of yaml are probably a bit cleaner, anyway. I'd be happy to work on adding that as a config option, if others thought it would be useful.
623514d
to
4a886a2
Compare
e799405
to
2cc8fcc
Compare
@ejholmes rebased and commit history cleaned up |
Good catch; sorry for my part in starting this pain :) Agreed on dropping to_json usage in diff. A case could be made to keep it if we were going to do it on both the old & new template, but I don't think anyone is going to lose sleep over a massive diff if they change a template from json -> yaml. |
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.
Looks good! Thanks @acmcelwee and @troyready!
Fix parameter handling for diffs
After using the DAG RC for the past week or so, I realized diffs were broken today. All of the param portions of the diffs came out as something like this:
This also led to a lot of unresolved variable errors like: