summaryrefslogtreecommitdiff
path: root/pkg/hooks/read.go
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2018-06-03 11:38:46 -0700
committerAtomic Bot <atomic-devel@projectatomic.io>2018-06-04 13:01:56 +0000
commit947e410fe6e731743f2f25df3cf4b79cdcfbbf15 (patch)
tree4816eff0eb056ac15b25f34f350ebc4e5d17696d /pkg/hooks/read.go
parentcae49fca2930e461577df77ed303f90c9eed615c (diff)
downloadpodman-947e410fe6e731743f2f25df3cf4b79cdcfbbf15.tar.gz
podman-947e410fe6e731743f2f25df3cf4b79cdcfbbf15.tar.bz2
podman-947e410fe6e731743f2f25df3cf4b79cdcfbbf15.zip
hooks: Fail ReadDir if a configured hook executable is missing
The continue here is from 5676597f (hooks/read: Ignore IsNotExist for JSON files in ReadDir, 2018-04-27, #686), where it was intended to silently ignore missing JSON files. However, the old logic was also silently ignoring not-exist errors from the os.Stat(hook.Hook.Path) from 68eb128f (pkg/hooks: Version the hook structure and add 1.0.0 hooks, 2018-04-27, #686). This commit adjusts the check so JSON not-exist errors continue to be silently ignored while hook executable not-exist errors become fatal. Signed-off-by: W. Trevor King <wking@tremily.us> Closes: #887 Approved by: rhatdan
Diffstat (limited to 'pkg/hooks/read.go')
-rw-r--r--pkg/hooks/read.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/pkg/hooks/read.go b/pkg/hooks/read.go
index ae34913b6..a8c9a7adc 100644
--- a/pkg/hooks/read.go
+++ b/pkg/hooks/read.go
@@ -67,13 +67,16 @@ func ReadDir(path string, extensionStages []string, hooks map[string]*current.Ho
}
for _, file := range files {
- hook, err := Read(filepath.Join(path, file.Name()), extensionStages)
+ filePath := filepath.Join(path, file.Name())
+ hook, err := Read(filePath, extensionStages)
if err != nil {
if err == ErrNoJSONSuffix {
continue
}
if os.IsNotExist(err) {
- continue
+ if err2, ok := err.(*os.PathError); ok && err2.Path == filePath {
+ continue
+ }
}
return err
}