Sha256: 184bf24fbecf69a6942fc738a91e2527599230709fdad300bcd14f64543c4118

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'hako/schema'

module Hako
  module Schedulers
    class EcsServiceDiscoveryServiceComparator
      # @param [Hash] expected_service
      def initialize(expected_service)
        @expected_service = expected_service
        @schema = service_schema
      end

      # @param [Aws::ServiceDiscovery::Types::ServiceSummary] actual_service
      # @return [Boolean]
      def different?(actual_service)
        !@schema.same?(actual_service.to_h, @expected_service)
      end

      private

      def service_schema
        Schema::Structure.new.tap do |struct|
          struct.member(:description, Schema::Nullable.new(Schema::String.new))
          struct.member(:dns_config, dns_config_schema)
        end
      end

      def dns_config_schema
        Schema::Structure.new.tap do |struct|
          struct.member(:dns_records, Schema::UnorderedArray.new(dns_records_schema))
        end
      end

      def dns_records_schema
        Schema::Structure.new.tap do |struct|
          struct.member(:ttl, Schema::Integer.new)
          struct.member(:type, Schema::String.new)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hako-2.17.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.16.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.15.1 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.15.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.14.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.13.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.12.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.11.1 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.11.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.10.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.9.2 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.9.1 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.9.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.8.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb
hako-2.7.0 lib/hako/schedulers/ecs_service_discovery_service_comparator.rb