Class: KubernetesApplication

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_config: [], namespace:, cluster_name:, file_name:) ⇒ KubernetesApplication

Returns a new instance of KubernetesApplication.



272
273
274
275
276
277
# File 'lib/orchparty/kubernetes_application.rb', line 272

def initialize(app_config: [], namespace:, cluster_name:, file_name:)
  self.file_path = Pathname.new(file_name).parent.expand_path
  self.cluster_name = cluster_name
  self.namespace = namespace
  self.app_config = app_config
end

Instance Attribute Details

#app_configObject

Returns the value of attribute app_config.



270
271
272
# File 'lib/orchparty/kubernetes_application.rb', line 270

def app_config
  @app_config
end

#cluster_nameObject

Returns the value of attribute cluster_name.



267
268
269
# File 'lib/orchparty/kubernetes_application.rb', line 267

def cluster_name
  @cluster_name
end

#file_pathObject

Returns the value of attribute file_path.



268
269
270
# File 'lib/orchparty/kubernetes_application.rb', line 268

def file_path
  @file_path
end

#namespaceObject

Returns the value of attribute namespace.



269
270
271
# File 'lib/orchparty/kubernetes_application.rb', line 269

def namespace
  @namespace
end

Instance Method Details

#combine_charts(app_config) ⇒ Object



291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/orchparty/kubernetes_application.rb', line 291

def combine_charts(app_config)
  services = app_config._service_order.map(&:to_s)
  app_config._service_order.each do |name|
    current_service = app_config[:services][name]
    if current_service._type == "chart"
      current_service._services.each do |n|
        services.delete n.to_s
      end
    end
  end
  services
end

#each_service(method) ⇒ Object



304
305
306
307
308
309
310
# File 'lib/orchparty/kubernetes_application.rb', line 304

def each_service(method)
  services = combine_charts(app_config)
  services.each do |name|
    service = app_config[:services][name]
    "::Orchparty::Services::#{service._type.classify}".constantize.new(cluster_name: cluster_name, namespace: namespace, file_path: file_path, app_config: app_config).send(method, service)
  end
end

#installObject



279
280
281
# File 'lib/orchparty/kubernetes_application.rb', line 279

def install
  each_service(:install)
end


287
288
289
# File 'lib/orchparty/kubernetes_application.rb', line 287

def print(method)
  each_service("print_#{method}".to_sym)
end

#upgradeObject



283
284
285
# File 'lib/orchparty/kubernetes_application.rb', line 283

def upgrade
  each_service(:upgrade)
end