Skip to content

Commit 1970087

Browse files
authored
refactor(share): File share mount target assign none by default for dp2 (#6482)
1 parent d765320 commit 1970087

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

ibm/service/vpc/resource_ibm_is_share.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,10 +1435,14 @@ func resourceIbmIsShareMapToShareMountTargetPrototype(d *schema.ResourceData, sh
14351435
shareTargetPrototype.TransitEncryption = &transitEncryption
14361436
} else {
14371437
shareProfile := d.Get("profile").(string)
1438-
if shareProfile == "dp2" {
1439-
shareTargetPrototype.TransitEncryption = &[]string{"none"}[0]
1440-
} else if shareProfile == "rfs" {
1438+
accessControlMode := ""
1439+
if accessControlModeIntf, ok := d.GetOk("access_control_mode"); ok {
1440+
accessControlMode = accessControlModeIntf.(string)
1441+
}
1442+
if accessControlMode == "security_group" && shareProfile == "rfs" {
14411443
shareTargetPrototype.TransitEncryption = &[]string{"stunnel"}[0]
1444+
} else {
1445+
shareTargetPrototype.TransitEncryption = &[]string{"none"}[0]
14421446
}
14431447
}
14441448

ibm/service/vpc/resource_ibm_is_share_mount_target.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,10 @@ func resourceIBMIsShareMountTargetCreate(context context.Context, d *schema.Reso
383383
return tfErr.GetDiag()
384384
}
385385
if share != nil && share.Profile != nil && share.Profile.Name != nil {
386-
if *share.Profile.Name == "dp2" {
387-
shareMountTargetPrototype.TransitEncryption = &[]string{"ipsec"}[0]
388-
} else if *share.Profile.Name == "rfs" {
386+
if share.AccessControlMode != nil && *share.AccessControlMode == "security_group" && *share.Profile.Name == "rfs" {
389387
shareMountTargetPrototype.TransitEncryption = &[]string{"stunnel"}[0]
388+
} else {
389+
shareMountTargetPrototype.TransitEncryption = &[]string{"none"}[0]
390390
}
391391
}
392392
}

ibm/service/vpc/resource_ibm_is_share_mount_target_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestAccIbmIsShareMountTargetVNISubnet(t *testing.T) {
9898
vpcname := fmt.Sprintf("tf-vpc-name-%d", acctest.RandIntRange(10, 100))
9999
targetName := fmt.Sprintf("tf-target-%d", acctest.RandIntRange(10, 100))
100100
targetNameUpdate := fmt.Sprintf("tf-target-%d", acctest.RandIntRange(10, 100))
101-
sname := fmt.Sprintf("tf-fs-name-%d", acctest.RandIntRange(10, 100))
101+
sname := fmt.Sprintf("tf-fs-mt-vni-name-%d", acctest.RandIntRange(10, 100))
102102
subnetName := fmt.Sprintf("tf-subnet-name-%d", acctest.RandIntRange(10, 100))
103103
vniName := fmt.Sprintf("tf-vni-name-%d", acctest.RandIntRange(10, 100))
104104
vniNameUpdated := fmt.Sprintf("tf-vni-name-updated-%d", acctest.RandIntRange(10, 100))
@@ -398,7 +398,6 @@ func testAccCheckIbmIsShareMountTargetConfigVNIProtocolStateFilteringMode(vpcNam
398398
primary_ip {
399399
name = "%s"
400400
address = "${replace(ibm_is_subnet.testacc_subnet.ipv4_cidr_block, "0/24", "14")}"
401-
auto_delete = %t
402401
}
403402
subnet = ibm_is_subnet.testacc_subnet.id
404403
protocol_state_filtering_mode = "auto"
@@ -407,9 +406,9 @@ func testAccCheckIbmIsShareMountTargetConfigVNIProtocolStateFilteringMode(vpcNam
407406
name = "%s"
408407
}
409408
data "ibm_is_virtual_network_interface" "is_virtual_network_interface" {
410-
virtual_network_interface = ibm_is_share_mount_target.is_share_target.virtual_network_interface.0.id
409+
virtual_network_interface = ibm_is_share_mount_target.is_share_target.virtual_network_interface[0].id
411410
}
412-
`, sname, acc.ShareProfileName, vpcName, subnetName, acc.ISCIDR, vniName, pIpName, false, targetName)
411+
`, sname, acc.ShareProfileName, vpcName, subnetName, acc.ISCIDR, vniName, pIpName, targetName)
413412
}
414413

415414
func testAccCheckIbmIsShareMountTargetConfigVNIProtocolStateFilteringModeUpdate(vpcName, sname, targetName, subnetName, vniName, pIpName string) string {
@@ -439,15 +438,17 @@ func testAccCheckIbmIsShareMountTargetConfigVNIProtocolStateFilteringModeUpdate(
439438
primary_ip {
440439
name = "%s"
441440
address = "${replace(ibm_is_subnet.testacc_subnet.ipv4_cidr_block, "0/24", "14")}"
442-
auto_delete = %t
443441
}
444442
subnet = ibm_is_subnet.testacc_subnet.id
445443
protocol_state_filtering_mode = "enabled"
446444
}
447445
448446
name = "%s"
449447
}
450-
`, sname, acc.ShareProfileName, vpcName, subnetName, acc.ISCIDR, vniName, pIpName, false, targetName)
448+
data "ibm_is_virtual_network_interface" "is_virtual_network_interface" {
449+
virtual_network_interface = ibm_is_share_mount_target.is_share_target.virtual_network_interface[0].id
450+
}
451+
`, sname, acc.ShareProfileName, vpcName, subnetName, acc.ISCIDR, vniName, pIpName, targetName)
451452
}
452453

453454
func testAccCheckIbmIsShareMountTargetConfigVNI(vpcName, sname, targetName, subnetName, vniName, pIpName string) string {
@@ -477,14 +478,13 @@ func testAccCheckIbmIsShareMountTargetConfigVNI(vpcName, sname, targetName, subn
477478
primary_ip {
478479
name = "%s"
479480
address = "${replace(ibm_is_subnet.testacc_subnet.ipv4_cidr_block, "0/24", "14")}"
480-
auto_delete = %t
481481
}
482482
subnet = ibm_is_subnet.testacc_subnet.id
483483
}
484484
485485
name = "%s"
486486
}
487-
`, sname, acc.ShareProfileName, vpcName, subnetName, acc.ISCIDR, vniName, pIpName, false, targetName)
487+
`, sname, acc.ShareProfileName, vpcName, subnetName, acc.ISCIDR, vniName, pIpName, targetName)
488488
}
489489

490490
func testAccCheckIbmIsShareTargetConfig(vpcName, sname, targetName string) string {

0 commit comments

Comments
 (0)