From 4c4b10668ad60cf96eee5745393cc43427bca174 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 13 Aug 2019 16:04:08 -0700 Subject: [PATCH] ref(test): join all hook manifests before building Signed-off-by: Matthew Fisher --- pkg/action/release_testing.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/action/release_testing.go b/pkg/action/release_testing.go index 1bd61b8de..15cc70947 100644 --- a/pkg/action/release_testing.go +++ b/pkg/action/release_testing.go @@ -19,6 +19,7 @@ package action import ( "bytes" "fmt" + "strings" "time" "github.com/pkg/errors" @@ -61,19 +62,21 @@ func (r *ReleaseTesting) Run(name string) error { } if r.Cleanup { + var manifestsToDelete strings.Builder for _, h := range rel.Hooks { for _, e := range h.Events { if e == release.HookTest { - hookResource, err := r.cfg.KubeClient.Build(bytes.NewBufferString(h.Manifest)) - if err != nil { - return errors.Wrapf(err, "unable to build kubernetes object for %v hook %s", h, h.Path) - } - if _, errs := r.cfg.KubeClient.Delete(hookResource); errs != nil { - return fmt.Errorf("unable to delete kubernetes object for %v hook %s: %s", h, h.Path, joinErrors(errs)) - } + fmt.Fprintf(&manifestsToDelete, "\n---\n%s", h.Manifest) } } } + hooks, err := r.cfg.KubeClient.Build(bytes.NewBufferString(manifestsToDelete.String())) + if err != nil { + return fmt.Errorf("unable to build test hooks: %v", err) + } + if _, errs := r.cfg.KubeClient.Delete(hooks); errs != nil { + return fmt.Errorf("unable to delete test hooks: %v", joinErrors(errs)) + } } return r.cfg.Releases.Update(rel)