From 1f7db4f51c4cb9e232fd33a1d865f91e29c4f8d5 Mon Sep 17 00:00:00 2001 From: Mateusz Kubaczyk Date: Fri, 2 Oct 2020 10:47:40 +0200 Subject: [PATCH] Run helm tests as a last command of after commands from hooks --- internal/app/release.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/app/release.go b/internal/app/release.go index 0385f612..38000b03 100644 --- a/internal/app/release.go +++ b/internal/app/release.go @@ -292,21 +292,21 @@ func getChartVersion(chart, version string) (string, string) { } // testRelease creates a Helm command to test a particular release. -func (r *release) test(p *plan) { +func (r *release) test(afterCommands *[]command) { cmd := helmCmd(r.getHelmArgsFor("test"), "Running tests for release [ "+r.Name+" ] in namespace [ "+r.Namespace+" ]") - p.addCommand(cmd, r.Priority, r, []command{}, []command{}) + *afterCommands = append(*afterCommands, cmd) } // installRelease creates a Helm command to install a particular release in a particular namespace using a particular Tiller. func (r *release) install(p *plan) { - before, after := r.checkHooks("install", p) - cmd := helmCmd(r.getHelmArgsFor("install"), "Install release [ "+r.Name+" ] version [ "+r.Version+" ] in namespace [ "+r.Namespace+" ]") - p.addCommand(cmd, r.Priority, r, before, after) if r.Test { - r.test(p) + r.test(&after) } + + cmd := helmCmd(r.getHelmArgsFor("install"), "Install release [ "+r.Name+" ] version [ "+r.Version+" ] in namespace [ "+r.Namespace+" ]") + p.addCommand(cmd, r.Priority, r, before, after) } // uninstall uninstalls a release @@ -358,14 +358,14 @@ func (r *release) upgrade(p *plan) { before, after := r.checkHooks("upgrade", p) + if r.Test { + r.test(&after) + } + cmd := helmCmd(r.getHelmArgsFor("upgrade"), "Upgrade release [ "+r.Name+" ] to version [ "+r.Version+" ] in namespace [ "+r.Namespace+" ]") p.addCommand(cmd, r.Priority, r, before, after) - if r.Test { - r.test(p) - } - } // reInstall uninstalls a release and reinstalls it.