-
Notifications
You must be signed in to change notification settings - Fork 182
Allow deploy source to be nil considering the first deploy #5766
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5766 +/- ##
==========================================
+ Coverage 27.06% 27.08% +0.01%
==========================================
Files 504 504
Lines 53178 53184 +6
==========================================
+ Hits 14395 14407 +12
+ Misses 37709 37703 -6
Partials 1074 1074 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Yoshiki Fujikane <[email protected]>
193d5d7
to
0e33fa7
Compare
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.
almost LGTM
@@ -38,6 +38,10 @@ type DeploySource struct { | |||
} | |||
|
|||
func (d *DeploySource) ToPluginDeploySource() *common.DeploymentSource { | |||
if d == nil { |
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 this will go panic, right?
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.
@t-kikuc
This is not go panic.
This is to avoid panic for nil pointer reference.
Referencing a nil value will result in an panic such as d.AppDir
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 got it, i understood golang
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.
If we add this check here, other toXXX
converter methods could be required as well 🤔 So I think it could be better to emit that "object" here if it is not nil, don't check nil here (or we have to do that for all other methods). And my suggestion is to update this newDeploymentSource
constructor (ref: https://github.com/pipe-cd/pipecd/blob/master/pkg/plugin/sdk/deployment_source.go#L39-L50), since this error looks like: call to constructor to create object but get nil without error, to me. wdyt? @ffjlabo
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.
@khanhtc1202
According to the specifications, there are cases where DeploySource is nil, so I personally don't mind if it's included in ToXX, but what do you think?
I don't think it's necessary to check for nil in all To methods.
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.
As discussed with @khanhtc1202, we
noticed that it might be easy to understand to check nil outside ToPluginDeploySource
.
I'd be happy to hear other opinions. WDYT? @t-kikuc @Warashi
The fix↓
60708ca
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 agree with you. I think it's easy to understand and enough to check whether the variable is nil outside of the ToPluginDeploySource.
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 agree, it seems easier to check outside of the method.
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.
Thank you for checking!
I'll merge the fixed one🚀
Signed-off-by: Yoshiki Fujikane <[email protected]>
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 👍
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.
Good!
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 👍🏻
What this PR does:
Fix to allow deploy target to be nil considering the first deploy.
Why we need it:
When I register an app with plugin-architected pipd, the first deployment fails because the SDK does not consider the running deploy source to be nil.
FYI, this is the error msg I encountered.
Which issue(s) this PR fixes:
Fixes #
Does this PR introduce a user-facing change?: