Class: Hako::Schedulers::EcsVolumeComparator

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

Instance Method Summary collapse

Constructor Details

#initialize(expected_volume) ⇒ EcsVolumeComparator

Returns a new instance of EcsVolumeComparator.

Parameters:

  • expected_volume (Hash)


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

def initialize(expected_volume)
  @expected_volume = expected_volume
  @schema = volume_schema
end

Instance Method Details

#different?(actual_volume) ⇒ Boolean

Parameters:

  • actual_volume (Aws::ECS::Types::Volume)

Returns:

  • (Boolean)


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

def different?(actual_volume)
  !@schema.same?(actual_volume.to_h, @expected_volume)
end

#docker_volume_configuration_schemaObject (private)



30
31
32
33
34
35
36
37
38
# File 'lib/hako/schedulers/ecs_volume_comparator.rb', line 30

def docker_volume_configuration_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:autoprovision, Schema::Nullable.new(Schema::Boolean.new))
    struct.member(:driver, Schema::WithDefault.new(Schema::String.new, 'local'))
    struct.member(:driver_opts, Schema::Nullable.new(Schema::Table.new(Schema::String.new, Schema::String.new)))
    struct.member(:labels, Schema::Nullable.new(Schema::Table.new(Schema::String.new, Schema::String.new)))
    struct.member(:scope, Schema::WithDefault.new(Schema::String.new, 'task'))
  end
end

#host_schemaObject (private)



40
41
42
43
44
# File 'lib/hako/schedulers/ecs_volume_comparator.rb', line 40

def host_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:source_path, Schema::Nullable.new(Schema::String.new))
  end
end

#volume_schemaObject (private)



22
23
24
25
26
27
28
# File 'lib/hako/schedulers/ecs_volume_comparator.rb', line 22

def volume_schema
  Schema::Structure.new.tap do |struct|
    struct.member(:docker_volume_configuration, Schema::Nullable.new(docker_volume_configuration_schema))
    struct.member(:host, Schema::Nullable.new(host_schema))
    struct.member(:name, Schema::String.new)
  end
end