Skip to content

Commit

Permalink
remove os.Exit in magician subcommands (GoogleCloudPlatform#10901)
Browse files Browse the repository at this point in the history
  • Loading branch information
iyabchen authored and BBBmau committed Jun 24, 2024
1 parent 548e5c2 commit 66660ce
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .ci/magician/cmd/generate_downstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func execGenerateDownstream(baseBranch, command, repo, version, ref string, gh G
if commitErr != nil {
fmt.Println("Error creating commit: ", commitErr)
if !strings.Contains(commitErr.Error(), "nothing to commit") {
os.Exit(1)
return fmt.Errorf("error creating commit: %w", commitErr)
}
}

Expand Down
3 changes: 1 addition & 2 deletions .ci/magician/cmd/scheduled_pr_reminders.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ var scheduledPrReminders = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
githubToken, ok := os.LookupEnv("GITHUB_TOKEN")
if !ok {
fmt.Println("Did not provide GITHUB_TOKEN environment variable")
os.Exit(1)
return fmt.Errorf("did not provide GITHUB_TOKEN environment variable")
}
gh := github.NewClient(nil).WithAuthToken(githubToken)
return execScheduledPrReminders(gh)
Expand Down
1 change: 0 additions & 1 deletion .ci/magician/cmd/test_tgc_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var testTGCIntegrationCmd = &cobra.Command{
rnr, err := exec.NewRunner()
if err != nil {
return fmt.Errorf("error creating runner: %w", err)
os.Exit(1)
}

ctlr := source.NewController(goPath, "modular-magician", githubToken, rnr)
Expand Down
4 changes: 1 addition & 3 deletions .ci/magician/cmd/wait_for_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"magician/exec"
"magician/source"
"os"
"strings"
"time"

Expand Down Expand Up @@ -33,8 +32,7 @@ var waitForCommitCmd = &cobra.Command{

rnr, err := exec.NewRunner()
if err != nil {
fmt.Println("Error creating Runner: ", err)
os.Exit(1)
return fmt.Errorf("error creating Runner: %w", err)
}

return execWaitForCommit(syncBranchPrefix, baseBranch, sha, rnr)
Expand Down

0 comments on commit 66660ce

Please sign in to comment.