Skip to content

Commit

Permalink
Merge pull request #148 from volcengine/feat/nas
Browse files Browse the repository at this point in the history
Feat/nas
  • Loading branch information
zpp12354321 authored Dec 7, 2023
2 parents 93ac5b7 + ead3720 commit e22f65e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion common/common_volcengine_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package common

const (
TerraformProviderName = "terraform-provider-volcengine"
TerraformProviderVersion = "0.0.128"
TerraformProviderVersion = "0.0.129"
)
2 changes: 1 addition & 1 deletion example/nasPermissionGroup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ resource "volcengine_nas_permission_group" "foo" {
permission_rules {
cidr_ip = "192.168.0.0"
rw_mode = "RO"
use_mode = "All_squash"
use_mode = "No_all_squash"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,21 @@ func ResourceVolcengineBandwidthPackage() *schema.Resource {
Description: "Route type, default to BGP.",
},
"billing_type": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "PostPaidByBandwidth",
Description: "BillingType of the Ipv6 bandwidth. Valid values: `PrePaid`, `PostPaidByBandwidth`(Default), `PostPaidByTraffic`, `PayBy95Peak`.",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "PostPaidByBandwidth",
Description: "BillingType of the bandwidth package. Valid values: `PrePaid`, `PostPaidByBandwidth`(Default), `PostPaidByTraffic`, `PayBy95Peak`." +
" The billing method of IPv6 does not include `PrePaid`, and the billing method is only based on the `PostPaidByBandwidth`.",
},
"bandwidth": {
Type: schema.TypeInt,
Required: true,
Description: "Bandwidth upper limit of shared bandwidth package, unit: Mbps. Valid values: 2 to 5000.",
Type: schema.TypeInt,
Required: true,
Description: "Bandwidth upper limit of shared bandwidth package, unit: Mbps. " +
"When BillingType is set to PrePaid: the value range is 5 to 5000. " +
"When BillingType is set to PostPaidByBandwidth: the value range is 2 to 5000. " +
"When BillingType is set to PostPaidByTraffic: the value range is 2 to 2000. " +
"When BillingType is set to PayBy95Peak: the value range is 2 to 5000.",
},
"protocol": {
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ func permissionRuleHash(v interface{}) int {
)
buf.WriteString(fmt.Sprintf("%v:", m["cidr_ip"]))
buf.WriteString(fmt.Sprintf("%v:", m["rw_mode"]))
buf.WriteString(fmt.Sprintf("%v:", m["user_mode"]))
buf.WriteString(fmt.Sprintf("%v:", m["use_mode"]))
return hashcode.String(buf.String())
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ func (v *VolcengineNasPermissionGroupService) RefreshResourceState(data *schema.

func (v *VolcengineNasPermissionGroupService) WithResourceResponseHandlers(m map[string]interface{}) []ve.ResourceResponseHandler {
handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) {
if rules, ok := m["PermissionRules"].([]interface{}); ok {
newRules := make([]interface{}, 0)
for _, rule := range rules {
ruleMap := rule.(map[string]interface{})
if mode, ok := ruleMap["UserMode"]; ok {
ruleMap["UseMode"] = mode
}
delete(ruleMap, "UserMode")
newRules = append(newRules, ruleMap)
}
m["PermissionRules"] = newRules
}
return m, map[string]ve.ResponseConvert{}, nil
}
return []ve.ResourceResponseHandler{handler}
Expand Down Expand Up @@ -158,7 +170,7 @@ func (v *VolcengineNasPermissionGroupService) CreateResource(resData *schema.Res
if ruleMap, ok := rule.(map[string]interface{}); ok {
ruleMapValue["CidrIp"] = ruleMap["cidr_ip"]
ruleMapValue["RwMode"] = ruleMap["rw_mode"]
ruleMapValue["UseMode"] = ruleMap["use_mode"]
ruleMapValue["UserMode"] = ruleMap["use_mode"]
}
rulesValue = append(rulesValue, ruleMapValue)
}
Expand Down Expand Up @@ -222,7 +234,7 @@ func (v *VolcengineNasPermissionGroupService) ModifyResource(resData *schema.Res
if ruleMap, ok := rule.(map[string]interface{}); ok {
ruleMapValue["CidrIp"] = ruleMap["cidr_ip"]
ruleMapValue["RwMode"] = ruleMap["rw_mode"]
ruleMapValue["UseMode"] = ruleMap["use_mode"]
ruleMapValue["UserMode"] = ruleMap["use_mode"]
}
rulesValue = append(rulesValue, ruleMapValue)
}
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/bandwidth_package.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ resource "volcengine_bandwidth_package" "foo" {
```
## Argument Reference
The following arguments are supported:
* `bandwidth` - (Required) Bandwidth upper limit of shared bandwidth package, unit: Mbps. Valid values: 2 to 5000.
* `bandwidth` - (Required) Bandwidth upper limit of shared bandwidth package, unit: Mbps. When BillingType is set to PrePaid: the value range is 5 to 5000. When BillingType is set to PostPaidByBandwidth: the value range is 2 to 5000. When BillingType is set to PostPaidByTraffic: the value range is 2 to 2000. When BillingType is set to PayBy95Peak: the value range is 2 to 5000.
* `bandwidth_package_name` - (Optional) The name of the bandwidth package.
* `billing_type` - (Optional, ForceNew) BillingType of the Ipv6 bandwidth. Valid values: `PrePaid`, `PostPaidByBandwidth`(Default), `PostPaidByTraffic`, `PayBy95Peak`.
* `billing_type` - (Optional, ForceNew) BillingType of the bandwidth package. Valid values: `PrePaid`, `PostPaidByBandwidth`(Default), `PostPaidByTraffic`, `PayBy95Peak`. The billing method of IPv6 does not include `PrePaid`, and the billing method is only based on the `PostPaidByBandwidth`.
* `description` - (Optional) The description of the bandwidth package.
* `isp` - (Optional, ForceNew) Route type, default to BGP.
* `period` - (Optional, ForceNew) Duration of purchasing shared bandwidth package on an annual or monthly basis. The valid value range in 1~9 or 12, 24 or 36. Default value is 1. The period unit defaults to `Month`.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/nas_permission_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "volcengine_nas_permission_group" "foo" {
permission_rules {
cidr_ip = "192.168.0.0"
rw_mode = "RO"
use_mode = "All_squash"
use_mode = "No_all_squash"
}
}
```
Expand Down

0 comments on commit e22f65e

Please sign in to comment.