Class: Hako::Schedulers::EcsServiceComparator

Inherits:
Object
  • Object
show all
Defined in:
lib/hako/schedulers/ecs_service_comparator.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_service) ⇒ EcsServiceComparator

Returns a new instance of EcsServiceComparator.



8
9
10
11
# File 'lib/hako/schedulers/ecs_service_comparator.rb', line 8

def initialize(expected_service)
  @expected_service = expected_service
  @schema = service_schema
end

Instance Method Details

#awsvpc_configuration_schemaObject (private)



45
46
47
48
49
50
51
# File 'lib/hako/schedulers/ecs_service_comparator.rb', line 45

def awsvpc_configuration_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:subnets, Schema::UnorderedArray.new(Schema::String.new))
    struct.member(:security_groups, Schema::UnorderedArray.new(Schema::String.new))
    struct.member(:assign_public_ip, Schema::String.new)
  end
end

#default_configurationObject (private)



53
54
55
56
57
58
# File 'lib/hako/schedulers/ecs_service_comparator.rb', line 53

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

#deployment_configuration_schemaObject (private)



32
33
34
35
36
37
# File 'lib/hako/schedulers/ecs_service_comparator.rb', line 32

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

#different?(actual_service) ⇒ Boolean

Parameters:

  • actual_service (Aws::ECS::Types::Service)

Returns:

  • (Boolean)


15
16
17
# File 'lib/hako/schedulers/ecs_service_comparator.rb', line 15

def different?(actual_service)
  !@schema.same?(actual_service.to_h, @expected_service)
end

#network_configuration_schemaObject (private)



39
40
41
42
43
# File 'lib/hako/schedulers/ecs_service_comparator.rb', line 39

def network_configuration_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:awsvpc_configuration, awsvpc_configuration_schema)
  end
end

#service_schemaObject (private)



21
22
23
24
25
26
27
28
29
30
# File 'lib/hako/schedulers/ecs_service_comparator.rb', line 21

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))
    struct.member(:platform_version, Schema::WithDefault.new(Schema::String.new, 'LATEST'))
    struct.member(:network_configuration, Schema::Nullable.new(network_configuration_schema))
    struct.member(:health_check_grace_period_seconds, Schema::Nullable.new(Schema::Integer.new))
  end
end