Skip to content

Commit

Permalink
Better handle the error in command not-scheduled
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsbhat committed Jun 27, 2023
1 parent 221b29a commit 8cb7099
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions cmd/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,21 @@ func getPipelineNotSchedulesCommand() *cobra.Command {
}

pipelineSchedules := make([]gocd.PipelineSchedules, 0)
var errors []string

for _, pipeline := range pipelines.Pipeline {
pipelineName, err := gocd.GetPipelineName(pipeline.Href)
if err != nil {
cliLogger.Errorf("fetching pipeline name from pipline url erored with:, %v", err)

continue
}

cliLogger.Infof("fetching schedules of pipeline %s", pipelineName)
cliLogger.Infof("fetching schedules of pipeline '%s'", pipelineName)
response, err := client.GetPipelineSchedules(pipelineName, "0", "1")
if err != nil {
errors = append(errors, err.Error())
cliLogger.Errorf("getting schedules for pipline '%s' errored with '%v'", pipelineName, err)

continue
}

timeNow := time.Now()
Expand Down Expand Up @@ -269,10 +272,6 @@ func getPipelineNotSchedulesCommand() *cobra.Command {
time.Sleep(delay)
}

if len(errors) != 0 {
cliLogger.Errorf("fetching pipeline schedules errored: %s", strings.Join(errors, ",\n"))
}

if len(jsonQuery) != 0 {
cliLogger.Debugf(queryEnabledMessage, jsonQuery)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/ghodss/yaml v1.0.0
github.com/nikhilsbhat/gocd-sdk-go v0.1.4
github.com/nikhilsbhat/gocd-sdk-go v0.1.5-0.20230627134633-2d1e4525a6f2
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.6.1
github.com/stretchr/testify v1.8.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/nikhilsbhat/gocd-sdk-go v0.1.4 h1:4hBs/qRLBgbh+M77OEEtx/Tqe9cgowMD+s1mvQuDQOI=
github.com/nikhilsbhat/gocd-sdk-go v0.1.4/go.mod h1:bIE3Xr7rRzOo0xSX/oa13kXNdFTgCR3JtCh/SontbwM=
github.com/nikhilsbhat/gocd-sdk-go v0.1.5-0.20230627134633-2d1e4525a6f2 h1:8+IpbFip/rSQ4hQgMVeEn0mibi1mdPKw2Z+sccESgFA=
github.com/nikhilsbhat/gocd-sdk-go v0.1.5-0.20230627134633-2d1e4525a6f2/go.mod h1:bIE3Xr7rRzOo0xSX/oa13kXNdFTgCR3JtCh/SontbwM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down

0 comments on commit 8cb7099

Please sign in to comment.