Skip to content

Commit 9f5ca4c

Browse files
authored
Merge branch 'GoogleCloudPlatform:main' into tflint_provider
2 parents 89bb69f + 6440099 commit 9f5ca4c

File tree

3,082 files changed

+344325
-8994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,082 files changed

+344325
-8994
lines changed

.ci/gcb-push-downstream.yml

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ steps:
3535
id: tpg-sync
3636
waitFor: ["build-magician-binary"]
3737
args:
38-
- wait-for-commit
38+
- 'wait-for-commit'
3939
- 'tpg-sync'
4040
- $BRANCH_NAME
4141
- $COMMIT_SHA
@@ -46,7 +46,7 @@ steps:
4646
id: tpgb-sync
4747
waitFor: ["build-magician-binary"]
4848
args:
49-
- wait-for-commit
49+
- 'wait-for-commit'
5050
- 'tpgb-sync'
5151
- $BRANCH_NAME
5252
- $COMMIT_SHA
@@ -57,7 +57,7 @@ steps:
5757
id: tgc-sync
5858
waitFor: ["build-magician-binary"]
5959
args:
60-
- wait-for-commit
60+
- 'wait-for-commit'
6161
- 'tgc-sync'
6262
- $BRANCH_NAME
6363
- $COMMIT_SHA
@@ -68,7 +68,7 @@ steps:
6868
id: tf-oics-sync
6969
waitFor: ["build-magician-binary"]
7070
args:
71-
- wait-for-commit
71+
- 'wait-for-commit'
7272
- 'tf-oics-sync'
7373
- $BRANCH_NAME
7474
- $COMMIT_SHA
@@ -88,18 +88,15 @@ steps:
8888
- 'ga'
8989
- $COMMIT_SHA
9090

91-
- name: 'gcr.io/cloud-builders/git'
91+
- name: 'gcr.io/graphite-docker-images/go-plus'
9292
waitFor: ["tpg-push"]
9393
secretEnv: ["GITHUB_TOKEN_CLASSIC"]
94-
entrypoint: 'bash'
94+
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
9595
args:
96-
- -c
97-
- |
98-
if [ "$BRANCH_NAME" == "main" ]; then
99-
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tpg-sync
100-
else
101-
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tpg-sync-$BRANCH_NAME
102-
fi
96+
- 'sync-branch'
97+
- 'tpg-sync'
98+
- $BRANCH_NAME
99+
- $COMMIT_SHA
103100

104101
# TPGB
105102
- name: 'gcr.io/graphite-docker-images/build-environment'
@@ -116,18 +113,15 @@ steps:
116113
- 'beta'
117114
- $COMMIT_SHA
118115

119-
- name: 'gcr.io/cloud-builders/git'
116+
- name: 'gcr.io/graphite-docker-images/go-plus'
120117
waitFor: ["tpgb-push"]
121118
secretEnv: ["GITHUB_TOKEN_CLASSIC"]
122-
entrypoint: 'bash'
119+
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
123120
args:
124-
- -c
125-
- |
126-
if [ "$BRANCH_NAME" == "main" ]; then
127-
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tpgb-sync
128-
else
129-
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tpgb-sync-$BRANCH_NAME
130-
fi
121+
- 'sync-branch'
122+
- 'tpgb-sync'
123+
- $BRANCH_NAME
124+
- $COMMIT_SHA
131125

132126
# TGC
133127
- name: 'gcr.io/graphite-docker-images/build-environment'
@@ -144,18 +138,15 @@ steps:
144138
- 'beta'
145139
- $COMMIT_SHA
146140

147-
- name: 'gcr.io/cloud-builders/git'
141+
- name: 'gcr.io/graphite-docker-images/go-plus'
148142
waitFor: ["tgc-push"]
149143
secretEnv: ["GITHUB_TOKEN_CLASSIC"]
150-
entrypoint: 'bash'
144+
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
151145
args:
152-
- -c
153-
- |
154-
if [ "$BRANCH_NAME" == "main" ]; then
155-
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tgc-sync
156-
else
157-
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tgc-sync-$BRANCH_NAME
158-
fi
146+
- 'sync-branch'
147+
- 'tgc-sync'
148+
- $BRANCH_NAME
149+
- $COMMIT_SHA
159150

