This repository was archived by the owner on May 25, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
1313 "github.com/go-resty/resty/v2"
1414 log "github.com/sirupsen/logrus"
1515 "github.com/spf13/viper"
16+ "gopkg.in/yaml.v2"
1617)
1718
1819func ensureTargetConnection () error {
@@ -119,8 +120,17 @@ func importYaml(yamlPath, action string) error {
119120 SetAuthToken (targetConfig .accesstoken ).
120121 SetError (& CodeStreamException {}).
121122 Post ("https://" + targetConfig .server + "/pipeline/api/import" )
123+ log .Debugln (queryResponse .Request .RawRequest .URL )
122124 if queryResponse .IsError () {
123125 return queryResponse .Error ().(error )
124126 }
127+ var importResponse CodeStreamPipelineImportResponse
128+ err = yaml .Unmarshal (queryResponse .Body (), & importResponse )
129+ if importResponse .Status != "CREATED" && action == "create" {
130+ return errors .New (importResponse .Status + " - " + importResponse .StatusMessage )
131+ }
132+ if importResponse .Status != "UPDATED" && action == "apply" {
133+ return errors .New (importResponse .Status + " - " + importResponse .StatusMessage )
134+ }
125135 return nil
126136}
Original file line number Diff line number Diff line change @@ -231,3 +231,10 @@ type CodeStreamCustomIntegration struct {
231231 Status string `json:"status"`
232232 Yaml string `json:"yaml"`
233233}
234+
235+ // CodeStreamException - Generic exception struct
236+ type CodeStreamPipelineImportResponse struct {
237+ Name string `yaml:"name"`
238+ Status string `yaml:"status"`
239+ StatusMessage string `yaml:"statusMessage"`
240+ }
You can’t perform that action at this time.
0 commit comments