55require 'actions/services/route_binding_delete'
66
77module VCAP ::CloudController
8-
98 class Route < Sequel ::Model
109 class InvalidOrganizationRelation < CloudController ::Errors ::InvalidRelation ; end
1110
@@ -21,12 +20,12 @@ class OutOfVIPException < CloudController::Errors::InvalidRelation; end
2120
2221 # TODO: apps are actually processes
2322 many_to_many :apps , class : 'VCAP::CloudController::ProcessModel' ,
24- join_table : RouteMappingModel . table_name ,
25- left_primary_key : :guid , left_key : :route_guid ,
26- right_primary_key : %i[ app_guid type ] , right_key : %i[ app_guid process_type ] ,
27- distinct : true ,
28- order : Sequel . asc ( :id ) ,
29- conditions : { type : ProcessTypes ::WEB }
23+ join_table : RouteMappingModel . table_name ,
24+ left_primary_key : :guid , left_key : :route_guid ,
25+ right_primary_key : %i[ app_guid type ] , right_key : %i[ app_guid process_type ] ,
26+ distinct : true ,
27+ order : Sequel . asc ( :id ) ,
28+ conditions : { type : ProcessTypes ::WEB }
3029
3130 many_to_many :shared_spaces ,
3231 left_key : :route_guid ,
@@ -90,7 +89,6 @@ def options_with_serialization
9089 alias_method :options , :options_with_serialization
9190
9291 alias_method :old_path , :path
93-
9492 def path
9593 old_path . nil? ? '' : old_path
9694 end
@@ -179,8 +177,8 @@ def domains_match?
179177
180178 def validate_changed_space ( new_space )
181179 raise CloudController ::Errors ::InvalidAppRelation . new ( 'Route and apps not in same space' ) if !FeatureFlag . enabled? ( :route_sharing ) && apps . any? do |app |
182- app . space . id != space . id
183- end
180+ app . space . id != space . id
181+ end
184182 raise InvalidOrganizationRelation . new ( "Organization cannot use domain #{ domain . name } " ) if domain && !domain . usable_by_organization? ( new_space . organization )
185183 end
186184
@@ -238,8 +236,8 @@ def find_next_vip_offset
238236 # See SQL self-joins for the reasoning behind this
239237
240238 n = Route . exclude ( vip_offset : 1 ) .
241- exclude { vip_offset - 1 =~ Route . select ( :vip_offset ) } . order ( :vip_offset ) . get { vip_offset - 1 } ||
242- ( return ( Route . max ( :vip_offset ) || 0 ) + 1 )
239+ exclude { vip_offset - 1 =~ Route . select ( :vip_offset ) } . order ( :vip_offset ) . get { vip_offset - 1 } ||
240+ ( return ( Route . max ( :vip_offset ) || 0 ) + 1 )
243241 Route . where { vip_offset < n } . reverse ( :vip_offset ) . get { vip_offset + 1 } || 1
244242 end
245243
@@ -258,9 +256,9 @@ def internal_route_vip_range_len
258256
259257 def internal_route_vip_range
260258 @internal_route_vip_range ||= begin
261- internal_route_vip_range = Config . config . get ( :internal_route_vip_range )
262- NetAddr ::IPv4Net . parse ( internal_route_vip_range )
263- end
259+ internal_route_vip_range = Config . config . get ( :internal_route_vip_range )
260+ NetAddr ::IPv4Net . parse ( internal_route_vip_range )
261+ end
264262 end
265263
266264 def destroy_route_bindings
@@ -326,7 +324,7 @@ def validate_total_routes
326324 return unless new? && space
327325
328326 space_routes_policy = MaxRoutesPolicy . new ( space . space_quota_definition , SpaceRoutes . new ( space ) )
329- org_routes_policy = MaxRoutesPolicy . new ( space . organization . quota_definition , OrganizationRoutes . new ( space . organization ) )
327+ org_routes_policy = MaxRoutesPolicy . new ( space . organization . quota_definition , OrganizationRoutes . new ( space . organization ) )
330328
331329 errors . add ( :space , :total_routes_exceeded ) if space . space_quota_definition && !space_routes_policy . allow_more_routes? ( 1 )
332330
0 commit comments