Skip to content

Commit 7174ff4

Browse files
ScottSuarezhao-nan-li
authored andcommitted
validate template syntax needed (GoogleCloudPlatform#13929)
1 parent 8317d6f commit 7174ff4

File tree

152 files changed

+2204
-2192
lines changed

Some content is hidden

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

152 files changed

+2204
-2192
lines changed

.github/workflows/mmv1-check-templates.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/mmv1-lint-product-yaml.yml renamed to .github/workflows/unit-test-mmv1.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
1-
name: mmv1-lint-product-yaml
1+
name: mmv1
22

33
permissions: read-all
44

55
on:
66
pull_request:
77
paths:
8-
- 'mmv1/products/**'
8+
- 'mmv1/**'
99

1010
jobs:
11+
version-guard-check:
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2
16+
with:
17+
path: repo
18+
fetch-depth: 0
19+
- name: Merge base branch
20+
id: pull_request
21+
run: |
22+
cd repo
23+
git config user.name "modular-magician"
24+
git config user.email "magic-modules@google.com"
25+
git fetch origin ${{ github.base_ref }} # Fetch the base branch
26+
git merge --no-ff origin/${{ github.base_ref }} # Merge with the base branch
27+
- name: Check for invalid version guards
28+
run: |
29+
cd repo/tools/template-check
30+
git diff --name-only --diff-filter=d origin/${{ github.base_ref }} ../../*.tmpl | sed 's=^=../../=g' | go run main.go
1131
lint-yaml:
1232
runs-on: ubuntu-22.04
1333
steps:
@@ -34,3 +54,16 @@ jobs:
3454
- name: Lint YAML files
3555
if: ${{ !failure() && steps.pull_request.outputs.yamlfiles != '' }}
3656
run: yamllint -c repo/.yamllint ${{steps.pull_request.outputs.yamlfiles}}
57+
unit-tests:
58+
runs-on: ubuntu-22.04
59+
steps:
60+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2
61+
- name: Set up Go
62+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
63+
with:
64+
go-version: '^1.23'
65+
- name: Run mmv1 unit tests
66+
run: |
67+
cd mmv1
68+
go test ./... -v
69+

mmv1/provider/terraform.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ func (t Terraform) getCommonCopyFiles(versionName string, generateCode, generate
344344
"go.sum": "third_party/terraform/go.sum",
345345
"go.mod": "third_party/terraform/go.mod",
346346
".go-version": "third_party/terraform/.go-version",
347-
"terraform-registry-manifest.json": "third_party/terraform/terraform-registry-manifest.json.tmpl",
347+
"terraform-registry-manifest.json": "third_party/terraform/terraform-registry-manifest.json",
348348
}
349349
maps.Copy(commonCopyFiles, singleFiles)
350350

mmv1/provider/terraform_tgc_next.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ func (tgc TerraformGoogleConversionNext) CompileCommonFiles(outputFolder string,
7474
// common
7575
"pkg/transport/config.go": "third_party/terraform/transport/config.go.tmpl",
7676
"pkg/transport/provider_handwritten_endpoint.go": "third_party/terraform/transport/provider_handwritten_endpoint.go.tmpl",
77-
"pkg/tpgresource/common_diff_suppress.go": "third_party/terraform/tpgresource/common_diff_suppress.go.tmpl",
77+
"pkg/tpgresource/common_diff_suppress.go": "third_party/terraform/tpgresource/common_diff_suppress.go",
7878
"pkg/provider/provider.go": "third_party/terraform/provider/provider.go.tmpl",
79-
"pkg/provider/provider_validators.go": "third_party/terraform/provider/provider_validators.go.tmpl",
79+
"pkg/provider/provider_validators.go": "third_party/terraform/provider/provider_validators.go",
8080

8181
// tfplan2cai
8282
"pkg/tfplan2cai/converters/resource_converters.go": "templates/tgc_next/tfplan2cai/resource_converters.go.tmpl",

mmv1/third_party/terraform/provider/provider_validators.go.tmpl renamed to mmv1/third_party/terraform/provider/provider_validators.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ func ValidateServiceAccountEmail(v interface{}, k string) (warnings []string, er
8585
}
8686

8787
return
88-
}
88+
}

mmv1/third_party/terraform/services/backupdr/resource_backup_dr_backup_vault_test.go.tmpl renamed to mmv1/third_party/terraform/services/backupdr/resource_backup_dr_backup_vault_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ func TestAccBackupDRBackupVault_fullUpdate(t *testing.T) {
1818
referenceTime := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.UTC)
1919

2020
context := map[string]interface{}{
21-
"project": envvar.GetTestProjectFromEnv(),
21+
"project": envvar.GetTestProjectFromEnv(),
2222
"effective_time": referenceTime.Add(24 * time.Hour).Format(time.RFC3339),
23-
"random_suffix": acctest.RandString(t, 10),
23+
"random_suffix": acctest.RandString(t, 10),
2424
}
2525

2626
acctest.VcrTest(t, resource.TestCase{
@@ -97,4 +97,4 @@ resource "google_backup_dr_backup_vault" "backup-vault-test" {
9797
allow_missing = "true"
9898
}
9999
`, context)
100-
}
100+
}

mmv1/third_party/terraform/services/binaryauthorization/resource_binary_authorization_policy_test.go.tmpl renamed to mmv1/third_party/terraform/services/binaryauthorization/resource_binary_authorization_policy_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestAccBinaryAuthorizationPolicy_basic(t *testing.T) {
2121
pid := "tf-test-" + acctest.RandString(t, 10)
2222
billingId := envvar.GetTestBillingAccountFromEnv(t)
2323
acctest.VcrTest(t, resource.TestCase{
24-
PreCheck: func() { acctest.AccTestPreCheck(t) },
24+
PreCheck: func() { acctest.AccTestPreCheck(t) },
2525
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
2626
Steps: []resource.TestStep{
2727
{
@@ -165,9 +165,9 @@ func testAccCheckBinaryAuthorizationPolicyDefault(t *testing.T, pid string) reso
165165
config := acctest.GoogleProviderConfig(t)
166166
url := fmt.Sprintf("https://binaryauthorization.googleapis.com/v1/projects/%s/policy", pid)
167167
pol, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
168-
Config: config,
169-
Method: "GET",
170-
RawURL: url,
168+
Config: config,
169+
Method: "GET",
170+
RawURL: url,
171171
UserAgent: config.UserAgent,
172172
})
173173
if err != nil {

mmv1/third_party/terraform/services/chronicle/resource_chronicle_data_access_label_test.go.tmpl renamed to mmv1/third_party/terraform/services/chronicle/resource_chronicle_data_access_label_test.go

File renamed without changes.

mmv1/third_party/terraform/services/chronicle/resource_chronicle_data_access_scope_test.go.tmpl renamed to mmv1/third_party/terraform/services/chronicle/resource_chronicle_data_access_scope_test.go

File renamed without changes.

mmv1/third_party/terraform/services/chronicle/resource_chronicle_reference_list_test.go.tmpl renamed to mmv1/third_party/terraform/services/chronicle/resource_chronicle_reference_list_test.go

File renamed without changes.

0 commit comments

Comments
 (0)