Skip to content

Commit

Permalink
resource meraki_networks_appliance_traffic_shaping_uplink_selection e…
Browse files Browse the repository at this point in the history
…rror - on updates when state file has entry #92
  • Loading branch information
fmunozmiranda committed Jul 10, 2024
1 parent 9be383e commit 1f15178
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
terraform {
required_providers {
meraki = {
source = "hashicorp.com/edu/meraki"
version = "0.2.5-alpha"
}
}

required_version = ">= 1.2.0"
}

provider "meraki" {
meraki_debug = "true"
}


resource "meraki_networks_appliance_traffic_shaping_custom_performance_classes" "example" {

network_id = "L_828099381482775486"
parameters = {

max_jitter = 100
max_latency = 100
max_loss_percentage = 5
name = "myCustomPerformanceClass"
}
}

output "meraki_networks_appliance_traffic_shaping_custom_performance_classes_example" {
value = meraki_networks_appliance_traffic_shaping_custom_performance_classes.example
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import meraki_networks_appliance_traffic_shaping_uplink_selection.example "network_id"
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
terraform {
required_providers {
meraki = {
source = "hashicorp.com/edu/meraki"
version = "0.2.5-alpha"
}
}

required_version = ">= 1.2.0"
}

provider meraki {
meraki_debug = "true"
}


# data "meraki_networks" "my_networks" {
# provider = meraki
# organization_id = "828099381482762270"

# }

resource "meraki_networks_appliance_traffic_shaping_uplink_selection" "this" {
network_id = "L_828099381482775486"
default_uplink = "wan1"
active_active_auto_vpn_enabled = true
load_balancing_enabled = true
failover_and_failback = {
immediate = {
enabled = false
}
}
}


output "meraki_networks_appliance_traffic_shaping_uplink_selection_example" {
value = meraki_networks_appliance_traffic_shaping_uplink_selection.this
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provider
// RESOURCE NORMAL
import (
"context"
"log"

merakigosdk "github.com/meraki/dashboard-api-go/v3/sdk"

Expand Down Expand Up @@ -921,6 +922,7 @@ func (r *NetworksApplianceTrafficShapingUplinkSelectionRs) toSdkApiRequestUpdate
})
}
}
log.Print("Hola revisar aqui %t", requestApplianceUpdateNetworkApplianceTrafficShapingUplinkSelectionVpnTrafficUplinkPreferencesPerformanceClass == nil)

Check failure on line 925 in internal/provider/resource_meraki_networks_appliance_traffic_shaping_uplink_selection.go

View workflow job for this annotation

GitHub Actions / Matrix Test (0.13.4)

log.Print call has possible Printf formatting directive %t

Check failure on line 925 in internal/provider/resource_meraki_networks_appliance_traffic_shaping_uplink_selection.go

View workflow job for this annotation

GitHub Actions / Matrix Test (0.14.5)

