Class: Algo::Dsl::Service::VolumeContext

Inherits:
Object
  • Object
show all
Defined in:
lib/algo/dsl/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clstr_context, srv_context) ⇒ VolumeContext

Returns a new instance of VolumeContext.



8
9
10
11
12
# File 'lib/algo/dsl/service.rb', line 8

def initialize clstr_context, srv_context
  @clstr_context = clstr_context
  @srv_context = srv_context
  @context = {}
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/algo/dsl/service.rb', line 6

def context
  @context
end

Instance Method Details

#driver(item) ⇒ Object

Parameters:

  • volume (String)

    driver type ex) local



45
46
47
48
# File 'lib/algo/dsl/service.rb', line 45

def driver item
  @context['VolumeOptions'] ||= {}
  @context['VolumeOptions'] = { 'DriverConfig' => { 'Name' => item } }
end

#label(key, val) ⇒ Object



38
39
40
41
42
# File 'lib/algo/dsl/service.rb', line 38

def label key, val
  @context['VolumeOptions'] ||= {}
  @context['VolumeOptions']['Labels'] ||= {}
  @context['VolumeOptions']['Labels'][key] = val
end

#readonlyObject



14
15
16
# File 'lib/algo/dsl/service.rb', line 14

def readonly
  @context['ReadOnly'] = true
end

#source(item) ⇒ Object

Parameters:

  • item (String)

    volume name or host file/directory path



19
20
21
22
23
24
25
26
# File 'lib/algo/dsl/service.rb', line 19

def source item
  raise 'Need to call type at first' unless @context['Type']
  if @context['Type'] == 'volume'
    @context['Source'] = "#{cluster_prefix}#{item}"
  else
    @context['Source'] = item
  end
end

#target(item) ⇒ Object

Parameters:

  • item (String)

    container mount path



29
30
31
# File 'lib/algo/dsl/service.rb', line 29

def target item
  @context['Target'] = item
end

#type(item) ⇒ Object

Parameters:

  • volume (String)

    type ex) bind,volume



34
35
36
# File 'lib/algo/dsl/service.rb', line 34

def type item
  @context['Type'] = item
end