Skip to content

Commit a3a8f5e

Browse files
authored
Add missing nfsv4 value while updating export_policy (#15801)
1 parent f566350 commit a3a8f5e

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

mmv1/templates/terraform/pre_update/netapp_volume_update.go.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ if v, ok := d.GetOk("export_policy"); ok {
4646
if val, exists := ruleMapItemSet["allowed_clients"]; exists { newRuleMapItemSet["allowedClients"] = val }
4747
if val, exists := ruleMapItemSet["has_root_access"]; exists { newRuleMapItemSet["hasRootAccess"] = val }
4848
if val, exists := ruleMapItemSet["nfsv3"]; exists { newRuleMapItemSet["nfsv3"] = val }
49+
if val, exists := ruleMapItemSet["nfsv4"]; exists { newRuleMapItemSet["nfsv4"] = val }
4950
if val, exists := ruleMapItemSet["kerberos5_read_only"]; exists { newRuleMapItemSet["kerberos5ReadOnly"] = val }
5051
if val, exists := ruleMapItemSet["kerberos5_read_write"]; exists { newRuleMapItemSet["kerberos5ReadWrite"] = val }
5152
if val, exists := ruleMapItemSet["kerberos5i_read_only"]; exists { newRuleMapItemSet["kerberos5iReadOnly"] = val }

mmv1/third_party/terraform/services/netapp/resource_netapp_volume_test.go.tmpl

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,3 +1238,102 @@ func testAccNetappVolume_volumeExportPolicyWithSquashMode_switchMutipleExportRul
12381238
}
12391239
`, context)
12401240
}
1241+
1242+
func TestAccNetappVolume_NetappVolumeNfsv4Example_update(t *testing.T) {
1243+
context := map[string]interface{}{
1244+
"network_name": acctest.BootstrapSharedServiceNetworkingConnection(t, "gcnv-network-config-3", acctest.ServiceNetworkWithParentService("netapp.servicenetworking.goog")),
1245+
"random_suffix": acctest.RandString(t, 10),
1246+
}
1247+
1248+
acctest.VcrTest(t, resource.TestCase{
1249+
PreCheck: func() { acctest.AccTestPreCheck(t) },
1250+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
1251+
CheckDestroy: testAccCheckNetappVolumeDestroyProducer(t),
1252+
Steps: []resource.TestStep{
1253+
{
1254+
Config: testAccNetappVolume_volumeNfsv4BasicExample_basic(context),
1255+
},
1256+
{
1257+
ResourceName: "google_netapp_volume.test_volume",
1258+
ImportState: true,
1259+
ImportStateVerify: true,
1260+
ImportStateVerifyIgnore: []string{"restore_parameters", "location", "name", "deletion_policy", "labels", "terraform_labels"},
1261+
},
1262+
{
1263+
Config: testAccNetappVolume_volumeNfsv4BasicExample_update(context),
1264+
},
1265+
{
1266+
ResourceName: "google_netapp_volume.test_volume",
1267+
ImportState: true,
1268+
ImportStateVerify: true,
1269+
ImportStateVerifyIgnore: []string{"restore_parameters", "location", "name", "deletion_policy", "labels", "terraform_labels"},
1270+
},
1271+
},
1272+
})
1273+
}
1274+
1275+
func testAccNetappVolume_volumeNfsv4BasicExample_basic(context map[string]interface{}) string {
1276+
return acctest.Nprintf(`
1277+
resource "google_netapp_storage_pool" "default" {
1278+
name = "tf-test-test-pool%{random_suffix}"
1279+
location = "us-west4"
1280+
service_level = "PREMIUM"
1281+
capacity_gib = "2048"
1282+
network = data.google_compute_network.default.id
1283+
}
1284+
1285+
resource "google_netapp_volume" "test_volume" {
1286+
location = "us-west4"
1287+
name = "tf-test-test-volume%{random_suffix}"
1288+
capacity_gib = "100"
1289+
share_name = "tf-test-test-volume%{random_suffix}"
1290+
storage_pool = google_netapp_storage_pool.default.name
1291+
protocols = ["NFSV4"]
1292+
export_policy {
1293+
rules {
1294+
access_type = "READ_WRITE"
1295+
allowed_clients = "10.0.0.0/24"
1296+
has_root_access = true
1297+
nfsv4 = true
1298+
}
1299+
}
1300+
}
1301+
1302+
data "google_compute_network" "default" {
1303+
name = "%{network_name}"
1304+
}
1305+
`, context)
1306+
}
1307+
1308+
func testAccNetappVolume_volumeNfsv4BasicExample_update(context map[string]interface{}) string {
1309+
return acctest.Nprintf(`
1310+
resource "google_netapp_storage_pool" "default" {
1311+
name = "tf-test-test-pool%{random_suffix}"
1312+
location = "us-west4"
1313+
service_level = "PREMIUM"
1314+
capacity_gib = "2048"
1315+
network = data.google_compute_network.default.id
1316+
}
1317+
1318+
resource "google_netapp_volume" "test_volume" {
1319+
location = "us-west4"
1320+
name = "tf-test-test-volume%{random_suffix}"
1321+
capacity_gib = "100"
1322+
share_name = "tf-test-test-volume%{random_suffix}"
1323+
storage_pool = google_netapp_storage_pool.default.name
1324+
protocols = ["NFSV4"]
1325+
export_policy {
1326+
rules {
1327+
access_type = "READ_WRITE"
1328+
allowed_clients = "10.0.0.0/24"
1329+
has_root_access = false
1330+
nfsv4 = true
1331+
}
1332+
}
1333+
}
1334+
1335+
data "google_compute_network" "default" {
1336+
name = "%{network_name}"
1337+
}
1338+
`, context)
1339+
}

0 commit comments

Comments
 (0)