Skip to content

Commit

Permalink
fix dynamic_vlan.default_vlan_ids convert from SDK to Terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
tmunzer committed Jan 2, 2025
1 parent 247a71b commit b2698be
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/guides/release_note_0.2.xx.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ description: |-

# Release Notes for v0.2.xx

## Release Notes for v0.2.16
**release date** : January 2nd, 2025

### Fix
* fix `mist_org_wlan.dynamic_vlan.default_vlan_ids` and `mist_site_wlan.dynamic_vlan.default_vlan_ids` issue when converting the value from the Go SDK to Terraform.


## Release Notes for v0.2.15
**release date** : December 27th, 2024

Expand Down
10 changes: 10 additions & 0 deletions internal/commons/api_response/vlan_id_with_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ func GatewayVlanAsString(vlanId models.GatewayPortVlanIdWithVariable) basetypes.
return types.StringNull()
}
}

func WlanDynamicVlanAsString(vlanId models.WlanDynamicVlanDefaultVlanId) basetypes.StringValue {
if v, ok := vlanId.AsString(); ok {
return types.StringValue(*v)
} else if v, ok := vlanId.AsNumber(); ok {
return types.StringValue(fmt.Sprint(*v))
} else {
return types.StringNull()
}
}
4 changes: 3 additions & 1 deletion internal/resource_org_wlan/sdk_to_terraform_dynamic_vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resource_org_wlan
import (
"context"

mist_api "github.com/Juniper/terraform-provider-mist/internal/commons/api_response"
mist_transform "github.com/Juniper/terraform-provider-mist/internal/commons/utils"
"github.com/tmunzer/mistapi-go/mistapi/models"

Expand All @@ -24,7 +25,8 @@ func dynamicVlanSdkToTerraform(ctx context.Context, diags *diag.Diagnostics, d *
var items []attr.Value
var items_type attr.Type = basetypes.StringType{}
for _, item := range d.DefaultVlanIds {
items = append(items, types.StringValue(item.String()))
vlan_id := mist_api.WlanDynamicVlanAsString(item)
items = append(items, vlan_id)
}
r, e := types.ListValue(items_type, items)
diags.Append(e...)
Expand Down
4 changes: 3 additions & 1 deletion internal/resource_site_wlan/sdk_to_terraform_dynamic_vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resource_site_wlan
import (
"context"

mist_api "github.com/Juniper/terraform-provider-mist/internal/commons/api_response"
mist_transform "github.com/Juniper/terraform-provider-mist/internal/commons/utils"
"github.com/tmunzer/mistapi-go/mistapi/models"

Expand All @@ -24,7 +25,8 @@ func dynamicVlanSdkToTerraform(ctx context.Context, diags *diag.Diagnostics, d *
var items []attr.Value
var items_type attr.Type = basetypes.StringType{}
for _, item := range d.DefaultVlanIds {
items = append(items, types.StringValue(item.String()))
vlan_id := mist_api.WlanDynamicVlanAsString(item)
items = append(items, vlan_id)
}
r, e := types.ListValue(items_type, items)
diags.Append(e...)
Expand Down
7 changes: 7 additions & 0 deletions templates/guides/release_note_0.2.xx.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ description: |-

# Release Notes for v0.2.xx

## Release Notes for v0.2.16
**release date** : January 2nd, 2025

### Fix
* fix `mist_org_wlan.dynamic_vlan.default_vlan_ids` and `mist_site_wlan.dynamic_vlan.default_vlan_ids` issue when converting the value from the Go SDK to Terraform.


## Release Notes for v0.2.15
**release date** : December 27th, 2024

Expand Down

0 comments on commit b2698be

Please sign in to comment.