Skip to content

Commit

Permalink
allow sending empty values for router fields
Browse files Browse the repository at this point in the history
  • Loading branch information
danawillow committed Oct 3, 2018
1 parent 1f8b860 commit 3fcb25e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2768,6 +2768,7 @@ objects:
name: description
description: |
An optional description of this resource.
send_empty_value: true
- !ruby/object:Api::Type::ResourceRef
name: network
resource: Network
Expand Down Expand Up @@ -2817,6 +2818,7 @@ objects:
This enum field has the one valid value: ALL_SUBNETS
item_type: Api::Type::String # TODO(#324): enum?
send_empty_value: true
- !ruby/object:Api::Type::Array
name: advertisedIpRanges
description: |
Expand All @@ -2825,17 +2827,20 @@ objects:
is CUSTOM and is advertised to all peers of the router. These IP
ranges will be advertised in addition to any specified groups.
Leave this field blank to advertise no custom IP ranges.
send_empty_value: true
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: range
description: |
The IP range to advertise. The value must be a
CIDR-formatted string.
send_empty_value: true
- !ruby/object:Api::Type::String
name: description
description: |
User-specified description for the IP range.
send_empty_value: true
- !ruby/object:Api::Resource
name: 'Snapshot'
kind: 'compute#snapshot'
Expand Down
5 changes: 5 additions & 0 deletions templates/terraform/expand_property_method.erb
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *
transformed<%= titlelize_property(prop) -%>, err := expand<%= prefix -%><%= titlelize_property(property) -%><%= titlelize_property(prop) -%>(original["<%= prop.name.underscore -%>"], d, config)
if err != nil {
return nil, err
<% unless prop.send_empty_value -%>
} else if val := reflect.ValueOf(transformed<%= titlelize_property(prop) -%>); val.IsValid() && !isEmptyValue(val) {
transformed["<%= prop.api_name -%>"] = transformed<%= titlelize_property(prop) -%>
<% else -%>
} else {
transformed["<%= prop.api_name -%>"] = transformed<%= titlelize_property(prop) -%>
<% end -%>
}

<% end -%>
Expand Down

0 comments on commit 3fcb25e

Please sign in to comment.