Skip to content
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
10 changes: 7 additions & 3 deletions pkg/model/deployment.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pkg/model/deployment.proto
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,19 @@ 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;
// Stage index from the stage list in configuration.
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.
Expand Down
21 changes: 7 additions & 14 deletions pkg/plugin/sdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
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

Check warning on line 202 in pkg/plugin/sdk/deployment.go

View check run for this annotation

Codecov / codecov/patch

pkg/plugin/sdk/deployment.go#L202

Added line #L202 was not covered by tests
}
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())
Expand Down Expand Up @@ -428,24 +428,19 @@
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,
}, nil
}

// 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 {

Check warning on line 440 in pkg/plugin/sdk/deployment.go

View check run for this annotation

Codecov / codecov/patch

pkg/plugin/sdk/deployment.go#L440

Added line #L440 was not covered by tests
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))

Check warning on line 443 in pkg/plugin/sdk/deployment.go

View check run for this annotation

Codecov / codecov/patch

pkg/plugin/sdk/deployment.go#L442-L443

Added lines #L442 - L443 were not covered by tests
}
return &deployment.BuildQuickSyncStagesResponse{
Stages: stages,
Expand Down Expand Up @@ -528,9 +523,8 @@
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),
Expand Down Expand Up @@ -559,9 +553,8 @@
AvailableOperation ManualOperation
}

func (p *QuickSyncStage) toModel(id string, now time.Time) *model.PipelineStage {
func (p *QuickSyncStage) toModel(now time.Time) *model.PipelineStage {

Check warning on line 556 in pkg/plugin/sdk/deployment.go

View check run for this annotation

Codecov / codecov/patch

pkg/plugin/sdk/deployment.go#L556

Added line #L556 was not covered by tests
return &model.PipelineStage{
Id: id,
Name: p.Name,
Desc: p.Description,
Index: 0,
Expand Down