Skip to content

Commit

Permalink
Changes to VPN gateway connections
Browse files Browse the repository at this point in the history
  • Loading branch information
SunithaGudisagarIBM1 committed Jun 14, 2023
1 parent 5cec910 commit ff7b31b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 33 deletions.
12 changes: 4 additions & 8 deletions ibm/service/vpc/data_source_ibm_is_vpn_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,18 +423,14 @@ func dataSourceIBMIsVPNGatewayRead(context context.Context, d *schema.ResourceDa
if err = d.Set("health_state", vpnGateway.HealthState); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting health_state: %s", err))
}
if vpnGateway.HealthReasons != nil {
if err := d.Set("health_reasons", resourceVPNGatewayRouteFlattenHealthReasons(vpnGateway.HealthReasons)); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting health_reasons: %s", err))
}
if err := d.Set("health_reasons", resourceVPNGatewayRouteFlattenHealthReasons(vpnGateway.HealthReasons)); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting health_reasons: %s", err))
}
if err = d.Set("lifecycle_state", vpnGateway.LifecycleState); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting lifecycle_state: %s", err))
}
if vpnGateway.LifecycleReasons != nil {
if err := d.Set("lifecycle_reasons", resourceVPNGatewayFlattenLifecycleReasons(vpnGateway.LifecycleReasons)); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting lifecycle_reasons: %s", err))
}
if err := d.Set("lifecycle_reasons", resourceVPNGatewayFlattenLifecycleReasons(vpnGateway.LifecycleReasons)); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting lifecycle_reasons: %s", err))
}
if vpnGateway.Subnet != nil {
err = d.Set("subnet", dataSourceVPNGatewayFlattenSubnet(*vpnGateway.Subnet))
Expand Down
6 changes: 2 additions & 4 deletions ibm/service/vpc/data_source_ibm_is_vpn_gateway_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,8 @@ func dataSourceIBMIsVPNGatewayConnectionRead(context context.Context, d *schema.
if err = d.Set("status", vpnGatewayConnection.Status); err != nil {
return diag.FromErr(fmt.Errorf("Error setting status: %s", err))
}
if vpnGatewayConnection.StatusReasons != nil {
if err := d.Set("status_reasons", resourceVPNGatewayConnectionFlattenLifecycleReasons(vpnGatewayConnection.StatusReasons)); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting status_reasons: %s", err))
}
if err := d.Set("status_reasons", resourceVPNGatewayConnectionFlattenLifecycleReasons(vpnGatewayConnection.StatusReasons)); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting status_reasons: %s", err))
}
if err = d.Set("routing_protocol", vpnGatewayConnection.RoutingProtocol); err != nil {
return diag.FromErr(fmt.Errorf("Error setting routing_protocol: %s", err))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ func dataSourceIBMVPNGatewayConnectionsRead(d *schema.ResourceData, meta interfa
gatewayconnection[isVPNGatewayConnectionPeerAddress] = *data.PeerAddress
gatewayconnection[isVPNGatewayConnectionResourcetype] = *data.ResourceType
gatewayconnection[isVPNGatewayConnectionStatus] = *data.Status
if data.StatusReasons != nil {
gatewayconnection["status_reasons"] = resourceVPNGatewayConnectionFlattenLifecycleReasons(data.StatusReasons)
}
gatewayconnection["status_reasons"] = resourceVPNGatewayConnectionFlattenLifecycleReasons(data.StatusReasons)
//if data.Tunnels != nil {
if len(data.Tunnels) > 0 {
vpcTunnelsList := make([]map[string]interface{}, 0)
Expand Down
8 changes: 2 additions & 6 deletions ibm/service/vpc/data_source_ibm_is_vpn_gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,9 @@ func dataSourceIBMVPNGatewaysRead(d *schema.ResourceData, meta interface{}) erro
gateway[isVPNGatewayResourceType] = *data.ResourceType
gateway[isVPNGatewayStatus] = *data.Status
gateway["health_state"] = *data.HealthState
if data.HealthReasons != nil {
gateway["health_reasons"] = resourceVPNGatewayRouteFlattenHealthReasons(data.HealthReasons)
}
gateway["health_reasons"] = resourceVPNGatewayRouteFlattenHealthReasons(data.HealthReasons)
gateway["lifecycle_state"] = *data.LifecycleState
if data.LifecycleReasons != nil {
gateway["lifecycle_reasons"] = resourceVPNGatewayFlattenLifecycleReasons(data.LifecycleReasons)
}
gateway["lifecycle_reasons"] = resourceVPNGatewayFlattenLifecycleReasons(data.LifecycleReasons)
gateway[isVPNGatewayMode] = *data.Mode
gateway[isVPNGatewayResourceGroup] = *data.ResourceGroup.ID
gateway[isVPNGatewaySubnet] = *data.Subnet.ID
Expand Down
12 changes: 4 additions & 8 deletions ibm/service/vpc/resource_ibm_is_vpn_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,18 +514,14 @@ func vpngwGet(d *schema.ResourceData, meta interface{}, id string) error {
if err = d.Set("health_state", vpnGateway.HealthState); err != nil {
return fmt.Errorf("[ERROR] Error setting health_state: %s", err)
}
if vpnGateway.HealthReasons != nil {
if err := d.Set("health_reasons", resourceVPNGatewayRouteFlattenHealthReasons(vpnGateway.HealthReasons)); err != nil {
return fmt.Errorf("[ERROR] Error setting health_reasons: %s", err)
}
if err := d.Set("health_reasons", resourceVPNGatewayRouteFlattenHealthReasons(vpnGateway.HealthReasons)); err != nil {
return fmt.Errorf("[ERROR] Error setting health_reasons: %s", err)
}
if err = d.Set("lifecycle_state", vpnGateway.LifecycleState); err != nil {
return fmt.Errorf("[ERROR] Error setting lifecycle_state: %s", err)
}
if vpnGateway.LifecycleReasons != nil {
if err := d.Set("lifecycle_reasons", resourceVPNGatewayFlattenLifecycleReasons(vpnGateway.LifecycleReasons)); err != nil {
return fmt.Errorf("[ERROR] Error setting lifecycle_reasons: %s", err)
}
if err := d.Set("lifecycle_reasons", resourceVPNGatewayFlattenLifecycleReasons(vpnGateway.LifecycleReasons)); err != nil {
return fmt.Errorf("[ERROR] Error setting lifecycle_reasons: %s", err)
}
members := []vpcv1.VPNGatewayMember{}
for _, member := range vpnGateway.Members {
Expand Down
6 changes: 2 additions & 4 deletions ibm/service/vpc/resource_ibm_is_vpn_gateway_connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,8 @@ func vpngwconGet(d *schema.ResourceData, meta interface{}, gID, gConnID string)
if vpnGatewayConnection.Status != nil {
d.Set(isVPNGatewayConnectionStatus, *vpnGatewayConnection.Status)
}
if vpnGatewayConnection.StatusReasons != nil {
if err := d.Set("status_reasons", resourceVPNGatewayConnectionFlattenLifecycleReasons(vpnGatewayConnection.StatusReasons)); err != nil {
return fmt.Errorf("[ERROR] Error setting status_reasons: %s", err)
}
if err := d.Set("status_reasons", resourceVPNGatewayConnectionFlattenLifecycleReasons(vpnGatewayConnection.StatusReasons)); err != nil {
return fmt.Errorf("[ERROR] Error setting status_reasons: %s", err)
}
if vpnGatewayConnection.ResourceType != nil {
d.Set(isVPNGatewayConnectionResourcetype, *vpnGatewayConnection.ResourceType)
Expand Down

0 comments on commit ff7b31b

Please sign in to comment.