Skip to content
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

Use index from requests in buildQuickSyncPipeline #5242

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/app/pipedv1/plugin/kubernetes/deployment/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,24 @@
}
}

func buildQuickSyncPipeline(autoRollback bool, now time.Time) []*model.PipelineStage {
func buildQuickSyncPipeline(index int32, autoRollback bool, now time.Time) []*model.PipelineStage {
var (
preStageID = ""
stage, _ = GetPredefinedStage(PredefinedStageK8sSync)
stages = []config.PipelineStage{stage}
out = make([]*model.PipelineStage, 0, len(stages))
)

for i, s := range stages {
for _, s := range stages {
id := s.ID
if id == "" {
id = fmt.Sprintf("stage-%d", i)
id = fmt.Sprintf("kubernetes-stage-%d", index)

Check warning on line 119 in pkg/app/pipedv1/plugin/kubernetes/deployment/pipeline.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/plugin/kubernetes/deployment/pipeline.go#L119

Added line #L119 was not covered by tests
}
stage := &model.PipelineStage{
Id: id,
Name: s.Name.String(),
Desc: s.Desc,
Index: int32(i),
Index: int32(index),
Predefined: true,
Visible: true,
Status: model.StageStatus_STAGE_NOT_STARTED_YET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ func TestBuildQuickSyncPipeline(t *testing.T) {

tests := []struct {
name string
index int32
autoRollback bool
expected []*model.PipelineStage
}{
{
name: "without auto rollback",
index: 0,
autoRollback: false,
expected: []*model.PipelineStage{
{
Expand All @@ -52,6 +54,7 @@ func TestBuildQuickSyncPipeline(t *testing.T) {
},
{
name: "with auto rollback",
index: 0,
autoRollback: true,
expected: []*model.PipelineStage{
{
Expand Down Expand Up @@ -82,7 +85,7 @@ func TestBuildQuickSyncPipeline(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual := buildQuickSyncPipeline(tt.autoRollback, now)
actual := buildQuickSyncPipeline(tt.index, tt.autoRollback, now)
assert.Equal(t, tt.expected, actual)
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/pipedv1/plugin/kubernetes/deployment/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
// BuildQuickSyncStages implements deployment.DeploymentServiceServer.
func (a *DeploymentService) BuildQuickSyncStages(ctx context.Context, request *deployment.BuildQuickSyncStagesRequest) (*deployment.BuildQuickSyncStagesResponse, error) {
now := time.Now()
stages := buildQuickSyncPipeline(request.GetRollback(), now)
stages := buildQuickSyncPipeline(request.GetStageIndex(), request.GetRollback(), now)

Check warning on line 75 in pkg/app/pipedv1/plugin/kubernetes/deployment/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/plugin/kubernetes/deployment/server.go#L75

Added line #L75 was not covered by tests
return &deployment.BuildQuickSyncStagesResponse{
Stages: stages,
}, nil
Expand Down
Loading