Class: Orchparty::Kubernetes::MixinBuilder

Inherits:
Builder
  • Object
show all
Defined in:
lib/orchparty/dsl_parser_kubernetes.rb

Instance Method Summary collapse

Methods inherited from Builder

#assign_or_merge, build

Constructor Details

#initialize(name) ⇒ MixinBuilder

Returns a new instance of MixinBuilder.



67
68
69
# File 'lib/orchparty/dsl_parser_kubernetes.rb', line 67

def initialize(name)
  @mixin = AST.mixin(name:)
end

Instance Method Details

#_buildObject



125
126
127
# File 'lib/orchparty/dsl_parser_kubernetes.rb', line 125

def _build
  @mixin
end

#apply(name, &block) ⇒ Object



106
107
108
109
110
111
# File 'lib/orchparty/dsl_parser_kubernetes.rb', line 106

def apply(name, &block)
  result = ServiceBuilder.build(name, 'apply', block)
  @mixin.services[name] = result
  @mixin._mixins[name] = result
  self
end

#helm(name, &block) ⇒ Object



99
100
101
102
103
104
# File 'lib/orchparty/dsl_parser_kubernetes.rb', line 99

def helm(name, &block)
  result = ServiceBuilder.build(name, 'helm', block)
  @mixin.services[name] = result
  @mixin._mixins[name] = result
  self
end

#mixin(name, &block) ⇒ Object



113
114
115
# File 'lib/orchparty/dsl_parser_kubernetes.rb', line 113

def mixin(name, &block)
  @mixin._mixins[name] = ServiceMixinBuilder.build(name, block)
end

#networks(&block) ⇒ Object



121
122
123
# File 'lib/orchparty/dsl_parser_kubernetes.rb', line 121

def networks(&block)
  @mixin.networks = HashBuilder.build(block)
end

#service(name, &block) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/orchparty/dsl_parser_kubernetes.rb', line 82

def service(name, &block)
  chart_name = '_mixin_temp_name'
  unless @mixin.services[chart_name]
    @mixin.services[chart_name] = AST.chart(name: chart_name, _type: 'chart')
    @mixin._service_order << chart_name
  end
  chart = @mixin.services[chart_name]

  result = ServiceBuilder.build(name, 'chart-service', block)

  name = "chart-#{chart.name}-#{name}"
  @mixin.services[name] = result
  @mixin._service_order << name
  chart._services << name
  self
end

#template(path) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/orchparty/dsl_parser_kubernetes.rb', line 71

def template(path)
  chart_name = '_mixin_temp_name'
  unless @mixin.services[chart_name]
    @mixin.services[chart_name] = AST.chart(name: chart_name, _type: 'chart')
    @mixin._service_order << chart_name
  end
  chart = @mixin.services[chart_name]
  chart.template = path
  self
end

#volumes(&block) ⇒ Object



117
118
119
# File 'lib/orchparty/dsl_parser_kubernetes.rb', line 117

def volumes(&block)
  @mixin.volumes = HashBuilder.build(block)
end