class Orchparty::Services::Context

Attributes

app_config[RW]
cluster_name[RW]
dir_path[RW]
namespace[RW]

Public Class Methods

new(cluster_name: , namespace:, file_path: , app_config:) click to toggle source
# File lib/orchparty/kubernetes_application.rb, line 20
def initialize(cluster_name: , namespace:, file_path: , app_config:)
  self.cluster_name = cluster_name
  self.namespace = namespace
  self.dir_path = file_path
  self.app_config = app_config
end

Public Instance Methods

install(helm) click to toggle source
# File lib/orchparty/kubernetes_application.rb, line 62
def install(helm)
  puts system(install_cmd(helm))
end
print_install(helm) click to toggle source
print_upgrade(helm) click to toggle source
template(file_path, helm, flag: "-f ", fix_file_path: nil) click to toggle source
# File lib/orchparty/kubernetes_application.rb, line 27
def template(file_path, helm, flag: "-f ", fix_file_path: nil)
  return "" unless file_path
  file_path = File.join(self.dir_path, file_path)
  if(file_path.end_with?(".erb"))
    helm.application = OpenStruct.new(cluster_name: cluster_name, namespace: namespace)
    template = Erubis::Eruby.new(File.read(file_path))
    yaml = template.result(helm.get_binding)
    file = Tempfile.new("kube-deploy.yaml")
    file.write(yaml)
    file.close
    file_path = file.path
  end
  "#{flag}#{fix_file_path || file_path}"
end
upgrade(helm) click to toggle source
# File lib/orchparty/kubernetes_application.rb, line 57
def upgrade(helm)
  puts system(upgrade_cmd(helm))
end