Class: Hako::Schedulers::EcsDefinitionComparator

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

Instance Method Summary collapse

Constructor Details

#initialize(expected_container) ⇒ EcsDefinitionComparator

Returns a new instance of EcsDefinitionComparator.

Parameters:

  • expected_container (Hash)


9
10
11
12
# File 'lib/hako/schedulers/ecs_definition_comparator.rb', line 9

def initialize(expected_container)
  @expected_container = expected_container
  @schema = definition_schema
end

Instance Method Details

#definition_schemaObject (private)



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/hako/schedulers/ecs_definition_comparator.rb', line 22

def definition_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:image, Schema::String.new)
    struct.member(:cpu, Schema::Integer.new)
    struct.member(:memory, Schema::Integer.new)
    struct.member(:memory_reservation, Schema::Nullable.new(Schema::Integer.new))
    struct.member(:links, Schema::UnorderedArray.new(Schema::String.new))
    struct.member(:port_mappings, Schema::UnorderedArray.new(port_mapping_schema))
    struct.member(:environment, Schema::UnorderedArray.new(environment_schema))
    struct.member(:docker_labels, Schema::Table.new(Schema::String.new, Schema::String.new))
    struct.member(:mount_points, Schema::UnorderedArray.new(mount_point_schema))
    struct.member(:command, Schema::Nullable.new(Schema::OrderedArray.new(Schema::String.new)))
    struct.member(:volumes_from, Schema::UnorderedArray.new(volumes_from_schema))
    struct.member(:user, Schema::Nullable.new(Schema::String.new))
    struct.member(:privileged, Schema::Boolean.new)
    struct.member(:log_configuration, Schema::Nullable.new(log_configuration_schema))
  end
end

#different?(actual_container) ⇒ Boolean

Parameters:

  • actual_container (Aws::ECS::Types::ContainerDefinition)

Returns:

  • (Boolean)


16
17
18
# File 'lib/hako/schedulers/ecs_definition_comparator.rb', line 16

def different?(actual_container)
  !@schema.same?(actual_container.to_h, @expected_container)
end

#environment_schemaObject (private)



49
50
51
52
53
54
# File 'lib/hako/schedulers/ecs_definition_comparator.rb', line 49

def environment_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:name, Schema::String.new)
    struct.member(:value, Schema::String.new)
  end
end

#log_configuration_schemaObject (private)



71
72
73
74
75
76
# File 'lib/hako/schedulers/ecs_definition_comparator.rb', line 71

def log_configuration_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:log_driver, Schema::String.new)
    struct.member(:options, Schema::Table.new(Schema::String.new, Schema::String.new))
  end
end

#mount_point_schemaObject (private)



56
57
58
59
60
61
62
# File 'lib/hako/schedulers/ecs_definition_comparator.rb', line 56

def mount_point_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:source_volume, Schema::String.new)
    struct.member(:container_path, Schema::String.new)
    struct.member(:read_only, Schema::Boolean.new)
  end
end

#port_mapping_schemaObject (private)



41
42
43
44
45
46
47
# File 'lib/hako/schedulers/ecs_definition_comparator.rb', line 41

def port_mapping_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:container_port, Schema::Integer.new)
    struct.member(:host_port, Schema::Integer.new)
    struct.member(:protocol, Schema::String.new)
  end
end

#volumes_from_schemaObject (private)



64
65
66
67
68
69
# File 'lib/hako/schedulers/ecs_definition_comparator.rb', line 64

def volumes_from_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:source_container, Schema::String.new)
    struct.member(:read_only, Schema::Boolean.new)
  end
end