160151
# TF-OICS
161152
- name: 'gcr.io/graphite-docker-images/build-environment'
@@ -172,18 +163,15 @@ steps:
172163
- 'beta'
173164
- $COMMIT_SHA
174165

175-
- name: 'gcr.io/cloud-builders/git'
166+
- name: 'gcr.io/graphite-docker-images/go-plus'
176167
waitFor: ["tf-oics-push"]
177168
secretEnv: ["GITHUB_TOKEN_CLASSIC"]
178-
entrypoint: 'bash'
169+
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
179170
args:
180-
- -c
181-
- |
182-
if [ "$BRANCH_NAME" == "main" ]; then
183-
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tf-oics-sync
184-
else
185-
git push https://modular-magician:[email protected]/GoogleCloudPlatform/magic-modules $COMMIT_SHA:tf-oics-sync-$BRANCH_NAME
186-
fi
171+
- 'sync-branch'
172+
- 'tf-oics-sync'
173+
- $BRANCH_NAME
174+
- $COMMIT_SHA
187175

188176
- name: 'gcr.io/graphite-docker-images/go-plus'
189177
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'

.ci/magician/cmd/DIFF_COMMENT.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,22 @@ If you believe this detection to be incorrect please raise the concern with your
2424
If you intend to make this change you will need to wait for a [major release](https://www.terraform.io/plugin/sdkv2/best-practices/versioning#example-major-number-increments) window.
2525
An `override-breaking-change` label can be added to allow merging.
2626
{{end}}
27-
{{.MissingTests}}
27+
28+
{{if gt (len .MissingTests) 0}}
29+
## Missing test report
30+
Your PR includes resource fields which are not covered by any test.
31+
{{ range $resourceName, $missingTestInfo := .MissingTests }}
32+
Resource: `{{ $resourceName }}` ({{ len $missingTestInfo.Tests }} total tests)
33+
Please add an acceptance test which includes these fields. The test should include the following:
34+
35+
```hcl
36+
{{ $missingTestInfo.SuggestedTest }}
37+
38+
```
39+
40+
{{- end }}
41+
{{end}}
42+
2843
{{- $errorsLength := len .Errors}}
2944
{{- if gt $errorsLength 0}}
3045
## Errors

.ci/magician/cmd/SCHEDULED_PR_WAITING_FOR_CONTRIBUTOR.md.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ if lt .SinceDays 30 -}}
2-
@{{.PullRequest.User.Login}}, this PR is waiting for action from you. Please address any comments or change requests, or [re-request review](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review) from a core reviewer if no action is required.
2+
@{{.User}}, this PR is waiting for action from you. Please address any comments or change requests, or [re-request review](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review) from a core reviewer if no action is required.
33

