From 9964fcde373f040de72fede569590a5e82b944ab Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Tue, 15 Sep 2015 18:21:07 -0400 Subject: [PATCH] hooks: Integrate spec hooks with libcontainer Signed-off-by: Mrunal Patel --- spec.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec.go b/spec.go index a27f67823..c216118af 100644 --- a/spec.go +++ b/spec.go @@ -391,6 +391,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 } @@ -653,3 +654,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)) + } +}