-
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
Implement DetermineStrategy with SDK #5671
Conversation
Signed-off-by: Yoshiki Fujikane <[email protected]>
Signed-off-by: Yoshiki Fujikane <[email protected]>
// FIXME | ||
func (p *Plugin) DetermineStrategy(context.Context, *sdk.ConfigNone, *sdk.Client, *sdk.DetermineStrategyInput) (*sdk.DetermineStrategyResponse, error) { | ||
return &sdk.DetermineStrategyResponse{}, nil | ||
func (p *Plugin) DetermineStrategy(ctx context.Context, _ *sdk.ConfigNone, _ *sdk.Client, input *sdk.DetermineStrategyInput) (*sdk.DetermineStrategyResponse, error) { |
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.
reference implementation:
pipecd/pkg/app/pipedv1/plugin/kubernetes/deployment/server.go
Lines 82 to 107 in 7b4c9bd
func (a *DeploymentService) DetermineStrategy(ctx context.Context, request *deployment.DetermineStrategyRequest) (*deployment.DetermineStrategyResponse, error) { | |
cfg, err := config.DecodeYAML[*kubeconfig.KubernetesApplicationSpec](request.GetInput().GetTargetDeploymentSource().GetApplicationConfig()) | |
if err != nil { | |
return nil, status.Error(codes.InvalidArgument, err.Error()) | |
} | |
runnings, err := a.loadManifests(ctx, request.GetInput().GetDeployment(), cfg.Spec, request.GetInput().GetRunningDeploymentSource()) | |
if err != nil { | |
return nil, status.Error(codes.Internal, err.Error()) | |
} | |
targets, err := a.loadManifests(ctx, request.GetInput().GetDeployment(), cfg.Spec, request.GetInput().GetTargetDeploymentSource()) | |
if err != nil { | |
return nil, status.Error(codes.Internal, err.Error()) | |
} | |
strategy, summary := determineStrategy(runnings, targets, cfg.Spec.Workloads, a.logger) | |
return &deployment.DetermineStrategyResponse{ | |
SyncStrategy: strategy, | |
Summary: summary, | |
}, nil | |
} |
Signed-off-by: Yoshiki Fujikane <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5671 +/- ##
==========================================
- Coverage 25.57% 25.56% -0.02%
==========================================
Files 478 478
Lines 51240 51277 +37
==========================================
+ Hits 13105 13107 +2
- Misses 37130 37165 +35
Partials 1005 1005 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Let's try!
After merging this, let's refactor determineStrategy with no use of types from the model package.
What this PR does:
I implemented k8s DetermineStrategy by using SDK.
Why we need it:
We want to implement plugins with SDK.
Which issue(s) this PR fixes:
Part of #4980 #5006
Does this PR introduce a user-facing change?: