Skip to content

Commit 5cc3a6b

Browse files
authored
Merge pull request #678 from ovh/dev/aamstutz/add-dedicated-nasha-access-desc
fix: Add acl_description to resource ovh_dedicated_nasha_partition_access
2 parents 0d591b4 + 69c1cd9 commit 5cc3a6b

4 files changed

+29
-14
lines changed

ovh/resource_dedicated_nasha_partition_access.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ func resourceDedicatedNASHAPartitionAccess() *schema.Resource {
4343
Optional: true,
4444
ForceNew: true,
4545
},
46+
"acl_description": {
47+
Type: schema.TypeString,
48+
Optional: true,
49+
ForceNew: true,
50+
Description: "A brief description of the ACL",
51+
},
4652
},
4753
}
4854
}
@@ -54,13 +60,14 @@ func resourceDedicatedNASHAPartitionAccessCreate(c context.Context, d *schema.Re
5460
ipsubnet, _ := d.Get("ip").(string)
5561

5662
access := &DedicatedNASHAPartitionAccess{
57-
IP: d.Get("ip").(string),
58-
Type: d.Get("type").(string),
63+
IP: d.Get("ip").(string),
64+
Type: d.Get("type").(string),
65+
AclDescription: d.Get("acl_description").(string),
5966
}
6067

6168
resp := &DedicatedNASHATask{}
6269

63-
endpoint := fmt.Sprintf("/dedicated/nasha/%s/partition/%s/access", serviceName, partitionName)
70+
endpoint := fmt.Sprintf("/dedicated/nasha/%s/partition/%s/access", url.PathEscape(serviceName), url.PathEscape(partitionName))
6471

6572
err := config.OVHClient.Post(endpoint, access, resp)
6673
if err != nil {
@@ -101,7 +108,7 @@ func resourceDedicatedNASHAPartitionAccessRead(c context.Context, d *schema.Reso
101108

102109
resp := &DedicatedNASHAPartitionAccess{}
103110

104-
endpoint := fmt.Sprintf("/dedicated/nasha/%s/partition/%s/access/%s", serviceName, partitionName, url.PathEscape(ipsubnet))
111+
endpoint := fmt.Sprintf("/dedicated/nasha/%s/partition/%s/access/%s", url.PathEscape(serviceName), url.PathEscape(partitionName), url.PathEscape(ipsubnet))
105112

106113
err := config.OVHClient.Get(endpoint, resp)
107114
if err != nil {
@@ -112,7 +119,9 @@ func resourceDedicatedNASHAPartitionAccessRead(c context.Context, d *schema.Reso
112119
}
113120
return diag.Errorf("Error calling %s:\n\t '%q'", endpoint, err)
114121
}
122+
115123
d.Set("type", resp.Type)
124+
d.Set("acl_description", resp.AclDescription)
116125

117126
return nil
118127
}
@@ -123,7 +132,7 @@ func resourceDedicatedNASHAPartitionAccessDelete(c context.Context, d *schema.Re
123132
partitionName := d.Get("partition_name").(string)
124133
ipsubnet, _ := d.Get("ip").(string)
125134

126-
endpoint := fmt.Sprintf("/dedicated/nasha/%s/partition/%s/access/%s", serviceName, partitionName, url.PathEscape(ipsubnet))
135+
endpoint := fmt.Sprintf("/dedicated/nasha/%s/partition/%s/access/%s", url.PathEscape(serviceName), url.PathEscape(partitionName), url.PathEscape(ipsubnet))
127136

128137
resp := &DedicatedNASHATask{}
129138

ovh/resource_dedicated_nasha_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func TestAccDedicatedNASHA(t *testing.T) {
4444
partition_name = "${ovh_dedicated_nasha_partition.testacc.name}"
4545
ip = "127.0.0.1/32"
4646
type = "readonly"
47+
acl_description = "ACL for acceptance tests"
4748
}
4849
`, serviceName, partitionName),
4950
Check: resource.ComposeTestCheckFunc(
@@ -61,6 +62,7 @@ func TestAccDedicatedNASHA(t *testing.T) {
6162
resource.TestCheckResourceAttr("ovh_dedicated_nasha_partition_access.testacc", "partition_name", partitionName),
6263
resource.TestCheckResourceAttr("ovh_dedicated_nasha_partition_access.testacc", "ip", "127.0.0.1/32"),
6364
resource.TestCheckResourceAttr("ovh_dedicated_nasha_partition_access.testacc", "type", "readonly"),
65+
resource.TestCheckResourceAttr("ovh_dedicated_nasha_partition_access.testacc", "acl_description", "ACL for acceptance tests"),
6466
),
6567
},
6668
},

ovh/types_dedicated_nasha.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ type DedicatedNASHAPartition struct {
3131
}
3232

3333
type DedicatedNASHAPartitionAccess struct {
34-
IP string `json:"ip"`
35-
Type string `json:"type,omitempty"` // readonly, readwrite
34+
IP string `json:"ip"`
35+
Type string `json:"type,omitempty"` // readonly, readwrite
36+
AclDescription string `json:"aclDescription,omitempty"`
3637
}
3738

3839
type DedicatedNASHAPartitionSnapshot struct {

website/docs/r/dedicated_nasha_partition_access.markdown

+10-7
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ Provides a resource for managing access rights to partitions on HA-NAS services
1010

1111
```hcl
1212
resource "ovh_dedicated_nasha_partition_access" "my-partition" {
13-
service_name = "zpool-12345"
14-
partition_name = "my-partition"
15-
ip = "123.123.123.123/32"
16-
type = "readwrite"
13+
service_name = "zpool-12345"
14+
partition_name = "my-partition"
15+
ip = "123.123.123.123/32"
16+
type = "readwrite"
17+
acl_description = "Description of the ACL"
1718
}
1819
```
1920

@@ -22,9 +23,10 @@ resource "ovh_dedicated_nasha_partition_access" "my-partition" {
2223
The following arguments are supported:
2324

2425
* `service_name` - (Required) The internal name of your HA-NAS (it has to be ordered via OVHcloud interface)
25-
* `partition_name` - (Required) name of the partition
26-
* `ip` - (Required) ip block in x.x.x.x/x format
27-
* `type` - (Required) one of "readwrite", "readonly"
26+
* `partition_name` - (Required) Name of the partition
27+
* `ip` - (Required) IP block in x.x.x.x/x format
28+
* `type` - (Required) One of "readwrite", "readonly"
29+
* `acl_description` - A brief description of the acl
2830

2931
## Attributes Reference
3032

@@ -34,6 +36,7 @@ The following attributes are exported:
3436
* `partition_name` - See Argument Reference above.
3537
* `ip` - See Argument Reference above.
3638
* `type` - See Argument Reference above.
39+
* `acl_description` - See Argument Reference above.
3740

3841
## Import
3942

0 commit comments

Comments
 (0)