diff --git a/pkg/model/deployment.pb.go b/pkg/model/deployment.pb.go index 25862dce99..412578e84a 100644 --- a/pkg/model/deployment.pb.go +++ b/pkg/model/deployment.pb.go @@ -704,6 +704,8 @@ type PipelineStage struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // Plugin-arch piped note: + // This id will be generated by the piped on planning time. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Desc string `protobuf:"bytes,3,opt,name=desc,proto3" json:"desc,omitempty"` @@ -712,9 +714,11 @@ type PipelineStage struct { // Whether this stage is the predefined one by planner. // // Deprecated: Do not use. - Predefined bool `protobuf:"varint,5,opt,name=predefined,proto3" json:"predefined,omitempty"` - Requires []string `protobuf:"bytes,6,rep,name=requires,proto3" json:"requires,omitempty"` - // Whether this stage should be rendered or not. + Predefined bool `protobuf:"varint,5,opt,name=predefined,proto3" json:"predefined,omitempty"` + // This field is used for UI to specify the stage order in graph, + // as well as the current stage execution order. + Requires []string `protobuf:"bytes,6,rep,name=requires,proto3" json:"requires,omitempty"` + // This field is used for UI to specify whether this stage should be rendered or not. // // Deprecated: Do not use. Visible bool `protobuf:"varint,7,opt,name=visible,proto3" json:"visible,omitempty"` diff --git a/pkg/model/deployment.proto b/pkg/model/deployment.proto index b2aa10924d..0665fdd417 100644 --- a/pkg/model/deployment.proto +++ b/pkg/model/deployment.proto @@ -142,6 +142,8 @@ message DeploymentTrigger { } message PipelineStage { + // Plugin-arch piped note: + // This id will be generated by the piped on planning time. string id = 1 [(validate.rules).string.min_len = 1]; string name = 2 [(validate.rules).string.min_len = 1]; string desc = 3; @@ -149,8 +151,10 @@ message PipelineStage { int32 index = 4; // Whether this stage is the predefined one by planner. bool predefined = 5 [deprecated=true]; + // This field is used for UI to specify the stage order in graph, + // as well as the current stage execution order. repeated string requires = 6; - // Whether this stage should be rendered or not. + // This field is used for UI to specify whether this stage should be rendered or not. bool visible = 7 [deprecated=true]; StageStatus status = 8 [(validate.rules).enum.defined_only = true]; // The human-readable description why the stage is at current status. diff --git a/pkg/plugin/sdk/deployment.go b/pkg/plugin/sdk/deployment.go index d8a55833d3..0aa427f91c 100644 --- a/pkg/plugin/sdk/deployment.go +++ b/pkg/plugin/sdk/deployment.go @@ -199,7 +199,7 @@ func (s *DeploymentPluginServiceServer[Config, DeployTargetConfig, ApplicationCo if err != nil { return nil, status.Errorf(codes.Internal, "failed to build quick sync stages: %v", err) } - return newQuickSyncStagesResponse(s.name, time.Now(), response), nil + return newQuickSyncStagesResponse(time.Now(), response), nil } func (s *DeploymentPluginServiceServer[Config, DeployTargetConfig, ApplicationConfigSpec]) ExecuteStage(ctx context.Context, request *deployment.ExecuteStageRequest) (response *deployment.ExecuteStageResponse, _ error) { lp := s.logPersister.StageLogPersister(request.GetInput().GetDeployment().GetId(), request.GetInput().GetStage().GetId()) @@ -428,12 +428,8 @@ func newPipelineSyncStagesResponse(pluginName string, now time.Time, request *de if !ok { return nil, status.Errorf(codes.Internal, "missing stage with index %d in the request, it's unexpected behavior of the plugin", s.Index) } - id := requestStage.GetId() - if id == "" { - id = fmt.Sprintf("%s-stage-%d", pluginName, s.Index) - } - stages = append(stages, s.toModel(id, requestStage.GetDesc(), now)) + stages = append(stages, s.toModel(requestStage.GetDesc(), now)) } return &deployment.BuildPipelineSyncStagesResponse{ Stages: stages, @@ -441,11 +437,10 @@ func newPipelineSyncStagesResponse(pluginName string, now time.Time, request *de } // newQuickSyncStagesResponse converts the response to the external representation. -func newQuickSyncStagesResponse(pluginName string, now time.Time, response *BuildQuickSyncStagesResponse) *deployment.BuildQuickSyncStagesResponse { +func newQuickSyncStagesResponse(now time.Time, response *BuildQuickSyncStagesResponse) *deployment.BuildQuickSyncStagesResponse { stages := make([]*model.PipelineStage, 0, len(response.Stages)) - for i, s := range response.Stages { - id := fmt.Sprintf("%s-stage-%d", pluginName, i) - stages = append(stages, s.toModel(id, now)) + for _, s := range response.Stages { + stages = append(stages, s.toModel(now)) } return &deployment.BuildQuickSyncStagesResponse{ Stages: stages, @@ -528,9 +523,8 @@ type PipelineStage struct { AvailableOperation ManualOperation } -func (p *PipelineStage) toModel(id, description string, now time.Time) *model.PipelineStage { +func (p *PipelineStage) toModel(description string, now time.Time) *model.PipelineStage { return &model.PipelineStage{ - Id: id, Name: p.Name, Desc: description, Index: int32(p.Index), @@ -559,9 +553,8 @@ type QuickSyncStage struct { AvailableOperation ManualOperation } -func (p *QuickSyncStage) toModel(id string, now time.Time) *model.PipelineStage { +func (p *QuickSyncStage) toModel(now time.Time) *model.PipelineStage { return &model.PipelineStage{ - Id: id, Name: p.Name, Desc: p.Description, Index: 0,