mirror of
https://github.com/containers/podman.git
synced 2025-05-21 00:56:36 +08:00
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] 44341cdd36/runtime.md (lifecycle)
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -67,7 +67,14 @@ func (hook *Hook) Validate(extensionStages []string) (err error) {
|
|||||||
return errors.New("missing required property: stages")
|
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 {
|
for _, stage := range extensionStages {
|
||||||
validStages[stage] = true
|
validStages[stage] = true
|
||||||
}
|
}
|
||||||
|
@ -120,12 +120,18 @@ func (m *Manager) Hooks(config *rspec.Spec, annotations map[string]string, hasBi
|
|||||||
extensionStageHooks[stage] = append(extensionStageHooks[stage], namedHook.hook.Hook)
|
extensionStageHooks[stage] = append(extensionStageHooks[stage], namedHook.hook.Hook)
|
||||||
} else {
|
} else {
|
||||||
switch stage {
|
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":
|
case "prestart":
|
||||||
config.Hooks.Prestart = append(config.Hooks.Prestart, namedHook.hook.Hook)
|
config.Hooks.Prestart = append(config.Hooks.Prestart, namedHook.hook.Hook)
|
||||||
case "poststart":
|
case "poststart":
|
||||||
config.Hooks.Poststart = append(config.Hooks.Poststart, namedHook.hook.Hook)
|
config.Hooks.Poststart = append(config.Hooks.Poststart, namedHook.hook.Hook)
|
||||||
case "poststop":
|
case "poststop":
|
||||||
config.Hooks.Poststop = append(config.Hooks.Poststop, namedHook.hook.Hook)
|
config.Hooks.Poststop = append(config.Hooks.Poststop, namedHook.hook.Hook)
|
||||||
|
case "startContainer":
|
||||||
|
config.Hooks.StartContainer = append(config.Hooks.StartContainer, namedHook.hook.Hook)
|
||||||
default:
|
default:
|
||||||
return extensionStageHooks, fmt.Errorf("hook %q: unknown stage %q", namedHook.name, stage)
|
return extensionStageHooks, fmt.Errorf("hook %q: unknown stage %q", namedHook.name, stage)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user