-
Notifications
You must be signed in to change notification settings - Fork 18
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 overwrite of package resources with empty resource map #123
Merged
+38
−22
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b75160d
Pushing a package with no changes in resources deletes all resources …
liamfallon a2c4950
Allow all mutations to cary on in the case of more than one
liamfallon 4c36ecc
Remove references to DB
liamfallon c3e1170
Incvestigate why e2e failing on github
liamfallon f059489
Incvestigate why e2e failing on github
liamfallon f8383e5
Updated fix and test to check for empty resources
liamfallon 23ee51c
Updated code to show how renderStatus is handled
liamfallon 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 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 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
Oops, something went wrong.
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.
are you using the
renderStatus
return value somewhere? if not, then I think marking the fact that it is ignored by naming it_
is the idiomatic way to go.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.
renderStatus
is returned by the function on lines 1043 and 1047.Now,
renderStatus
was set by line 1032 before I introduced the if statement at line 1025. Looking at theapplyResourceMutations
function, when it is called at line 1020, it will return with a value ofnil
; the loop exits on thecontinue
at line 1057 withrenderStatus
not set.Another approach would be to use
-
in line 1021 as you sugges, but then I would have to add a line before line 1025 to declarerenderStatus
and set it to nil for the return statements.I think the code here is quite confusing, especially the double call to
applyResourceMutations
but here, I was trying to make as few changes as possible. I think engine.go in its entirety should be among the first files to target for refactoring in Porch.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.
The
renderStatus
returned by this method will eventually be written back to the status of thePackageRevisionResources
object returned by the Update() call. So far it represented the results of the render operation (a.k.a. executing the pipeline of the kpt package).If the body of your if statement is skipped, no actual rendering is happening, so IMHO the intuitive way of handling this case would be to return with a nil renderStatus.
Now I think this is exactly what your code is doing, because the first
applyResourceMutations
call doesn't have a render mutation in its input (a render mutation is of type "eval"), so it will return with a nil renderStatus. So I think your code is correct.However.... :) [sorry for the nitpicking]
IMHO it would be more readable if you would explicitly drop the renderStatus return value in the first
applyResourceMutations
call, by naming it_
, as it was before.And explicitly set the renderStatus to nil in the else branch of your new if statement. That would express the logic more directly: if there was a change do a render and return with its results, if there are no changes, no render is needed, and return with and empty render result.
I just want to reiterate that your code is correct as is, so you can safely choose to ignore any of the above.
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'll change it, it's probably clearer all right, I'll update it.
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.
It's changed in the latest update there. Thanks @kispaljr