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

provider/openstack: Add 'value_specs' option to 'openstack_fw_firewall_v1' resource #9836

Merged
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
20 changes: 14 additions & 6 deletions builtin/providers/openstack/resource_openstack_fw_firewall_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func resourceFWFirewallV1() *schema.Resource {
ForceNew: true,
Computed: true,
},
"value_specs": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
},
},
}
}
Expand All @@ -65,12 +70,15 @@ func resourceFWFirewallV1Create(d *schema.ResourceData, meta interface{}) error

adminStateUp := d.Get("admin_state_up").(bool)

firewallConfiguration := firewalls.CreateOpts{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
PolicyID: d.Get("policy_id").(string),
AdminStateUp: &adminStateUp,
TenantID: d.Get("tenant_id").(string),
firewallConfiguration := FirewallCreateOpts{
firewalls.CreateOpts{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
PolicyID: d.Get("policy_id").(string),
AdminStateUp: &adminStateUp,
TenantID: d.Get("tenant_id").(string),
},
MapValueSpecs(d),
}

log.Printf("[DEBUG] Create firewall: %#v", firewallConfiguration)
Expand Down
15 changes: 14 additions & 1 deletion builtin/providers/openstack/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package openstack

import (
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/policies"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/rules"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
Expand All @@ -11,7 +12,19 @@ import (
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
)

// FloatingIPCreateOpts represents the attributes used when creating a new port.
// FirewallCreateOpts represents the attributes used when creating a new firewall.
type FirewallCreateOpts struct {
firewalls.CreateOpts
ValueSpecs map[string]string `json:"value_specs,omitempty"`
}

// ToFirewallCreateMap casts a CreateOpts struct to a map.
// It overrides firewalls.ToFirewallCreateMap to add the ValueSpecs field.
func (opts FirewallCreateOpts) ToFirewallCreateMap() (map[string]interface{}, error) {
return BuildRequest(opts, "firewall")
}

// FloatingIPCreateOpts represents the attributes used when creating a new floating ip.
type FloatingIPCreateOpts struct {
floatingips.CreateOpts
ValueSpecs map[string]string `json:"value_specs,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ The following arguments are supported:
to create a firewall for another tenant. Changing this creates a new
firewall.

* `value_specs` - (Optional) Map of additional options.

## Attributes Reference

The following attributes are exported:
Expand Down