Skip to content

Commit

Permalink
Merge pull request #549 from Praqma/fix-file-hooks
Browse files Browse the repository at this point in the history
fix: isValidFile error for hooks should not lead to a file resolve.
  • Loading branch information
luisdavim authored Nov 24, 2020
2 parents b3b28d2 + d827131 commit f24f838
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/app/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions internal/app/release_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/app/state_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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)
}
}
Expand Down

0 comments on commit f24f838

Please sign in to comment.