Class: Algo::Dsl::Service::VolumeContext
- Inherits:
-
Object
- Object
- Algo::Dsl::Service::VolumeContext
- Defined in:
- lib/algo/dsl/service.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #driver(item) ⇒ Object
-
#initialize(clstr_context, srv_context) ⇒ VolumeContext
constructor
A new instance of VolumeContext.
- #label(key, val) ⇒ Object
- #readonly ⇒ Object
- #source(item) ⇒ Object
- #target(item) ⇒ Object
- #type(item) ⇒ Object
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
#context ⇒ Object (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
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 |
#readonly ⇒ Object
14 15 16 |
# File 'lib/algo/dsl/service.rb', line 14 def readonly @context['ReadOnly'] = true end |
#source(item) ⇒ Object
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
29 30 31 |
# File 'lib/algo/dsl/service.rb', line 29 def target item @context['Target'] = item end |
#type(item) ⇒ Object
34 35 36 |
# File 'lib/algo/dsl/service.rb', line 34 def type item @context['Type'] = item end |