Skip to content

Commit

Permalink
milindcq/gh-84: pipelineID resolution fix for multi/mixed pipeline st…
Browse files Browse the repository at this point in the history
…ages (#83)

* remove faulty !hasChildPipelines check

* Fix logging and a mock output

---------

Co-authored-by: Milind Mistry <[email protected]>
  • Loading branch information
milindcq and milindcq authored Aug 10, 2023
1 parent 567fcf5 commit 6d5ad24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/backend/spinnaker/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ func (s *SpinClient) savePipeline(pipelineJSON string) (string, *http.Response,
return pipelineID, nil, wrappedErr
}

s.log.Info("Pipeline %q not found in application %q", pipelineName, application)
s.log.Infof("Pipeline %q not found in application %q", pipelineName, application)
}

// pipeline found, let's use Spinnaker's known Pipeline ID, otherwise we'll get one created for us
if len(foundPipeline) > 0 {
s.log.Info("Pipeline %q found with ID %q", foundPipeline["name"], foundPipeline["id"], application)
s.log.Infof("Pipeline %q found with ID %q in application %q", foundPipeline["name"], foundPipeline["id"], application)

pipeline["id"] = foundPipeline["id"].(string)
pipelineID = foundPipeline["id"].(string)
Expand Down Expand Up @@ -748,7 +748,7 @@ func (s *SpinClient) saveNestedPipeline(stages interface{}, pipeline map[string]
for _, stage := range childPipelineStages.([]interface{}) {
innerStage := stage.(map[string]interface{})

if !hasChildPipelines && mapContainsKey(innerStage, "application") && mapContainsKey(innerStage, "pipeline") && reflect.TypeOf(innerStage["pipeline"]).Kind() == reflect.String {
if mapContainsKey(innerStage, "application") && mapContainsKey(innerStage, "pipeline") && reflect.TypeOf(innerStage["pipeline"]).Kind() == reflect.String {
if response, result := s.findAndReplacePipelineNameWithFoundID(innerStage); response {
stage = result
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/backend/spinnaker/backend_mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func (a *MockApplicationControllerAPI) GetPipelineConfigUsingGET(ctx context.Con
res = map[string]interface{}{}
} else {
res = map[string]interface{}{
"id": "1234",
"name": pipelineName,
"id": "1234",
}
}

Expand Down

0 comments on commit 6d5ad24

Please sign in to comment.