Class: Hako::Schedulers::EcsDefinitionComparator
- Inherits:
-
Object
- Object
- Hako::Schedulers::EcsDefinitionComparator
- Defined in:
- lib/hako/schedulers/ecs_definition_comparator.rb
Constant Summary collapse
- CONTAINER_KEYS =
%i[image cpu memory links docker_labels].freeze
- PORT_MAPPING_KEYS =
%i[container_port host_port protocol].freeze
- ENVIRONMENT_KEYS =
%i[name value].freeze
- MOUNT_POINT_KEYS =
%i[source_volume container_path read_only].freeze
Instance Method Summary collapse
- #different?(actual_container) ⇒ Boolean
-
#initialize(expected_container) ⇒ EcsDefinitionComparator
constructor
A new instance of EcsDefinitionComparator.
Constructor Details
#initialize(expected_container) ⇒ EcsDefinitionComparator
Returns a new instance of EcsDefinitionComparator.
5 6 7 |
# File 'lib/hako/schedulers/ecs_definition_comparator.rb', line 5 def initialize(expected_container) @expected_container = expected_container end |
Instance Method Details
#different?(actual_container) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hako/schedulers/ecs_definition_comparator.rb', line 14 def different?(actual_container) unless actual_container return true end if different_members?(@expected_container, actual_container, CONTAINER_KEYS) return true end if @expected_container[:port_mappings].size != actual_container.port_mappings.size return true end @expected_container[:port_mappings].zip(actual_container.port_mappings) do |e, a| if different_members?(e, a, PORT_MAPPING_KEYS) return true end end if @expected_container[:environment].size != actual_container.environment.size return true end @expected_container[:environment].zip(actual_container.environment) do |e, a| if different_members?(e, a, ENVIRONMENT_KEYS) return true end end if @expected_container[:mount_points].size != actual_container.mount_points.size return true end @expected_container[:mount_points].zip(actual_container.mount_points) do |e, a| if different_members?(e, a, MOUNT_POINT_KEYS) return true end end false end |