diff --git a/internal/app/release.go b/internal/app/release.go index 4288bfcb..28b3992c 100644 --- a/internal/app/release.go +++ b/internal/app/release.go @@ -485,13 +485,13 @@ func (r *release) getHookCommands(hookType, ns string) []hookCmd { var cmds []hookCmd if _, ok := r.Hooks[hookType]; ok { hook := r.Hooks[hookType].(string) - if err := isValidFile(hook, []string{".yaml", ".yml", ".json"}); err != nil { + if err := isValidFile(hook, []string{".yaml", ".yml", ".json"}); err == nil { cmd := kubectl([]string{"apply", "-n", ns, "-f", hook, flags.getKubeDryRunFlag("apply")}, "Apply "+hook+" manifest "+hookType) cmds = append(cmds, hookCmd{Command: cmd, Type: hookType}) if wait, waitCmds := r.shouldWaitForHook(hook, hookType, ns); wait { cmds = append(cmds, waitCmds...) } - } else { + } else { // shell hook args := strings.Fields(hook) cmds = append(cmds, hookCmd{ Command: Command{ diff --git a/internal/app/release_files.go b/internal/app/release_files.go index 21f9990b..13b08c6d 100644 --- a/internal/app/release_files.go +++ b/internal/app/release_files.go @@ -19,7 +19,7 @@ func (r *release) substituteVarsInStaticFiles() { for key, val := range r.Hooks { if key != "deleteOnSuccess" && key != "successTimeout" && key != "successCondition" { hook := val.(string) - if err := isValidFile(hook, []string{".yaml", ".yml"}); err != nil { + if err := isValidFile(hook, []string{".yaml", ".yml"}); err == nil { r.Hooks[key] = substituteVarsInYaml(hook) } } @@ -45,7 +45,7 @@ func (r *release) resolvePaths(dir, downloadDest string) { for key, val := range r.Hooks { if key != "deleteOnSuccess" && key != "successTimeout" && key != "successCondition" { hook := val.(string) - if err := isValidFile(hook, []string{".yaml", ".yml", ".json"}); err != nil { + if err := isValidFile(hook, []string{".yaml", ".yml", ".json"}); err == nil { r.Hooks[key], _ = resolveOnePath(hook, dir, downloadDest) } } diff --git a/internal/app/state_files.go b/internal/app/state_files.go index 97ebff8e..f9fc3a31 100644 --- a/internal/app/state_files.go +++ b/internal/app/state_files.go @@ -164,7 +164,7 @@ func (s *state) expand(relativeToFile string) { for key, val := range s.Settings.GlobalHooks { if key != "deleteOnSuccess" && key != "successTimeout" && key != "successCondition" { hook := val.(string) - if err := isValidFile(hook, []string{".yaml", ".yml"}); err != nil { + if err := isValidFile(hook, []string{".yaml", ".yml"}); err == nil { s.Settings.GlobalHooks[key] = substituteVarsInYaml(hook) } } @@ -180,7 +180,7 @@ func (s *state) expand(relativeToFile string) { for key, val := range s.Settings.GlobalHooks { if key != "deleteOnSuccess" && key != "successTimeout" && key != "successCondition" { hook := val.(string) - if err := isValidFile(hook, []string{".yaml", ".yml", ".json"}); err != nil { + if err := isValidFile(hook, []string{".yaml", ".yml", ".json"}); err == nil { s.Settings.GlobalHooks[key], _ = resolveOnePath(hook, dir, downloadDest) } }