Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Change type *string to string for & fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiamarchi committed Feb 16, 2015
1 parent ed2ed80 commit f1f9800
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ func TestFirewall(t *testing.T) {

listFirewalls(t)

description := "acceptance test updated"
updateFirewall(t, firewallID, &firewalls.UpdateOpts{
Description: &description,
Description: "acceptance test updated",
})

waitForFirewallToBeActive(t, firewallID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ func TestFirewallPolicy(t *testing.T) {

listPolicies(t)

description := "acceptance test updated"
updatePolicy(t, policyID, &policies.UpdateOpts{
Description: &description,
Description: "acceptance test updated",
})

getPolicy(t, policyID)
Expand Down
12 changes: 6 additions & 6 deletions openstack/networking/v2/extensions/fwaas/firewalls/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ func Get(c *gophercloud.ServiceClient, id string) GetResult {
// UpdateOpts contains the values used when updating a firewall.
type UpdateOpts struct {
// Name of the firewall.
Name *string
Description *string
Name string
Description string
AdminStateUp *bool
Shared *bool
PolicyID string
Expand All @@ -141,11 +141,11 @@ type UpdateOpts struct {
func (opts UpdateOpts) ToFirewallUpdateMap() (map[string]interface{}, error) {
f := make(map[string]interface{})

if opts.Name != nil {
f["name"] = *opts.Name
if opts.Name != "" {
f["name"] = opts.Name
}
if opts.Description != nil {
f["description"] = *opts.Description
if opts.Description != "" {
f["description"] = opts.Description
}
if opts.Shared != nil {
f["shared"] = *opts.Shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func TestUpdate(t *testing.T) {
{
"firewall":{
"name": "fw",
"description": "",
"description": "updated fw",
"admin_state_up":false,
"firewall_policy_id": "19ab8c87-4a32-4e6a-a74e-b77fffb89a0c"
}
Expand All @@ -220,12 +220,9 @@ func TestUpdate(t *testing.T) {
`)
})

name := "fw"
description := ""

options := UpdateOpts{
Name: &name,
Description: &description,
Name: "fw",
Description: "updated fw",
AdminStateUp: Down,
PolicyID: "19ab8c87-4a32-4e6a-a74e-b77fffb89a0c",
}
Expand Down
12 changes: 6 additions & 6 deletions openstack/networking/v2/extensions/fwaas/policies/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ func Get(c *gophercloud.ServiceClient, id string) GetResult {
// UpdateOpts contains the values used when updating a firewall policy.
type UpdateOpts struct {
// Name of the firewall policy.
Name *string
Description *string
Name string
Description string
Shared *bool
Audited *bool
Rules []string
Expand All @@ -130,11 +130,11 @@ type UpdateOpts struct {
func (opts UpdateOpts) ToPolicyUpdateMap() (map[string]interface{}, error) {
p := make(map[string]interface{})

if opts.Name != nil {
p["name"] = *opts.Name
if opts.Name != "" {
p["name"] = opts.Name
}
if opts.Description != nil {
p["description"] = *opts.Description
if opts.Description != "" {
p["description"] = opts.Description
}
if opts.Shared != nil {
p["shared"] = *opts.Shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,9 @@ func TestUpdate(t *testing.T) {
`)
})

name := "policy"
description := "Firewall policy"

options := UpdateOpts{
Name: &name,
Description: &description,
Name: "policy",
Description: "Firewall policy",
Rules: []string{
"98a58c87-76be-ae7c-a74e-b77fffb88d95",
"11a58c87-76be-ae7c-a74e-b77fffb88a32",
Expand Down
12 changes: 6 additions & 6 deletions openstack/networking/v2/extensions/fwaas/rules/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func Get(c *gophercloud.ServiceClient, id string) GetResult {
type UpdateOpts struct {
Protocol string
Action string
Name *string
Description *string
Name string
Description string
IPVersion int
SourceIPAddress *string
DestinationIPAddress *string
Expand All @@ -182,11 +182,11 @@ func (opts UpdateOpts) ToRuleUpdateMap() (map[string]interface{}, error) {
if opts.Action != "" {
r["action"] = opts.Action
}
if opts.Name != nil {
r["name"] = *opts.Name
if opts.Name != "" {
r["name"] = opts.Name
}
if opts.Description != nil {
r["description"] = *opts.Description
if opts.Description != "" {
r["description"] = opts.Description
}
if opts.IPVersion != 0 {
r["ip_version"] = opts.IPVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,16 @@ func TestUpdate(t *testing.T) {
`)
})

name := "ssh_form_any"
description := "ssh rule"
destinationIPAddress := "192.168.1.0/24"
destinationPort := "22"
empty := ""

options := UpdateOpts{
Protocol: "tcp",
Description: &description,
Description: "ssh rule",
DestinationIPAddress: &destinationIPAddress,
DestinationPort: &destinationPort,
Name: &name,
Name: "ssh_form_any",
SourceIPAddress: &empty,
SourcePort: &empty,
Action: "allow",
Expand Down

0 comments on commit f1f9800

Please sign in to comment.