mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Add version to HookState to make it json-compatible with spec State
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
@@ -173,6 +173,9 @@ type Config struct {
|
|||||||
// Hooks are a collection of actions to perform at various container lifecycle events.
|
// Hooks are a collection of actions to perform at various container lifecycle events.
|
||||||
// Hooks are not able to be marshaled to json but they are also not needed to.
|
// Hooks are not able to be marshaled to json but they are also not needed to.
|
||||||
Hooks *Hooks `json:"-"`
|
Hooks *Hooks `json:"-"`
|
||||||
|
|
||||||
|
// Version is the version of opencontainer specification that is supported.
|
||||||
|
Version string `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Hooks struct {
|
type Hooks struct {
|
||||||
@@ -186,9 +189,10 @@ type Hooks struct {
|
|||||||
|
|
||||||
// HookState is the payload provided to a hook on execution.
|
// HookState is the payload provided to a hook on execution.
|
||||||
type HookState struct {
|
type HookState struct {
|
||||||
ID string `json:"id"`
|
Version string `json:"version"`
|
||||||
Pid int `json:"pid"`
|
ID string `json:"id"`
|
||||||
Root string `json:"root"`
|
Pid int `json:"pid"`
|
||||||
|
Root string `json:"root"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Hook interface {
|
type Hook interface {
|
||||||
|
|||||||
@@ -250,8 +250,9 @@ func (c *linuxContainer) Destroy() error {
|
|||||||
c.initProcess = nil
|
c.initProcess = nil
|
||||||
if c.config.Hooks != nil {
|
if c.config.Hooks != nil {
|
||||||
s := configs.HookState{
|
s := configs.HookState{
|
||||||
ID: c.id,
|
Version: c.config.Version,
|
||||||
Root: c.config.Rootfs,
|
ID: c.id,
|
||||||
|
Root: c.config.Rootfs,
|
||||||
}
|
}
|
||||||
for _, hook := range c.config.Hooks.Poststop {
|
for _, hook := range c.config.Hooks.Poststop {
|
||||||
if err := hook.Run(s); err != nil {
|
if err := hook.Run(s); err != nil {
|
||||||
|
|||||||
@@ -203,9 +203,10 @@ func (p *initProcess) start() (err error) {
|
|||||||
}()
|
}()
|
||||||
if p.config.Config.Hooks != nil {
|
if p.config.Config.Hooks != nil {
|
||||||
s := configs.HookState{
|
s := configs.HookState{
|
||||||
ID: p.container.id,
|
Version: p.container.config.Version,
|
||||||
Pid: p.pid(),
|
ID: p.container.id,
|
||||||
Root: p.config.Config.Rootfs,
|
Pid: p.pid(),
|
||||||
|
Root: p.config.Config.Rootfs,
|
||||||
}
|
}
|
||||||
for _, hook := range p.config.Config.Hooks.Prestart {
|
for _, hook := range p.config.Config.Hooks.Prestart {
|
||||||
if err := hook.Run(s); err != nil {
|
if err := hook.Run(s); err != nil {
|
||||||
|
|||||||
@@ -392,6 +392,7 @@ func createLibcontainerConfig(cgroupName string, spec *specs.LinuxSpec, rspec *s
|
|||||||
config.ProcessLabel = rspec.Linux.SelinuxProcessLabel
|
config.ProcessLabel = rspec.Linux.SelinuxProcessLabel
|
||||||
config.AppArmorProfile = rspec.Linux.ApparmorProfile
|
config.AppArmorProfile = rspec.Linux.ApparmorProfile
|
||||||
createHooks(rspec, config)
|
createHooks(rspec, config)
|
||||||
|
config.Version = specs.Version
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user