Skip to content

Commit

Permalink
Allow empty string for name and description fields
Browse files Browse the repository at this point in the history
  • Loading branch information
lingxiankong committed Apr 9, 2018
1 parent 56a0b53 commit c509aa9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion acceptance/openstack/loadbalancer/v2/loadbalancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ func TestLoadbalancersCRUD(t *testing.T) {
}
defer DeleteL7Policy(t, lbClient, lb.ID, policy.ID)

newDescription := "New l7 policy description"
updateL7policyOpts := l7policies.UpdateOpts{
Description: "New l7 policy description",
Description: &newDescription,
}
_, err = l7policies.Update(lbClient, policy.ID, updateL7policyOpts).Extract()
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions openstack/loadbalancer/v2/l7policies/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,17 @@ type UpdateOptsBuilder interface {
// UpdateOpts is the common options struct used in this package's Update
// operation.
type UpdateOpts struct {
// Name of the L7 policy.
Name string `json:"name,omitempty"`
// Name of the L7 policy, empty string is allowed.
Name *string `json:"name,omitempty"`

// The L7 policy action. One of REDIRECT_TO_POOL, REDIRECT_TO_URL, or REJECT.
Action Action `json:"action,omitempty"`

// The position of this policy on the listener.
Position int32 `json:"position,omitempty"`

// A human-readable description for the resource.
Description string `json:"description,omitempty"`
// A human-readable description for the resource, empty string is allowed.
Description *string `json:"description,omitempty"`

// Requests matching this policy will be redirected to the pool with this ID.
// Only valid if action is REDIRECT_TO_POOL.
Expand Down
12 changes: 7 additions & 5 deletions openstack/loadbalancer/v2/l7policies/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ func TestUpdateL7Policy(t *testing.T) {
HandleL7PolicyUpdateSuccessfully(t)

client := fake.ServiceClient()
actual, err := l7policies.Update(client, "8a1412f0-4c32-4257-8b07-af4770b604fd", l7policies.UpdateOpts{
Name: "NewL7PolicyName",
Action: l7policies.ActionRedirectToURL,
RedirectURL: "http://www.new-example.com",
}).Extract()
newName := "NewL7PolicyName"
actual, err := l7policies.Update(client, "8a1412f0-4c32-4257-8b07-af4770b604fd",
l7policies.UpdateOpts{
Name: &newName,
Action: l7policies.ActionRedirectToURL,
RedirectURL: "http://www.new-example.com",
}).Extract()
if err != nil {
t.Fatalf("Unexpected Update error: %v", err)
}
Expand Down

0 comments on commit c509aa9

Please sign in to comment.