Sha256: 02533bceda9bbb03c1e41e1752ca2fd2187f1f4205f8b54664cee7bb3844090a

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

class KuberKit::Shell::Commands::HelmCommands
  Contract KuberKit::Shell::AbstractShell, Or[String, ArrayOf[String]], KeywordArgs[
    kubeconfig_path: Maybe[Or[
      String, KuberKit::Core::ArtifactPath
    ]],
    namespace:              Maybe[Or[Symbol, String]],
    interactive:            Optional[Bool],
  ] => Any
  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

  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

  def upgrade(shell, release_name, chart_path, kubeconfig_path: nil, namespace: nil, wait: true)
    command_parts = [
      "upgrade #{release_name} #{chart_path}",
      "--install"
    ]
    command_parts << "--wait" if wait
    helm_run(shell, command_parts, kubeconfig_path: kubeconfig_path, namespace: namespace)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kuber_kit-1.3.9 lib/kuber_kit/shell/commands/helm_commands.rb
kuber_kit-1.3.8 lib/kuber_kit/shell/commands/helm_commands.rb
kuber_kit-1.3.7 lib/kuber_kit/shell/commands/helm_commands.rb