Skip to content

Commit 066735d

Browse files
committed
let's try it
1 parent 33ee4c0 commit 066735d

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

mmv1/api/resource.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,13 @@ func (r Resource) FirstTestConfig() TestConfig {
17221722
return TestConfig{}
17231723
}
17241724

1725+
func (r Resource) NeedsEnvVar() bool {
1726+
if r.ProductMetadata != nil && r.ProductMetadata.Name == "BiglakeIceberg" && (r.Name == "IcebergNamespace" || r.Name == "IcebergCatalog") {
1727+
return false
1728+
}
1729+
return true
1730+
}
1731+
17251732
func (r Resource) ExamplePrimaryResourceId() string {
17261733
examples := google.Reject(r.Examples, func(e *resource.Examples) bool {
17271734
return e.ExcludeTest

mmv1/templates/terraform/examples/base_configs/test_file.go.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ import (
2929
"github.com/hashicorp/terraform-plugin-testing/terraform"
3030

3131
"{{ $.ImportPath }}/acctest"
32+
{{- if $.Res.NeedsEnvVar }}
3233
"{{ $.ImportPath }}/envvar"
34+
{{- end }}
3335
"{{ $.ImportPath }}/tpgresource"
3436
transport_tpg "{{ $.ImportPath }}/transport"
3537

@@ -44,7 +46,9 @@ var (
4446
_ = time.Now
4547
_ = resource.TestMain
4648
_ = terraform.NewState
49+
{{- if $.Res.NeedsEnvVar }}
4750
_ = envvar.TestEnvVar
51+
{{- end }}
4852
_ = tpgresource.SetLabels
4953
_ = transport_tpg.Config{}
5054
_ = googleapi.Error{}

mmv1/templates/terraform/samples/base_configs/test_file.go.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ import (
3333
{{- end }}
3434

3535
"{{ $.ImportPath }}/acctest"
36+
{{- if $.Res.NeedsEnvVar }}
3637
"{{ $.ImportPath }}/envvar"
38+
{{- end }}
3739
"{{ $.ImportPath }}/tpgresource"
3840
transport_tpg "{{ $.ImportPath }}/transport"
3941
)

mmv1/third_party/terraform/acctest/resource_inventory_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,13 @@ func TestValidateResourceMetadata(t *testing.T) {
267267
if r.ApiServiceName == "" {
268268
t.Errorf("%s: `api_service_name` is required and not set", r.Resource)
269269
}
270-
// Allowlist google_biglake_iceberg_catalog as a pre-existing case. I believe
270+
ignoredResources := []string{"google_biglake_iceberg_catalog", "google_biglake_iceberg_namespace"}
271+
// Allowlist google_biglake_iceberg_catalog and google_biglake_iceberg_namespace as a pre-existing case. I believe
271272
// that's a mistake which should be corrected at some point in the future.
272-
if r.ApiVersion == "" && resourceName != "google_biglake_iceberg_catalog" {
273+
if r.ApiVersion == "" && !slices.Contains(ignoredResources, resourceName) {
273274
t.Errorf("%s: `api_version` is required and not set", r.Resource)
274275
}
275276

276-
// Allowlist google_biglake_iceberg_namespace as a pre-existing case. I believe
277-
// that's a mistake which should be corrected at some point in the future.
278-
if r.ApiVersion == "" && resourceName != "google_biglake_iceberg_namespace" {
279-
t.Errorf("%s: `api_version` is required and not set", r.Resource)
280-
}
281277
if r.ApiResourceTypeKind == "" {
282278
t.Errorf("%s: `api_resource_type_kind` is required and not set", r.Resource)
283279
}

0 commit comments

Comments
 (0)