Skip to content

Commit

Permalink
Use lineage instead of api_name for property conflicts (#3885)
Browse files Browse the repository at this point in the history
  • Loading branch information
c2thorn authored Aug 19, 2020
1 parent fd9235d commit 0b984e8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions api/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ module Fields
attr_reader :min_version
attr_reader :exact_version

# A list of properties that conflict with this property.
# A list of properties that conflict with this property. Uses the "lineage"
# field to identify the property eg: parent.meta.label.foo
attr_reader :conflicts

# A list of properties that at least one of must be set.
Expand Down Expand Up @@ -203,8 +204,7 @@ def check_conflicts

return if @conflicts.empty?

names = @__resource.all_user_properties.map(&:api_name) +
@__resource.all_user_properties.map(&:name)
names = @__resource.all_user_properties.map(&:lineage)
@conflicts.each do |p|
raise "#{p} does not exist" unless names.include?(p)
end
Expand All @@ -214,8 +214,8 @@ def check_conflicts
def conflicting
return [] unless @__resource

(@__resource.all_user_properties.select { |p| @conflicts.include?(p.api_name) } +
@__resource.all_user_properties.select { |p| p.conflicts.include?(@api_name) }).uniq
(@__resource.all_user_properties.select { |p| @conflicts.include?(p.lineage) } +
@__resource.all_user_properties.select { |p| p.conflicts.include?(lineage) }).uniq
end

# Checks that all properties that needs at least one of their fields actually exist.
Expand Down
12 changes: 6 additions & 6 deletions products/appengine/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ objects:
description: |
Automatic scaling is based on request rate, response latencies, and other application metrics.
conflicts:
- basicScaling
- manualScaling
- basic_scaling
- manual_scaling
properties:
- !ruby/object:Api::Type::Integer
name: 'maxConcurrentRequests'
Expand Down Expand Up @@ -550,8 +550,8 @@ objects:
description: |
Basic scaling creates instances when your application receives requests. Each instance will be shut down when the application becomes idle. Basic scaling is ideal for work that is intermittent or driven by user activity.
conflicts:
- automaticScaling
- manualScaling
- automatic_scaling
- manual_scaling
properties:
- !ruby/object:Api::Type::String
name: 'idleTimeout'
Expand All @@ -569,8 +569,8 @@ objects:
description: |
A service with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time.
conflicts:
- automaticScaling
- basicScaling
- automatic_scaling
- basic_scaling
properties:
- !ruby/object:Api::Type::Integer
name: 'instances'
Expand Down
26 changes: 13 additions & 13 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3066,8 +3066,8 @@ objects:
must be expressed in CIDR format. Only IPv4 is supported.
item_type: Api::Type::String
conflicts:
- sourceRanges
- sourceTags
- source_ranges
- source_tags
- !ruby/object:Api::Type::Enum
name: 'direction'
description: |
Expand Down Expand Up @@ -3179,8 +3179,8 @@ objects:
item_type: Api::Type::String
max_size: 10
conflicts:
- sourceTags
- targetTags
- source_tags
- target_tags
- !ruby/object:Api::Type::Array
name: 'sourceTags'
description: |
Expand All @@ -3206,8 +3206,8 @@ objects:
item_type: Api::Type::String
max_size: 10
conflicts:
- sourceTags
- targetTags
- source_tags
- target_tags
- !ruby/object:Api::Type::Array
name: 'targetTags'
description: |
Expand Down Expand Up @@ -8060,7 +8060,7 @@ objects:
Node type to use for nodes group that are created from this template.
Only one of nodeTypeFlexibility and nodeType can be specified.
conflicts:
- nodeTypeFlexibility
- node_type_flexibility
- !ruby/object:Api::Type::NestedObject
name: 'nodeTypeFlexibility'
description: |
Expand All @@ -8069,7 +8069,7 @@ objects:
these properties. Only one of nodeTypeFlexibility and nodeType can
be specified.
conflicts:
- nodeType
- node_type
properties:
- !ruby/object:Api::Type::String
name: cpus
Expand Down Expand Up @@ -11779,7 +11779,7 @@ objects:
- !ruby/object:Api::Type::NestedObject
name: 'snapshotSchedulePolicy'
conflicts:
- 'groupPlacementPolicy'
- 'group_placement_policy'
description: |
Policy for creating snapshots of persistent disks.
properties:
Expand Down Expand Up @@ -11923,7 +11923,7 @@ objects:
- !ruby/object:Api::Type::NestedObject
name: 'groupPlacementPolicy'
conflicts:
- 'snapshotSchedulePolicy'
- 'snapshot_schedule_policy'
description: |
Policy for creating snapshots of persistent disks.
properties:
Expand Down Expand Up @@ -16204,7 +16204,7 @@ objects:
name: 'defaultRouteAction'
# TODO: (mbang) conflicts also won't work for array path matchers yet, uncomment here once supported.
# conflicts:
# - defaultUrlRedirect
# - path_matcher.path_matcher.default_url_redirect
description: |
defaultRouteAction takes effect when none of the pathRules or routeRules match. The load balancer performs
advanced routing actions like URL rewrites, header transformations, etc. prior to forwarding the request
Expand Down Expand Up @@ -16547,7 +16547,7 @@ objects:
- default_url_redirect
- default_route_action.0.weighted_backend_services
conflicts:
- defaultRouteAction
- default_route_action
description: |
When none of the specified hostRules match, the request is redirected to a URL specified
by defaultUrlRedirect. If defaultUrlRedirect is specified, defaultService or
Expand Down Expand Up @@ -16614,7 +16614,7 @@ objects:
- !ruby/object:Api::Type::NestedObject
name: 'defaultRouteAction'
conflicts:
- defaultUrlRedirect
- default_url_redirect
description: |
defaultRouteAction takes effect when none of the hostRules match. The load balancer performs advanced routing actions
like URL rewrites, header transformations, etc. prior to forwarding the request to the selected backend.
Expand Down
2 changes: 1 addition & 1 deletion products/mlengine/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ objects:
response to increases and decreases in traffic. Care should be taken
to ramp up traffic according to the model's ability to scale or you
will start seeing increases in latency and 429 response codes.
conflicts: ['manualScaling']
conflicts: ['manual_scaling']
properties:
- !ruby/object:Api::Type::Integer
name: 'minNodes'
Expand Down

0 comments on commit 0b984e8

Please sign in to comment.