Skip to content

Commit 6947d93

Browse files
All squash support (#15115) (#10711)
[upstream:13543acf88bc044848337e62f8517b72be115c17] Signed-off-by: Modular Magician <[email protected]>
1 parent 9e813ee commit 6947d93

File tree

5 files changed

+420
-0
lines changed

5 files changed

+420
-0
lines changed

.changelog/15115.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
unknown: All squash support

google-beta/services/netapp/resource_netapp_volume.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ Format: 'projects/{{projectId}}/locations/{{location}}/backupVaults/{{backupVaul
154154
Optional: true,
155155
Description: `Defines the client ingress specification (allowed clients) as a comma separated list with IPv4 CIDRs or IPv4 host addresses.`,
156156
},
157+
"anon_uid": {
158+
Type: schema.TypeInt,
159+
Optional: true,
160+
Description: `An integer representing the anonymous user ID. Range is 0 to 4294967295. Required when 'squash_mode' is 'ROOT_SQUASH' or 'ALL_SQUASH'.`,
161+
},
157162
"has_root_access": {
158163
Type: schema.TypeString,
159164
Optional: true,
@@ -199,6 +204,12 @@ Format: 'projects/{{projectId}}/locations/{{location}}/backupVaults/{{backupVaul
199204
Optional: true,
200205
Description: `Enable to apply the export rule to NFSV4.1 clients.`,
201206
},
207+
"squash_mode": {
208+
Type: schema.TypeString,
209+
Optional: true,
210+
ValidateFunc: verify.ValidateEnum([]string{"NO_ROOT_SQUASH", "ROOT_SQUASH", "ALL_SQUASH", ""}),
211+
Description: `SquashMode defines how remote user privileges are restricted when accessing an NFS export. It controls how the user identities (like root) are mapped to anonymous users to limit access and enforce security. Possible values: ["NO_ROOT_SQUASH", "ROOT_SQUASH", "ALL_SQUASH"]`,
212+
},
202213
},
203214
},
204215
},
@@ -1399,6 +1410,8 @@ func flattenNetappVolumeExportPolicyRules(v interface{}, d *schema.ResourceData,
13991410
"kerberos5i_read_write": flattenNetappVolumeExportPolicyRulesKerberos5iReadWrite(original["kerberos5iReadWrite"], d, config),
14001411
"kerberos5p_read_only": flattenNetappVolumeExportPolicyRulesKerberos5pReadOnly(original["kerberos5pReadOnly"], d, config),
14011412
"kerberos5p_read_write": flattenNetappVolumeExportPolicyRulesKerberos5pReadWrite(original["kerberos5pReadWrite"], d, config),
1413+
"squash_mode": flattenNetappVolumeExportPolicyRulesSquashMode(original["squashMode"], d, config),
1414+
"anon_uid": flattenNetappVolumeExportPolicyRulesAnonUid(original["anonUid"], d, config),
14021415
})
14031416
}
14041417
return transformed
@@ -1447,6 +1460,27 @@ func flattenNetappVolumeExportPolicyRulesKerberos5pReadWrite(v interface{}, d *s
14471460
return v
14481461
}
14491462

1463+
func flattenNetappVolumeExportPolicyRulesSquashMode(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1464+
return v
1465+
}
1466+
1467+
func flattenNetappVolumeExportPolicyRulesAnonUid(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1468+
// Handles the string fixed64 format
1469+
if strVal, ok := v.(string); ok {
1470+
if intVal, err := tpgresource.StringToFixed64(strVal); err == nil {
1471+
return intVal
1472+
}
1473+
}
1474+
1475+
// number values are represented as float64
1476+
if floatVal, ok := v.(float64); ok {
1477+
intVal := int(floatVal)
1478+
return intVal
1479+
}
1480+
1481+
return v // let terraform core handle it otherwise
1482+
}
1483+
14501484
func flattenNetappVolumeProtocols(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
14511485
return v
14521486
}
@@ -2136,6 +2170,20 @@ func expandNetappVolumeExportPolicyRules(v interface{}, d tpgresource.TerraformR
21362170
transformed["kerberos5pReadWrite"] = transformedKerberos5pReadWrite
21372171
}
21382172

2173+
transformedSquashMode, err := expandNetappVolumeExportPolicyRulesSquashMode(original["squash_mode"], d, config)
2174+
if err != nil {
2175+
return nil, err
2176+
} else if val := reflect.ValueOf(transformedSquashMode); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2177+
transformed["squashMode"] = transformedSquashMode
2178+
}
2179+
2180+
transformedAnonUid, err := expandNetappVolumeExportPolicyRulesAnonUid(original["anon_uid"], d, config)
2181+
if err != nil {
2182+
return nil, err
2183+
} else if val := reflect.ValueOf(transformedAnonUid); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2184+
transformed["anonUid"] = transformedAnonUid
2185+
}
2186+
21392187
req = append(req, transformed)
21402188
}
21412189
return req, nil
@@ -2185,6 +2233,14 @@ func expandNetappVolumeExportPolicyRulesKerberos5pReadWrite(v interface{}, d tpg
21852233
return v, nil
21862234
}
21872235

2236+
func expandNetappVolumeExportPolicyRulesSquashMode(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2237+
return v, nil
2238+
}
2239+
2240+
func expandNetappVolumeExportPolicyRulesAnonUid(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2241+
return v, nil
2242+
}
2243+
21882244
func expandNetappVolumeProtocols(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
21892245
return v, nil
21902246
}

google-beta/services/netapp/resource_netapp_volume_generated_meta.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fields:
2020
- field: 'encryption_type'
2121
- field: 'export_policy.rules.access_type'
2222
- field: 'export_policy.rules.allowed_clients'
23+
- field: 'export_policy.rules.anon_uid'
2324
- field: 'export_policy.rules.has_root_access'
2425
- field: 'export_policy.rules.kerberos5_read_only'
2526
- field: 'export_policy.rules.kerberos5_read_write'
@@ -29,6 +30,7 @@ fields:
2930
- field: 'export_policy.rules.kerberos5p_read_write'
3031
- field: 'export_policy.rules.nfsv3'
3132
- field: 'export_policy.rules.nfsv4'
33+
- field: 'export_policy.rules.squash_mode'
3234
- field: 'has_replication'
3335
- field: 'hybrid_replication_parameters.cluster_location'
3436
- field: 'hybrid_replication_parameters.description'

0 commit comments

Comments
 (0)