-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'GoogleCloudPlatform:main' into hns_folders
- Loading branch information
Showing
42 changed files
with
1,847 additions
and
607 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"magician/exec" | ||
"magician/github" | ||
"magician/source" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var vcrMergeEapCmd = &cobra.Command{ | ||
Use: "vcr-merge-eap", | ||
Short: "Merge VCR cassettes for EAP", | ||
Long: `This command is triggered in .ci/gcb-push-downstream.yml to merge vcr cassettes. | ||
The command expects the following as arguments: | ||
1. CL number | ||
It then performs the following operations: | ||
1. Run gsutil to list, copy, and remove the vcr cassettes fixtures. | ||
`, | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clNumber := args[0] | ||
fmt.Println("CL number:", clNumber) | ||
|
||
githubToken, ok := os.LookupEnv("GITHUB_TOKEN_CLASSIC") | ||
if !ok { | ||
return fmt.Errorf("did not provide GITHUB_TOKEN_CLASSIC environment variable") | ||
} | ||
|
||
baseBranch := os.Getenv("BASE_BRANCH") | ||
if baseBranch == "" { | ||
return fmt.Errorf("environment variable BASE_BRANCH is empty") | ||
} | ||
|
||
rnr, err := exec.NewRunner() | ||
if err != nil { | ||
return fmt.Errorf("error creating Runner: %w", err) | ||
} | ||
|
||
gh := github.NewClient(githubToken) | ||
return execVCRMergeEAP(gh, clNumber, baseBranch, rnr) | ||
}, | ||
} | ||
|
||
func execVCRMergeEAP(gh GithubClient, clNumber, baseBranch string, runner source.Runner) error { | ||
head := "auto-cl-" + clNumber | ||
mergeCassettes("gs://ci-vcr-cassettes/private", baseBranch, fmt.Sprintf("refs/heads/%s", head), runner) | ||
return nil | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(vcrMergeEapCmd) | ||
} |
Oops, something went wrong.