Class: Jets::Cfn::Resource::ApiGateway::RestApi::Routes::Change::To

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/cfn/resource/api_gateway/rest_api/routes/change/to.rb

Instance Method Summary collapse

Methods inherited from Base

#attributes, #logical_id, #outputs, #parameters, #permission, #properties, #replacements, #replacer, #standarize, #template, truncate_id, #type

Methods included from Util::Camelize

#camelize

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jets/cfn/resource/api_gateway/rest_api/routes/change/to.rb', line 4

def changed?
  deployed_routes.each do |deployed_route|
    next if deployed_route.engine   # skip engine routes
    next if deployed_route.internal # skip internal routes

    new_route = find_comparable_route(deployed_route)
    next unless new_route

    if new_route.to != deployed_route.to
      # change in already deployed route has been detected, requires bluegreen deploy
      return true
    end
  end
  false # Reaching here means no routes have been changed in a way that requires a bluegreen deploy
end

#find_comparable_route(deployed_route) ⇒ Object

Find a route that has the same path and method. This is a comparable route Then we will compare the to or controller action to see if an already deployed route has been changed.



23
24
25
26
27
28
# File 'lib/jets/cfn/resource/api_gateway/rest_api/routes/change/to.rb', line 23

def find_comparable_route(deployed_route)
  new_routes.find do |new_route|
    new_route.path == deployed_route.path &&
    new_route.http_method == deployed_route.http_method
  end
end