updated comment and made defer of shutdown function return errors as before and not the possible shutdown error

Signed-off-by: Michelle Fernandez Bieber <mfbieber@gmail.com>
pull/10603/head
Michelle Fernandez Bieber 4 years ago
parent d8953575af
commit 49c3b897bc

@ -54,7 +54,7 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
} }
return compListReleases(toComplete, args, cfg) return compListReleases(toComplete, args, cfg)
}, },
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) (returnError error) {
client.Namespace = settings.Namespace() client.Namespace = settings.Namespace()
notName := regexp.MustCompile(`^!\s?name=`) notName := regexp.MustCompile(`^!\s?name=`)
for _, f := range filter { for _, f := range filter {
@ -64,8 +64,16 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
client.Filters["!name"] = append(client.Filters["!name"], notName.ReplaceAllLiteralString(f, "")) client.Filters["!name"] = append(client.Filters["!name"], notName.ReplaceAllLiteralString(f, ""))
} }
} }
rel, shutdown, runErr := client.Run(args[0]) rel, shutdown, runErr := client.Run(args[0])
defer shutdown() defer func() {
if shutdownErr := shutdown(); shutdownErr != nil {
if returnError == nil {
returnError = shutdownErr
}
}
}()
// We only return an error if we weren't even able to get the // We only return an error if we weren't even able to get the
// release, otherwise we keep going so we can print status and logs // release, otherwise we keep going so we can print status and logs
// if requested // if requested

@ -44,7 +44,7 @@ func ShutdownNoOp() error {
return nil return nil
} }
// execHook executes all of the hooks for the given hook event and return a shutdownHook function to trigger deletions after doing other things like e.g. retrieving logs. // execHook executes all of the hooks for the given hook event and returns a shutdownHook function to trigger deletions after doing other things like e.g. retrieving logs.
func (cfg *Configuration) execHookWithDelayedShutdown(rl *release.Release, hook release.HookEvent, timeout time.Duration) (ExecuteShutdownHooks, error) { func (cfg *Configuration) execHookWithDelayedShutdown(rl *release.Release, hook release.HookEvent, timeout time.Duration) (ExecuteShutdownHooks, error) {
executingHooks := []*release.Hook{} executingHooks := []*release.Hook{}

Loading…
Cancel
Save