class Algo::Dsl::Service::VolumeContext

Attributes

context[R]

Public Class Methods

new(clstr_context, srv_context) click to toggle source
# File lib/algo/dsl/service.rb, line 8
def initialize clstr_context, srv_context
  @clstr_context = clstr_context
  @srv_context = srv_context
  @context = {}
end

Public Instance Methods

driver(item) click to toggle source

@param [String] volume driver type ex) local

# File lib/algo/dsl/service.rb, line 45
def driver item
  @context['VolumeOptions'] ||= {}
  @context['VolumeOptions'] = { 'DriverConfig' => { 'Name' => item } }
end
label(key, val) click to toggle source
# File lib/algo/dsl/service.rb, line 38
def label key, val
  @context['VolumeOptions'] ||= {}
  @context['VolumeOptions']['Labels'] ||= {}
  @context['VolumeOptions']['Labels'][key] = val
end
readonly() click to toggle source
# File lib/algo/dsl/service.rb, line 14
def readonly
  @context['ReadOnly'] = true
end
source(item) click to toggle source

@param [String] item volume name or host file/directory path

# 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) click to toggle source

@param [String] item container mount path

# File lib/algo/dsl/service.rb, line 29
def target item
  @context['Target'] = item
end
type(item) click to toggle source

@param [String] volume type ex) bind,volume

# File lib/algo/dsl/service.rb, line 34
def type item
  @context['Type'] = item
end

Private Instance Methods

cluster_prefix() click to toggle source
# File lib/algo/dsl/service.rb, line 52
def cluster_prefix
  "#{@clstr_context['prefix']}-" if @clstr_context['prefix']
end