Skip to content

Commit

Permalink
Merge pull request #11347 from shishir-a412ed/cleanup
Browse files Browse the repository at this point in the history
Code cleanup: Remove extra if clause.
  • Loading branch information
schmichael authored Oct 20, 2021
2 parents 6d35e2f + e14e355 commit fceb6ce
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 40 deletions.
6 changes: 1 addition & 5 deletions command/job_allocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ func (c *JobAllocsCommand) Run(args []string) int {
return 1
}
if len(jobs) > 1 {
if jobID != jobs[0].ID {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
if c.allNamespaces() && jobs[0].ID == jobs[1].ID {
if (jobID != jobs[0].ID) || (c.allNamespaces() && jobs[0].ID == jobs[1].ID) {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
Expand Down
6 changes: 1 addition & 5 deletions command/job_deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ func (c *JobDeploymentsCommand) Run(args []string) int {
return 1
}
if len(jobs) > 1 {
if jobID != jobs[0].ID {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
if c.allNamespaces() && jobs[0].ID == jobs[1].ID {
if (jobID != jobs[0].ID) || (c.allNamespaces() && jobs[0].ID == jobs[1].ID) {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
Expand Down
6 changes: 1 addition & 5 deletions command/job_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,7 @@ func (c *JobHistoryCommand) Run(args []string) int {
return 1
}
if len(jobs) > 1 {
if jobID != jobs[0].ID {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
if c.allNamespaces() && jobs[0].ID == jobs[1].ID {
if (jobID != jobs[0].ID) || (c.allNamespaces() && jobs[0].ID == jobs[1].ID) {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
Expand Down
6 changes: 1 addition & 5 deletions command/job_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,7 @@ func (c *JobInspectCommand) Run(args []string) int {
return 1
}
if len(jobs) > 1 {
if jobID != jobs[0].ID {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
if c.allNamespaces() && jobs[0].ID == jobs[1].ID {
if (jobID != jobs[0].ID) || (c.allNamespaces() && jobs[0].ID == jobs[1].ID) {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
Expand Down
6 changes: 1 addition & 5 deletions command/job_promote.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ func (c *JobPromoteCommand) Run(args []string) int {
return 1
}
if len(jobs) > 1 {
if jobID != jobs[0].ID {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
if c.allNamespaces() && jobs[0].ID == jobs[1].ID {
if (jobID != jobs[0].ID) || (c.allNamespaces() && jobs[0].ID == jobs[1].ID) {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
Expand Down
6 changes: 1 addition & 5 deletions command/job_revert.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@ func (c *JobRevertCommand) Run(args []string) int {
return 1
}
if len(jobs) > 1 {
if jobID != jobs[0].ID {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
if c.allNamespaces() && jobs[0].ID == jobs[1].ID {
if (jobID != jobs[0].ID) || (c.allNamespaces() && jobs[0].ID == jobs[1].ID) {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
Expand Down
6 changes: 1 addition & 5 deletions command/job_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,7 @@ func (c *JobStatusCommand) Run(args []string) int {
return 1
}
if len(jobs) > 1 {
if jobID != jobs[0].ID {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, allNamespaces)))
return 1
}
if allNamespaces && jobs[0].ID == jobs[1].ID {
if (jobID != jobs[0].ID) || (allNamespaces && jobs[0].ID == jobs[1].ID) {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, allNamespaces)))
return 1
}
Expand Down
6 changes: 1 addition & 5 deletions command/job_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,7 @@ func (c *JobStopCommand) Run(args []string) int {
return 1
}
if len(jobs) > 1 {
if jobID != jobs[0].ID {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
if c.allNamespaces() && jobs[0].ID == jobs[1].ID {
if (jobID != jobs[0].ID) || (c.allNamespaces() && jobs[0].ID == jobs[1].ID) {
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs, c.allNamespaces())))
return 1
}
Expand Down

0 comments on commit fceb6ce

Please sign in to comment.