Skip to content

Commit a0ffcbb

Browse files
authored
rewrite - fix template-converter and minor refresh (#11725)
1 parent c7aa539 commit a0ffcbb

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

mmv1/template-converter.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func convertTemplate(folder, tempFileTargets string) int {
6161
if checkExceptionList(filePath) {
6262
continue
6363
}
64-
if len(tempSlice) > 0 {
64+
if len(tempSlice) > 1 {
6565
// log.Printf("%s", filePath)
6666
if !slices.Contains(tempSlice, filePath) {
6767
continue
@@ -77,7 +77,7 @@ func convertTemplate(folder, tempFileTargets string) int {
7777

7878
goTemplate := strings.Replace(file, "erb", "tmpl", 1)
7979
outPath := path.Join(goDir, goTemplate)
80-
if len(tempSlice) > 0 {
80+
if len(tempSlice) > 1 {
8181
outPath = outPath + ".temp"
8282
}
8383
err = ioutil.WriteFile(outPath, data, 0644)
@@ -148,7 +148,7 @@ func convertHandwrittenFiles(folder, handwrittenTempFiles string) int {
148148
if checkExceptionList(filePath) {
149149
continue
150150
}
151-
if len(tempSlice) > 0 {
151+
if len(tempSlice) > 1 {
152152
if !slices.Contains(tempSlice, filePath) {
153153
continue
154154
}
@@ -166,7 +166,7 @@ func convertHandwrittenFiles(folder, handwrittenTempFiles string) int {
166166
goTemplate = strings.Replace(file, ".erb", "", 1)
167167
}
168168
outPath := path.Join(goDir, goTemplate)
169-
if len(tempSlice) > 0 {
169+
if len(tempSlice) > 1 {
170170
outPath = outPath + ".temp"
171171
}
172172
err = ioutil.WriteFile(outPath, data, 0644)

mmv1/third_party/terraform/provider/go/provider_mmv1_resources.go.tmpl

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ var handwrittenDatasources = map[string]*schema.Resource{
179179
"google_runtimeconfig_config": runtimeconfig.DataSourceGoogleRuntimeconfigConfig(),
180180
"google_runtimeconfig_variable": runtimeconfig.DataSourceGoogleRuntimeconfigVariable(),
181181
{{- end }}
182+
"google_secret_manager_regional_secret": secretmanagerregional.DataSourceSecretManagerRegionalRegionalSecret(),
182183
"google_secret_manager_secret": secretmanager.DataSourceSecretManagerSecret(),
183184
"google_secret_manager_secrets": secretmanager.DataSourceSecretManagerSecrets(),
184185
"google_secret_manager_secret_version": secretmanager.DataSourceSecretManagerSecretVersion(),

mmv1/third_party/terraform/services/compute/go/resource_compute_instance_test.go.tmpl

+4-12
Original file line numberDiff line numberDiff line change
@@ -3360,11 +3360,11 @@ func TestAccComputeInstance_proactiveAttributionLabel(t *testing.T) {
33603360
}
33613361

33623362
{{ if ne $.TargetVersionName `ga` -}}
3363+
const errorDeleteAccessConfigWithSecPolicy = "Cannot delete an access config with a security policy set. Please remove the security policy first"
3364+
33633365
// The tests related to security_policy use network_edge_security_service resource
33643366
// which can only exist one per region. Because of that, all the following tests must run serially.
33653367
func TestAccComputeInstanceNetworkIntefaceWithSecurityPolicy(t *testing.T) {
3366-
// Consistently failing - https://github.com/hashicorp/terraform-provider-google/issues/17838
3367-
acctest.SkipIfVcr(t)
33683368
testCases := map[string]func(t *testing.T){
33693369
"two_access_config": testAccComputeInstance_nic_securityPolicyCreateWithTwoAccessConfigs,
33703370
"two_nics_access_config_with_empty_nil_security_policy": testAccComputeInstance_nic_securityPolicyCreateWithEmptyAndNullSecurityPolicies,
@@ -3547,11 +3547,7 @@ func testAccComputeInstance_nic_securityPolicyCreateWithTwoNicsAndTwoAccessConfi
35473547
},
35483548
{
35493549
Config: testAccComputeInstance_nic_securityPolicyCreateWithTwoNicsAndTwoAccessConfigsUpdateTwoPoliciesRemoveAccessConfig(suffix, policyName, policyName2, instanceName, "google_compute_region_security_policy.policyforinstance.self_link", "google_compute_region_security_policy.policyforinstance.self_link"),
3550-
Check: resource.ComposeTestCheckFunc(
3551-
testAccCheckComputeInstanceExists(
3552-
t, "google_compute_instance.foobar", &instance),
3553-
testAccCheckComputeInstanceNicAccessConfigHasSecurityPolicy(&instance, policyName),
3554-
),
3550+
ExpectError: regexp.MustCompile(errorDeleteAccessConfigWithSecPolicy),
35553551
},
35563552
{
35573553
ResourceName: "google_compute_instance.foobar",
@@ -3657,11 +3653,7 @@ func testAccComputeInstance_nic_securityPolicyCreateWithAccessConfigUpdateAccess
36573653
},
36583654
{
36593655
Config: testAccComputeInstance_nic_securityPolicyCreateWithTwoAccessConfigsUpdateAccessConfig(suffix, policyName, instanceName),
3660-
Check: resource.ComposeTestCheckFunc(
3661-
testAccCheckComputeInstanceExists(
3662-
t, "google_compute_instance.foobar", &instance),
3663-
testAccCheckComputeInstanceNicAccessConfigHasSecurityPolicy(&instance, policyName),
3664-
),
3656+
ExpectError: regexp.MustCompile(errorDeleteAccessConfigWithSecPolicy),
36653657
},
36663658
{
36673659
ResourceName: "google_compute_instance.foobar",

0 commit comments

Comments
 (0)