fix(test): restore --cleanup

Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
This commit is contained in:
Matthew Fisher
2019-08-13 11:56:39 -07:00
parent 29d6853659
commit fddf066121

View File

@@ -17,6 +17,8 @@ limitations under the License.
package action
import (
"bytes"
"fmt"
"time"
"github.com/pkg/errors"
@@ -58,5 +60,21 @@ func (r *ReleaseTesting) Run(name string) error {
return err
}
if r.Cleanup {
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 %s hook %s", h, h.Path)
}
if _, errs := r.cfg.KubeClient.Delete(hookResource); errs != nil {
return fmt.Errorf("unable to delete kubernetes object for %s hook %s: %s", h, h.Path, joinErrors(errs))
}
}
}
}
}
return r.cfg.Releases.Update(rel)
}