Skip to content

Commit

Permalink
added '--wait' option for helm upgrade, so that the deployment will w…
Browse files Browse the repository at this point in the history
…ait for service restart
  • Loading branch information
gvalmon committed Jan 2, 2024
1 parent 8bccc3a commit 7b34419
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lib/kuber_kit/shell/commands/helm_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ def install(shell, release_name, chart_path, kubeconfig_path: nil, namespace: ni
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)
helm_run(shell, "upgrade #{release_name} #{chart_path} --install", kubeconfig_path: kubeconfig_path, namespace: namespace)
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
4 changes: 2 additions & 2 deletions spec/kuber_kit/shell/commands/helm_commands_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

context "#upgrade" do
it do
expect(shell).to receive(:exec!).with(%Q{helm upgrade learning-app /path/to/chart --install})
expect(shell).to receive(:exec!).with(%Q{helm upgrade learning-app /path/to/chart --install --wait})
subject.upgrade(shell, "learning-app", "/path/to/chart")
end

it do
expect(shell).to receive(:exec!).with(%Q{KUBECONFIG=/path/to/kube.cfg helm upgrade learning-app /path/to/chart --install})
expect(shell).to receive(:exec!).with(%Q{KUBECONFIG=/path/to/kube.cfg helm upgrade learning-app /path/to/chart --install --wait})
subject.upgrade(shell, "learning-app", "/path/to/chart", kubeconfig_path: "/path/to/kube.cfg")
end
end
Expand Down

0 comments on commit 7b34419

Please sign in to comment.