aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-09-22 14:39:36 +0200
committerValentin Rothberg <rothberg@redhat.com>2020-09-22 14:44:09 +0200
commitfed1ecf470f85d68527498b029252d26c43f50ef (patch)
treea61a2ae6bc195d8e56cd1097de22cb0b04cb93b6 /pkg
parent1921a82a91fe9536226092844ebb17c740824b65 (diff)
downloadpodman-fed1ecf470f85d68527498b029252d26c43f50ef.tar.gz
podman-fed1ecf470f85d68527498b029252d26c43f50ef.tar.bz2
podman-fed1ecf470f85d68527498b029252d26c43f50ef.zip
pkg/hooks: support all hooks
Add support for the missing hook types [1]: - createContainer - createRuntime - startContainer Otherwise, Podman won't inject them into the runtime config (and pass it on to runc/crun) but error out. [1] https://github.com/opencontainers/runtime-spec/blob/44341cdd36f6fee6ddd73e602f9e3eca1466052f/runtime.md#lifecycle Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/hooks/1.0.0/hook.go9
-rw-r--r--pkg/hooks/hooks.go6
2 files changed, 14 insertions, 1 deletions
diff --git a/pkg/hooks/1.0.0/hook.go b/pkg/hooks/1.0.0/hook.go
index 77fbab5aa..244e8800f 100644
--- a/pkg/hooks/1.0.0/hook.go
+++ b/pkg/hooks/1.0.0/hook.go
@@ -67,7 +67,14 @@ func (hook *Hook) Validate(extensionStages []string) (err error) {
return errors.New("missing required property: stages")
}
- validStages := map[string]bool{"prestart": true, "poststart": true, "poststop": true}
+ validStages := map[string]bool{
+ "createContainer": true,
+ "createRuntime": true,
+ "prestart": true,
+ "poststart": true,
+ "poststop": true,
+ "startContainer": true,
+ }
for _, stage := range extensionStages {
validStages[stage] = true
}
diff --git a/pkg/hooks/hooks.go b/pkg/hooks/hooks.go
index 2a12eceac..6257529ab 100644
--- a/pkg/hooks/hooks.go
+++ b/pkg/hooks/hooks.go
@@ -120,12 +120,18 @@ func (m *Manager) Hooks(config *rspec.Spec, annotations map[string]string, hasBi
extensionStageHooks[stage] = append(extensionStageHooks[stage], namedHook.hook.Hook)
} else {
switch stage {
+ case "createContainer":
+ config.Hooks.CreateContainer = append(config.Hooks.CreateContainer, namedHook.hook.Hook)
+ case "createRuntime":
+ config.Hooks.CreateRuntime = append(config.Hooks.CreateRuntime, namedHook.hook.Hook)
case "prestart":
config.Hooks.Prestart = append(config.Hooks.Prestart, namedHook.hook.Hook)
case "poststart":
config.Hooks.Poststart = append(config.Hooks.Poststart, namedHook.hook.Hook)
case "poststop":
config.Hooks.Poststop = append(config.Hooks.Poststop, namedHook.hook.Hook)
+ case "startContainer":
+ config.Hooks.StartContainer = append(config.Hooks.StartContainer, namedHook.hook.Hook)
default:
return extensionStageHooks, fmt.Errorf("hook %q: unknown stage %q", namedHook.name, stage)
}