Skip to content

Commit

Permalink
Fix issue #1117 and #1102
Browse files Browse the repository at this point in the history
  • Loading branch information
VaishnaviGopal authored and hkantare committed Feb 25, 2020
1 parent a6d3b7c commit da002c8
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,6 @@ func (f *InstanceClient) Create(instancedef compute.PostInstancesBody) (*models.
return resp.Payload, nil
}

// CreateEasy ...
func (f *InstanceClient) CreateEasy(name string) (*models.Instance, error) {

var body = compute.PostInstancesBody{
Name: name,
}
return f.Create(body)
}

// Update ...
func (f *InstanceClient) Update(id, name, profileName string) (*models.Instance, error) {
var body = compute.PatchInstancesIDBody{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (f *PublicGatewayClient) Get(id string) (*models.PublicGateway, error) {
}

/// Create ...
func (f *PublicGatewayClient) Create(name, zoneName, vpcID, FloatingIPID, FloatingIPaddr string) (*models.PublicGateway, error) {
func (f *PublicGatewayClient) Create(name, zoneName, vpcID, FloatingIPID, FloatingIPaddr, resourcegroupID string) (*models.PublicGateway, error) {

var body = network.PostPublicGatewaysBody{
Name: name,
Expand Down Expand Up @@ -88,6 +88,14 @@ func (f *PublicGatewayClient) Create(name, zoneName, vpcID, FloatingIPID, Floati
}
body.FloatingIP = &floatingip
}

if resourcegroupID != "" {
var resourcegroup = network.PostPublicGatewaysParamsBodyResourceGroup{
ID: strfmt.UUID(resourcegroupID),
}
body.ResourceGroup = &resourcegroup
}

params := network.NewPostPublicGatewaysParamsWithTimeout(f.session.Timeout).WithBody(body)
params.Version = "2019-10-08"
params.Generation = f.session.Generation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,15 @@ func (f *SubnetClient) Create(name, zoneName, vpcID, networkaclID, publicgwID,
}

if publicgwID != "" {
publicgwUUID := strfmt.UUID(publicgwID)
var pubgw = network.PostSubnetsParamsBodyPublicGateway{
ID: publicgwUUID,
ID: strfmt.UUID(publicgwID),
}
body.PublicGateway = &pubgw
}

if resourcegroupID != "" {
resourcegroupuuid := strfmt.UUID(resourcegroupID)
var resourcegroup = network.PostSubnetsParamsBodyResourceGroup{
ID: resourcegroupuuid,
ID: strfmt.UUID(resourcegroupID),
}
body.ResourceGroup = &resourcegroup
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4863,7 +4863,7 @@ paths:
title: FloatingIPTemplateBasic
type: object
resource_group:
description: The resource group for this network ACL
description: The resource group for this public gateway
properties:
id: {description: The unique identifier for this resource group, example: 56969d60-43e9-465c-883c-b9f7363e78e8,
format: uuid, pattern: '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$',
Expand Down
6 changes: 6 additions & 0 deletions examples/ibm-is-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,9 @@ resource "ibm_is_network_acl" "isExampleACL" {
}
}
}

resource "ibm_is_public_gateway" "publicgateway1" {
name = "gateway1"
vpc = ibm_is_vpc.testacc_vpc.id
zone = var.zone1
}
6 changes: 2 additions & 4 deletions ibm/resource_ibm_is_networkacls.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func resourceIBMISNetworkACLUpdate(d *schema.ResourceData, meta interface{}) err
}
nwaclC := network.NewNetworkAclClient(sess)
nwaclid := d.Id()
rules := d.Get(isNetworkACLRules).([]interface{})
rules := d.Get(isNetworkACLRules).(*schema.Set).List()

if d.HasChange(isNetworkACLName) {
name := d.Get(isNetworkACLName).(string)
Expand Down Expand Up @@ -584,13 +584,11 @@ func createInlineRules(nwaclC *network.NetworkAclClient, nwaclid string, rules [
}
}

rule, err := nwaclC.AddRule(nwaclid, name, source, destination, direction, action, protocol,
_, err := nwaclC.AddRule(nwaclid, name, source, destination, direction, action, protocol,
int64(icmptype), int64(icmpcode), int64(minport), int64(maxport), int64(sourceminport), int64(sourcemaxport), before)
if err != nil {
return err
}

before = rule.ID.String()
}
return nil
}
Expand Down
19 changes: 18 additions & 1 deletion ibm/resource_ibm_is_public_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (
isPublicGatewayProvisioningDone = "available"
isPublicGatewayDeleting = "deleting"
isPublicGatewayDeleted = "done"

isPublicGatewayResourceGroup = "resource_group"
)

func resourceIBMISPublicGateway() *schema.Resource {
Expand Down Expand Up @@ -71,6 +73,13 @@ func resourceIBMISPublicGateway() *schema.Resource {
Computed: true,
},

isPublicGatewayResourceGroup: {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Computed: true,
},

isPublicGatewayVPC: {
Type: schema.TypeString,
ForceNew: true,
Expand Down Expand Up @@ -139,8 +148,13 @@ func resourceIBMISPublicGatewayCreate(d *schema.ResourceData, meta interface{})
}
}

var rg string
if grp, ok := d.GetOk(isPublicGatewayResourceGroup); ok {
rg = grp.(string)
}

publicgwC := network.NewPublicGatewayClient(sess)
publicgw, err := publicgwC.Create(name, zone, vpc, floatingipID, floatingipadd)
publicgw, err := publicgwC.Create(name, zone, vpc, floatingipID, floatingipadd, rg)
if err != nil {
return err
}
Expand Down Expand Up @@ -217,6 +231,9 @@ func resourceIBMISPublicGatewayRead(d *schema.ResourceData, meta interface{}) er
d.Set(isPublicGatewayStatus, publicgw.Status)
d.Set(isPublicGatewayZone, publicgw.Zone.Name)
d.Set(isPublicGatewayVPC, publicgw.Vpc.ID.String())
if publicgw.ResourceGroup != nil {
d.Set(isPublicGatewayResourceGroup, publicgw.ResourceGroup.ID)
}

controller, err := getBaseController(meta)
if err != nil {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion website/docs/r/is_network_acl.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ The following arguments are supported:

* `name` - (Required, string) The name of the network ACL.
* `vpc` - (Optional, Forces new resource, string) The VPC Id. This is a Required field and to be set only when the generation parameter is `2`
* `rules` - (Optional, array) The rules for a network ACL
* `rules` - (Optional, array) The rules for a network ACL. The order of rules priority depends on the order of rules specified in the template.
Nested `rules` blocks have the following structure:
* `name` - (Required, string) The user-defined name for this rule.
* `action` - (Required, string) Whether to allow or deny matching traffic.
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/is_public_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resource "ibm_is_vpc" "testacc_vpc" {
}
resource "ibm_is_public_gateway" "testacc_gateway" {
name = "test_gateway"
name = "test-gateway"
vpc = ibm_is_vpc.testacc_vpc.id
zone = "us-south-1"
Expand All @@ -45,6 +45,7 @@ The following arguments are supported:
* `name` - (Required, string) The name of the gateway.
* `vpc` - (Required, Forces new resource, string) The vpc id.
* `zone` - (Required, Forces new resource, string) The gateway zone name.
* `resource_group` - (Optional, Forces new resource, string) The resource group ID where the Public gateway is to be created.
* `floating_ip` - (Optional, string) A nested block describing the floating IP of this gateway.
Nested `floating_ip` blocks have the following structure:
* `id` - (Optional, string) ID of the floating ip bound to the public gateway.
Expand Down

0 comments on commit da002c8

Please sign in to comment.