Class: KuberKit::Shell::Commands::HelmCommands

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/shell/commands/helm_commands.rb

Instance Method Summary collapse

Instance Method Details

#helm_run(shell, command_list, kubeconfig_path: nil, namespace: nil, interactive: false) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/kuber_kit/shell/commands/helm_commands.rb', line 9

def helm_run(shell, command_list, kubeconfig_path: nil, namespace: nil, interactive: false)
  command_parts = []

  if kubeconfig_path.is_a?(KuberKit::Core::ArtifactPath)
    kubeconfig_path = artifact_path_resolver.call(kubeconfig_path)
  end

  if kubeconfig_path
    command_parts << "KUBECONFIG=#{kubeconfig_path}"
  end

  command_parts << "helm"

  if namespace
    command_parts << "-n #{namespace}"
  end

  command_parts += Array(command_list).compact

  if interactive
    shell.interactive!(command_parts.join(" "))
  else
    shell.exec!(command_parts.join(" "))
  end
end

#install(shell, release_name, chart_path, kubeconfig_path: nil, namespace: nil) ⇒ Object



35
36
37
# File 'lib/kuber_kit/shell/commands/helm_commands.rb', line 35

def install(shell, release_name, chart_path, kubeconfig_path: nil, namespace: nil)
  helm_run(shell, "install #{release_name} #{chart_path}", kubeconfig_path: kubeconfig_path, namespace: namespace)
end

#upgrade(shell, release_name, chart_path, kubeconfig_path: nil, namespace: nil) ⇒ Object



39
40
41
# File 'lib/kuber_kit/shell/commands/helm_commands.rb', line 39

def upgrade(shell, release_name, chart_path, kubeconfig_path: nil, namespace: nil)
  helm_run(shell, "upgrade #{release_name} #{chart_path} --install", kubeconfig_path: kubeconfig_path, namespace: namespace)
end