Sha256: b719c6299695d105f8e5f2019bb79655f1e24988c612a344d208fe0a66b8acb1

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true
require 'hako/schema'

module Hako
  module Schedulers
    class EcsServiceComparator
      def initialize(expected_service)
        @expected_service = expected_service
        @schema = service_schema
      end

      # @param [Aws::ECS::Types::Service] 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(:desired_count, Schema::Integer.new)
          struct.member(:task_definition, Schema::String.new)
          struct.member(:deployment_configuration, Schema::WithDefault.new(deployment_configuration_schema, default_configuration))
        end
      end

      def deployment_configuration_schema
        Schema::Structure.new.tap do |struct|
          struct.member(:maximum_percent, Schema::Integer.new)
          struct.member(:minimum_healthy_percent, Schema::Integer.new)
        end
      end

      def default_configuration
        {
          maximum_percent: 200,
          minimum_healthy_percent: 100,
        }
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hako-1.1.0 lib/hako/schedulers/ecs_service_comparator.rb
hako-1.0.1 lib/hako/schedulers/ecs_service_comparator.rb
hako-1.0.0 lib/hako/schedulers/ecs_service_comparator.rb
hako-0.27.0 lib/hako/schedulers/ecs_service_comparator.rb
hako-0.26.0 lib/hako/schedulers/ecs_service_comparator.rb
hako-0.25.2 lib/hako/schedulers/ecs_service_comparator.rb
hako-0.25.1 lib/hako/schedulers/ecs_service_comparator.rb
hako-0.25.0 lib/hako/schedulers/ecs_service_comparator.rb
hako-0.24.0 lib/hako/schedulers/ecs_service_comparator.rb
hako-0.23.0 lib/hako/schedulers/ecs_service_comparator.rb
hako-0.22.0 lib/hako/schedulers/ecs_service_comparator.rb