Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(reserved ip) : bare metal server reserved ip multi nic changes, doc fix #3747

Merged
merged 1 commit into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions ibm/service/vpc/data_source_ibm_is_subnet_reserved_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package vpc

import (
"fmt"
"reflect"

"github.com/IBM/vpc-go-sdk/vpcv1"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -132,9 +133,33 @@ func dataSdataSourceIBMISReservedIPRead(d *schema.ResourceData, meta interface{}
}
d.Set(isReservedIPType, *reserveIP.ResourceType)
if reserveIP.Target != nil {
target, ok := reserveIP.Target.(*vpcv1.ReservedIPTarget)
if ok {
d.Set(isReservedIPTarget, target.ID)
targetIntf := reserveIP.Target
switch reflect.TypeOf(targetIntf).String() {
case "*vpcv1.ReservedIPTargetEndpointGatewayReference":
{
target := targetIntf.(*vpcv1.ReservedIPTargetEndpointGatewayReference)
d.Set(isReservedIPTarget, target.ID)
}
case "*vpcv1.ReservedIPTargetNetworkInterfaceReferenceTargetContext":
{
target := targetIntf.(*vpcv1.ReservedIPTargetNetworkInterfaceReferenceTargetContext)
d.Set(isReservedIPTarget, target.ID)
}
case "*vpcv1.ReservedIPTargetLoadBalancerReference":
{
target := targetIntf.(*vpcv1.ReservedIPTargetLoadBalancerReference)
d.Set(isReservedIPTarget, target.ID)
}
case "*vpcv1.ReservedIPTargetVPNGatewayReference":
{
target := targetIntf.(*vpcv1.ReservedIPTargetVPNGatewayReference)
d.Set(isReservedIPTarget, target.ID)
}
case "*vpcv1.ReservedIPTarget":
{
target := targetIntf.(*vpcv1.ReservedIPTarget)
d.Set(isReservedIPTarget, target.ID)
}
}
}
return nil // By default there should be no error
Expand Down
33 changes: 30 additions & 3 deletions ibm/service/vpc/data_source_ibm_is_subnet_reserved_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package vpc

import (
"fmt"
"reflect"
"time"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
Expand Down Expand Up @@ -152,9 +153,35 @@ func dataSdataSourceIBMISReservedIPsRead(d *schema.ResourceData, meta interface{
ipsOutput[isReservedIPName] = *data.Name
ipsOutput[isReservedIPOwner] = *data.Owner
ipsOutput[isReservedIPType] = *data.ResourceType
target, ok := data.Target.(*vpcv1.ReservedIPTarget)
if ok {
ipsOutput[isReservedIPTarget] = target.ID
if data.Target != nil {
targetIntf := data.Target
switch reflect.TypeOf(targetIntf).String() {
case "*vpcv1.ReservedIPTargetEndpointGatewayReference":
{
target := targetIntf.(*vpcv1.ReservedIPTargetEndpointGatewayReference)
ipsOutput[isReservedIPTarget] = target.ID
}
case "*vpcv1.ReservedIPTargetNetworkInterfaceReferenceTargetContext":
{
target := targetIntf.(*vpcv1.ReservedIPTargetNetworkInterfaceReferenceTargetContext)
ipsOutput[isReservedIPTarget] = target.ID
}
case "*vpcv1.ReservedIPTargetLoadBalancerReference":
{
target := targetIntf.(*vpcv1.ReservedIPTargetLoadBalancerReference)
ipsOutput[isReservedIPTarget] = target.ID
}
case "*vpcv1.ReservedIPTargetVPNGatewayReference":
{
target := targetIntf.(*vpcv1.ReservedIPTargetVPNGatewayReference)
ipsOutput[isReservedIPTarget] = target.ID
}
case "*vpcv1.ReservedIPTarget":
{
target := targetIntf.(*vpcv1.ReservedIPTarget)
ipsOutput[isReservedIPTarget] = target.ID
}
}
}
reservedIPs = append(reservedIPs, ipsOutput)
}
Expand Down
Loading