Skip to content

Commit

Permalink
fix: [ASSMT-476]: include Spinnaker credentialsInfo in the payload (#126
Browse files Browse the repository at this point in the history
)
  • Loading branch information
edgarulg authored Jul 17, 2024
1 parent ec2b5d9 commit acacd53
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func migrateSpinnakerPipelines() error {
}
var jsonBody []byte
var pipelines []map[string]interface{}
var credentials []map[string]interface{}
var err error
if len(migrationReq.PipelineName) > 0 {
jsonBody, err = getSinglePipeline(authMethod, migrationReq.PipelineName)
Expand All @@ -106,7 +107,11 @@ func migrateSpinnakerPipelines() error {
if err != nil {
return err
}
payload := map[string][]map[string]interface{}{"pipelines": pipelines}
credentials, err = getCredentialsInfo(authMethod)
if err != nil {
return err
}
payload := map[string][]map[string]interface{}{"pipelines": pipelines, "credentials": credentials}
_, err = createSpinnakerPipelines(payload)
return err
}
Expand Down Expand Up @@ -334,6 +339,22 @@ func getAllPipelines(authMethod string, appName string) ([]byte, error) {
return GetWithAuth(migrationReq.SpinnakerHost, "applications/"+appName+"/pipelineConfigs", authMethod, migrationReq.Auth64, migrationReq.Cert, migrationReq.Key, migrationReq.AllowInsecureReq)
}

func getCredentialsInfo(authMethod string) ([]map[string]interface{}, error) {
jsonBody, err := GetWithAuth(migrationReq.SpinnakerHost, "credentials", authMethod, migrationReq.Auth64, migrationReq.Cert, migrationReq.Key, migrationReq.AllowInsecureReq)
if err != nil {
return nil, err
}
credentials, err := normalizeJsonArray(jsonBody)
if err != nil {
return nil, err
}
filtered := make([]map[string]interface{}, 0)
for _, credential := range credentials {
filtered = append(filtered, map[string]interface{}{"name": credential["name"], "type": credential["type"]})
}
return filtered, nil
}

// this is because there's no endpoint in gate to fetch pipeline config based on a pipeline id
func findPipelineById(authMethod string, appName string, pipelineId string) (map[string]interface{}, error) {

Expand Down

0 comments on commit acacd53

Please sign in to comment.