Skip to content

Commit 1071477

Browse files
mfbieberbenoittgt
authored andcommitted
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>
1 parent 7a55758 commit 1071477

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pkg/action/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func ShutdownNoOp() error {
4949
return nil
5050
}
5151

52-
// 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.
52+
// 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.
5353
func (cfg *Configuration) execHookWithDelayedShutdown(rl *release.Release, hook release.HookEvent, waitStrategy kube.WaitStrategy, timeout time.Duration, serverSideApply bool) (ExecuteShutdownHooks, error) {
5454
executingHooks := []*release.Hook{}
5555

pkg/cmd/release_testing.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
5555
}
5656
return compListReleases(toComplete, args, cfg)
5757
},
58-
RunE: func(_ *cobra.Command, args []string) error {
58+
RunE: func(_ *cobra.Command, args []string) (returnError error) {
5959
client.Namespace = settings.Namespace()
6060
notName := regexp.MustCompile(`^!\s?name=`)
6161
for _, f := range filter {
@@ -65,8 +65,17 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
6565
client.Filters[action.ExcludeNameFilter] = append(client.Filters[action.ExcludeNameFilter], notName.ReplaceAllLiteralString(f, ""))
6666
}
6767
}
68+
6869
reli, shutdown, runErr := client.Run(args[0])
69-
defer shutdown()
70+
defer func() {
71+
if shutdownErr := shutdown(); shutdownErr != nil {
72+
if returnError == nil {
73+
returnError = shutdownErr
74+
}
75+
}
76+
}()
77+
78+
7079
// We only return an error if we weren't even able to get the
7180
// release, otherwise we keep going so we can print status and logs
7281
// if requested

0 commit comments

Comments
 (0)