-
Notifications
You must be signed in to change notification settings - Fork 157
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
Pass DeployTarget in SDK #5616
Pass DeployTarget in SDK #5616
Changes from 2 commits
d5b9bdf
fa64fcd
8173d91
fbb133e
fc90b4c
03519ad
0e167c0
1efc476
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -206,7 +206,33 @@ | |||||||||||||||||
stageID: request.GetInput().GetStage().GetId(), | ||||||||||||||||||
logPersister: lp, | ||||||||||||||||||
} | ||||||||||||||||||
return executeStage(ctx, s.base, &s.config, nil, client, request, s.logger) // TODO: pass the deployTargets | ||||||||||||||||||
|
||||||||||||||||||
dtNames, err := request.GetInput().GetDeployment().GetDeployTargets(s.commonFields.config.Name) | ||||||||||||||||||
if err != nil { | ||||||||||||||||||
return nil, status.Errorf(codes.Internal, "failed to get deploy targets for plugin %s: %v", s.commonFields.config.Name, err) | ||||||||||||||||||
} | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The plugin which doesn't have deploy target configurations such as WAIT will return an error in this if statement, and it's not expected behavior. ref; pipecd/pkg/model/deployment.go Lines 217 to 224 in 4afa3e6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||
|
||||||||||||||||||
deployTargets := make([]*DeployTarget[DeployTargetConfig], 0, len(dtNames)) | ||||||||||||||||||
for _, name := range dtNames { | ||||||||||||||||||
if dt := s.commonFields.config.FindDeployTarget(name); dt != nil { | ||||||||||||||||||
var sdkDt DeployTargetConfig | ||||||||||||||||||
if err := json.Unmarshal(dt.Config, &sdkDt); err != nil { | ||||||||||||||||||
return nil, status.Errorf(codes.Internal, "failed to unmarshal deploy target config: %v", err) | ||||||||||||||||||
} | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IMO] If possible, it's better to cache DeployTargetConfigs in the server instead of repeating unmarshaling. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! TODO is best for this case! We don't have to do that now. |
||||||||||||||||||
|
||||||||||||||||||
deployTargets = append(deployTargets, &DeployTarget[DeployTargetConfig]{ | ||||||||||||||||||
Name: name, | ||||||||||||||||||
Labels: dt.Labels, | ||||||||||||||||||
Config: sdkDt, | ||||||||||||||||||
}) | ||||||||||||||||||
} | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IMO] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed on 8173d91 |
||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
if len(dtNames) != len(deployTargets) { | ||||||||||||||||||
return nil, status.Errorf(codes.Internal, "the number of deploy targets in the piped plugin config should be the same as the ones set on the deployment") | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nits] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed on fc90b4c |
||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
return executeStage(ctx, s.base, &s.config, deployTargets, client, request, s.logger) | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// StagePluginServiceServer is the gRPC server that handles requests from the piped. | ||||||||||||||||||
|
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.
[nits]
[nit]
I wanna clarify which one we mention,
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.
Fixed on fbb133e