Skip to content

Commit

Permalink
hooks: Integrate spec hooks with libcontainer
Browse files Browse the repository at this point in the history
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
  • Loading branch information
mrunalp committed Sep 15, 2015
1 parent 4ab1324 commit f29794b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ func createLibcontainerConfig(cgroupName string, spec *specs.LinuxSpec, rspec *s
config.Sysctl = rspec.Linux.Sysctl
config.ProcessLabel = rspec.Linux.SelinuxProcessLabel
config.AppArmorProfile = rspec.Linux.ApparmorProfile
createHooks(rspec, config)
return config, nil
}

Expand Down Expand Up @@ -633,3 +634,23 @@ func setupSeccomp(config *specs.Seccomp) (*configs.Seccomp, error) {

return newConfig, nil
}

func createHooks(rspec *specs.LinuxRuntimeSpec, config *configs.Config) {
config.Hooks = &configs.Hooks{}
for _, h := range rspec.Hooks.Prestart {
cmd := configs.Command{
Path: h.Path,
Args: h.Args,
Env: h.Env,
}
config.Hooks.Prestart = append(config.Hooks.Prestart, configs.NewCommandHook(cmd))
}
for _, h := range rspec.Hooks.Poststop {
cmd := configs.Command{
Path: h.Path,
Args: h.Args,
Env: h.Env,
}
config.Hooks.Poststop = append(config.Hooks.Poststop, configs.NewCommandHook(cmd))
}
}

0 comments on commit f29794b

Please sign in to comment.