Sha256: 9c02639573e82a7aab3d581f10d9a38c64c5d73e7f317a5fbf97f535cb0ea61d
Contents?: true
Size: 1.48 KB
Versions: 16
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true module Hako module Schedulers class EcsDefinitionComparator def initialize(expected_container) @expected_container = expected_container end 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 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 false end private def different_members?(expected, actual, keys) keys.each do |key| if actual.public_send(key) != expected[key] return true end end false end end end end
Version data entries
16 entries across 16 versions & 1 rubygems