log.Print call has possible Printf formatting directive %t
requestApplianceUpdateNetworkApplianceTrafficShapingUplinkSelectionVpnTrafficUplinkPreferences = append(requestApplianceUpdateNetworkApplianceTrafficShapingUplinkSelectionVpnTrafficUplinkPreferences, merakigosdk.RequestApplianceUpdateNetworkApplianceTrafficShapingUplinkSelectionVpnTrafficUplinkPreferences{
FailOverCriterion: failOverCriterion,
PerformanceClass: requestApplianceUpdateNetworkApplianceTrafficShapingUplinkSelectionVpnTrafficUplinkPreferencesPerformanceClass,
Expand Down Expand Up @@ -1028,6 +1030,9 @@ func ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionItemToBody
if response.ActiveActiveAutoVpnEnabled != nil {
return types.BoolValue(*response.ActiveActiveAutoVpnEnabled)
}
if !state.ActiveActiveAutoVpnEnabled.IsNull() {
return state.ActiveActiveAutoVpnEnabled
}
return types.Bool{}
}(),
DefaultUplink: types.StringValue(response.DefaultUplink),
Expand All @@ -1045,11 +1050,11 @@ func ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionItemToBody
}(),
}
}
return &ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionFailoverAndFailbackImmediateRs{}
return nil
}(),
}
}
return &ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionFailoverAndFailbackRs{}
return nil
}(),
LoadBalancingEnabled: func() types.Bool {
if response.LoadBalancingEnabled != nil {
Expand All @@ -1071,7 +1076,7 @@ func ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionItemToBody
Type: types.StringValue(vpnTrafficUplinkPreferences.PerformanceClass.Type),
}
}
return &ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionVpnTrafficUplinkPreferencesPerformanceClassRs{}
return nil
}(),
PreferredUplink: types.StringValue(vpnTrafficUplinkPreferences.PreferredUplink),
TrafficFilters: func() *[]ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionVpnTrafficUplinkPreferencesTrafficFiltersRs {
Expand Down Expand Up @@ -1104,7 +1109,7 @@ func ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionItemToBody
}(),
}
}
return &ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionVpnTrafficUplinkPreferencesTrafficFiltersValueDestinationRs{}
return nil
}(),
ID: types.StringValue(trafficFilters.Value.ID),
Protocol: types.StringValue(trafficFilters.Value.Protocol),
Expand All @@ -1128,11 +1133,11 @@ func ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionItemToBody
}(),
}
}
return &ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionVpnTrafficUplinkPreferencesTrafficFiltersValueSourceRs{}
return nil
}(),
}
}
return &ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionVpnTrafficUplinkPreferencesTrafficFiltersValueRs{}
return nil
}(),
}
}
Expand Down Expand Up @@ -1168,7 +1173,7 @@ func ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionItemToBody
Port: types.StringValue(trafficFilters.Value.Destination.Port),
}
}
return &ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionWanTrafficUplinkPreferencesTrafficFiltersValueDestinationRs{}
return nil
}(),
Protocol: types.StringValue(trafficFilters.Value.Protocol),
Source: func() *ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionWanTrafficUplinkPreferencesTrafficFiltersValueSourceRs {
Expand All @@ -1190,11 +1195,11 @@ func ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionItemToBody
}(),
}
}
return &ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionWanTrafficUplinkPreferencesTrafficFiltersValueSourceRs{}
return nil
}(),
}
}
return &ResponseApplianceGetNetworkApplianceTrafficShapingUplinkSelectionWanTrafficUplinkPreferencesTrafficFiltersValueRs{}
return nil
}(),
}
}
Expand Down
25 changes: 22 additions & 3 deletions internal/provider/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,19 +843,38 @@ func changeStructUnknowns(a interface{}, b interface{}) interface{} {
log.Printf("Entre 3 %v to field %v\n", fieldValueB.Interface(), fieldName)
if !fieldValueA.IsZero() || !fieldValueB.IsZero() {
nestedResult := changeStructUnknowns(fieldValueA.Interface(), fieldValueB.Interface())
fieldValueBPtr := reflect.New(fieldValueB.Type())
fieldValueBPtr.Elem().Set(reflect.ValueOf(nestedResult))
resultStruct.Field(i).Set(fieldValueBPtr)

log.Printf("A pointer: %t", fieldValueA.Kind() != reflect.Ptr)
log.Printf("B pointer: %t", fieldValueB.Kind() != reflect.Ptr)
if fieldValueB.Kind() != reflect.Ptr {
log.Printf("Entre 3 %v to field %v\n", fieldValueB.Interface(), fieldName)
fieldValueBPtr := reflect.New(fieldValueB.Type())
fieldValueBPtr.Elem().Set(reflect.ValueOf(nestedResult))
resultStruct.Field(i).Set(fieldValueBPtr)
} else {
if fieldValueA.Kind() != reflect.Ptr {
log.Printf("Entre 3 %v to field %v\n", fieldValueB.Interface(), fieldName)
fieldValueAPtr := reflect.New(fieldValueA.Type())
fieldValueAPtr.Elem().Set(reflect.ValueOf(nestedResult))
resultStruct.Field(i).Set(fieldValueAPtr)
}
}
} else {
log.Printf("Both null")
}
} else {
log.Printf("2. Assigned %v to field %v\n", fieldValueA.Interface(), fieldName)

resultStruct.Field(i).Set(fieldValueA)
}
}
}
log.Printf("Sali: ")
// if resultStruct.Kind() != reflect.Ptr {
// log.Print("Diferente de puntero: ", resultStruct.Kind())
// resultStruct = reflect.ValueOf(resultStruct)
// log.Print("Ahora puntero: ", resultStruct.Kind())
// }
return resultStruct.Interface()
}

Expand Down

0 comments on commit 1f15178

Please sign in to comment.