Skip to content

Commit

Permalink
added "disabled" value for vlanid key in vnet (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
pogossian authored Dec 24, 2024
1 parent 4fba2e6 commit 831d3e4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HOSTNAME=registry.terraform.io
NAMESPACE=netrisai
NAME=netris
BINARY=terraform-provider-${NAME}
VERSION=3.6.0
VERSION=3.6.1
OS_ARCH=darwin_arm64
WORKDIRECTORY=examples

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/vnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ resource "netris_vnet" "my-vnet" {

- **state** (String) V-Net state. Allowed values: `active` or `disabled`. Default value is `active`
- **tags** (List of String) List of tags. Example `["foo", "bar"]`
- **vlanid** (String) VLAN tag for all network interfaces of the vnet. Also can be `auto`. If set `auto` the controller will assign a vlan ID automatically.
- **vlanid** (String) VLAN tag for all network interfaces of the vnet. Also can be `auto`, or `disabled`. If set `auto` the controller will assign a vlan ID automatically.
- **vpcid** (Number) ID of VPC. If not specified, the vnet will be created in the VPC marked as a default.
- **vxlanid** (Number) VXLAN ID. If not specified will be generated automatically.

Expand Down
3 changes: 2 additions & 1 deletion netris/vnet/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ func validateState(val interface{}, key string) (warns []string, errs []error) {

func validateVlanID(val interface{}, key string) (warns []string, errs []error) {
v := val.(string)
if v == "auto" {
if v == "auto" || v == "disabled" {
// No further checks are needed for "auto" or "disabled"
} else {
vlan, _ := strconv.Atoi(v)
if !(vlan >= 2 && vlan <= 4094) {
Expand Down
12 changes: 10 additions & 2 deletions netris/vnet/vnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,11 @@ func resourceCreate(d *schema.ResourceData, m interface{}) error {
if vnetTypeOne {
vlanidInterface = 0
} else {
vlanidInterface = vlanid
if vlanid == "disabled" {
vlanidInterface = 0
} else {
vlanidInterface = vlanid
}
}

vnetAdd := &vnet.VNetAdd{
Expand Down Expand Up @@ -851,7 +855,11 @@ func resourceUpdate(d *schema.ResourceData, m interface{}) error {
if vnetTypeOne {
vlanidInterface = 0
} else {
vlanidInterface = vlanid
if vlanid == "disabled" {
vlanidInterface = 0
} else {
vlanidInterface = vlanid
}
}

vnetUpdate := &vnet.VNetUpdate{
Expand Down

0 comments on commit 831d3e4

Please sign in to comment.