44
![Image showing the re-request review button](https://docs.github.com/assets/cb-28785/mw-1440/images/help/pull_requests/request-re-review.webp)
55

@@ -10,5 +10,5 @@ If no action is taken, this PR will be closed in
1010

1111
This notification can be disabled with the `disable-automatic-closure` label.
1212
{{ else -}}
13-
@{{.PullRequest.User.Login}}, this PR is being closed due to inactivity.
13+
@{{.User}}, this PR is being closed due to inactivity.
1414
{{ end -}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This PR is approved and has been waiting for merge for {{if eq .SinceDays 5}}1 week{{else}}{{weekdaysToWeeks .SinceDays}} weeks{{end}}. Is it ready to merge? Use the label `disable-review-reminders` to disable these notifications.
1+
{{range .CoreReviewers}}@{{ . }} {{end}}This PR is approved and has been waiting for merge for {{if eq .SinceDays 5}}1 week{{else}}{{weekdaysToWeeks .SinceDays}} weeks{{end}}. Is it ready to merge? Use the label `disable-review-reminders` to disable these notifications.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{if ge .SinceDays 5}}@GoogleCloudPlatform/terraform-team {{end}}This PR has been waiting for review for {{if lt .SinceDays 5}}{{.SinceDays}} weekdays{{else if eq .SinceDays 5}}1 week{{else}}{{weekdaysToWeeks .SinceDays}} weeks{{end}}. Please take a look! Use the label `disable-review-reminders` to disable these notifications.
1+
{{if ge .SinceDays 5}}@GoogleCloudPlatform/terraform-team {{end}}{{range .CoreReviewers}}@{{ . }} {{end}}This PR has been waiting for review for {{if lt .SinceDays 5}}{{.SinceDays}} weekdays{{else if eq .SinceDays 5}}1 week{{else}}{{weekdaysToWeeks .SinceDays}} weeks{{end}}. Please take a look! Use the label `disable-review-reminders` to disable these notifications.

.ci/magician/cmd/check_cassettes.go

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,33 @@ var checkCassettesCmd = &cobra.Command{
4343
` + listCCEnvironmentVariables() + `
4444
4545
It prints a list of tests that failed in replaying mode along with all test output.`,
46-
Run: func(cmd *cobra.Command, args []string) {
46+
RunE: func(cmd *cobra.Command, args []string) error {
4747
env := make(map[string]string, len(ccEnvironmentVariables))
4848
for _, ev := range ccEnvironmentVariables {
4949
val, ok := os.LookupEnv(ev)
5050
if !ok {
51-
fmt.Printf("Did not provide %s environment variable\n", ev)
52-
os.Exit(1)
51+
return fmt.Errorf("did not provide %s environment variable", ev)
5352
}
5453
env[ev] = val
5554
}
5655

5756
githubToken, ok := lookupGithubTokenOrFallback("GITHUB_TOKEN_DOWNSTREAMS")
5857
if !ok {
59-
fmt.Println("Did not provide GITHUB_TOKEN_DOWNSTREAMS or GITHUB_TOKEN environment variables")
60-
os.Exit(1)
58+
return fmt.Errorf("did not provide GITHUB_TOKEN_DOWNSTREAMS or GITHUB_TOKEN environment variables")
6159
}
6260

6361
rnr, err := exec.NewRunner()
6462
if err != nil {
65-
fmt.Println("Error creating Runner: ", err)
66-
os.Exit(1)
63+
return fmt.Errorf("error creating Runner: %w", err)
6764
}
6865

6966
ctlr := source.NewController(env["GOPATH"], "modular-magician", githubToken, rnr)
7067

7168
vt, err := vcr.NewTester(env, rnr)
7269
if err != nil {
73-
fmt.Println("Error creating VCR tester: ", err)
74-
os.Exit(1)
70+
return fmt.Errorf("error creating VCR tester: %w", err)
7571
}
76-
execCheckCassettes(env["COMMIT_SHA"], vt, ctlr)
72+
return execCheckCassettes(env["COMMIT_SHA"], vt, ctlr)
7773
},
7874
}
7975

@@ -93,10 +89,9 @@ func listCCEnvironmentVariables() string {
9389
return result
9490
}
9591

96-
func execCheckCassettes(commit string, vt *vcr.Tester, ctlr *source.Controller) {
92+
func execCheckCassettes(commit string, vt *vcr.Tester, ctlr *source.Controller) error {
9793
if err := vt.FetchCassettes(provider.Beta, "main", ""); err != nil {
98-
fmt.Println("Error fetching cassettes: ", err)
99-
os.Exit(1)
94+
return fmt.Errorf("error fetching cassettes: %w", err)
10095
}
10196

10297
providerRepo := &source.Repo{
@@ -105,8 +100,7 @@ func execCheckCassettes(commit string, vt *vcr.Tester, ctlr *source.Controller)
105100
}
106101
ctlr.SetPath(providerRepo)
107102
if err := ctlr.Clone(providerRepo); err != nil {
108-
fmt.Println("Error cloning provider: ", err)
109-
os.Exit(1)
103+
return fmt.Errorf("error cloning provider: %w", err)
110104
}
111105
vt.SetRepoPath(provider.Beta, providerRepo.Path)
112106

@@ -115,18 +109,17 @@ func execCheckCassettes(commit string, vt *vcr.Tester, ctlr *source.Controller)
115109
fmt.Println("Error running VCR: ", err)
116110
}
117111
if err := vt.UploadLogs("vcr-check-cassettes", "", "", false, false, vcr.Replaying, provider.Beta); err != nil {
118-
fmt.Println("Error uploading logs: ", err)
119-
os.Exit(1)
112+
return fmt.Errorf("error uploading logs: %w", err)
120113
}
121114
fmt.Println(len(result.FailedTests), " failed tests: ", result.FailedTests)
122115
// TODO(trodge) report these failures to bigquery
123116
fmt.Println(len(result.PassedTests), " passed tests: ", result.PassedTests)
124117
fmt.Println(len(result.SkippedTests), " skipped tests: ", result.SkippedTests)
125118

126119
if err := vt.Cleanup(); err != nil {
127-
fmt.Println("Error cleaning up vcr tester: ", err)
128-
os.Exit(1)
120+
return fmt.Errorf("error cleaning up vcr tester: %w", err)
129121
}
122+
return nil
130123
}
131124

132125
func init() {

.ci/magician/cmd/community_checker.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"fmt"
2020
"magician/cloudbuild"
2121
"magician/github"
22-
"os"
2322

2423
"github.com/spf13/cobra"
2524
)
@@ -42,7 +41,7 @@ var communityApprovalCmd = &cobra.Command{
4241
1. Trigger cloud presubmits with specific substitutions for the PR.
4342
2. Remove the 'awaiting-approval' label from the PR.
4443
`,
45-
Run: func(cmd *cobra.Command, args []string) {
44+
RunE: func(cmd *cobra.Command, args []string) error {
4645
prNumber := args[0]
4746
fmt.Println("PR Number: ", prNumber)
4847

@@ -63,16 +62,15 @@ var communityApprovalCmd = &cobra.Command{
6362

6463
githubToken, ok := lookupGithubTokenOrFallback("GITHUB_TOKEN_MAGIC_MODULES")
6564
if !ok {
66-
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES or GITHUB_TOKEN environment variables")
67-
os.Exit(1)
65+
return fmt.Errorf("did not provide GITHUB_TOKEN_MAGIC_MODULES or GITHUB_TOKEN environment variables")
6866
}
6967
gh := github.NewClient(githubToken)
7068
cb := cloudbuild.NewClient()
71-
execCommunityChecker(prNumber, commitSha, branchName, headRepoUrl, headBranch, baseBranch, gh, cb)
69+
return execCommunityChecker(prNumber, commitSha, branchName, headRepoUrl, headBranch, baseBranch, gh, cb)
7270
},
7371
}
7472

75-
func execCommunityChecker(prNumber, commitSha, branchName, headRepoUrl, headBranch, baseBranch string, gh GithubClient, cb CloudbuildClient) {
73+
func execCommunityChecker(prNumber, commitSha, branchName, headRepoUrl, headBranch, baseBranch string, gh GithubClient, cb CloudbuildClient) error {
7674
substitutions := map[string]string{
7775
"BRANCH_NAME": branchName,
7876
"_PR_NUMBER": prNumber,
@@ -85,13 +83,13 @@ func execCommunityChecker(prNumber, commitSha, branchName, headRepoUrl, headBran
8583
// (explicitly or via membership-checker)
8684
err := cb.TriggerMMPresubmitRuns(commitSha, substitutions)
8785
if err != nil {
88-
fmt.Println(err)
89-
os.Exit(1)
86+
return err
9087
}
9188

9289
// in community-checker job:
9390
// remove awaiting-approval label from external contributor PRs
9491
gh.RemoveLabel(prNumber, "awaiting-approval")
92+
return nil
9593
}
9694

9795
func init() {

0 commit comments

Comments
 (0)