From 86869d1fc7f220afff32853bcc85ee1bc6715b7b Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Sat, 10 Feb 2018 13:24:19 +0800 Subject: [PATCH] validation: Increase err judgment Signed-off-by: Zhou Hao --- validation/poststart.go | 7 ++++--- validation/poststop.go | 7 ++++--- validation/prestart.go | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/validation/poststart.go b/validation/poststart.go index 6cf3c50c..d77fe1d7 100644 --- a/validation/poststart.go +++ b/validation/poststart.go @@ -27,14 +27,15 @@ func main() { r.SetID(uuid.NewV4().String()) g := util.GetDefaultGenerator() output = filepath.Join(r.BundleDir, g.Spec().Root.Path, "output") - poststart := rspec.Hook{ + err := g.AddPostStartHook(rspec.Hook{ Path: filepath.Join(r.BundleDir, g.Spec().Root.Path, "/bin/sh"), Args: []string{ "sh", "-c", fmt.Sprintf("echo 'post-start called' >> %s", output), }, + }) + if err != nil { + return err } - - g.AddPostStartHook(poststart) g.SetProcessArgs([]string{"sh", "-c", fmt.Sprintf("echo 'process called' >> %s", "/output")}) r.SetConfig(g) return nil diff --git a/validation/poststop.go b/validation/poststop.go index 39f4ca70..cebcf941 100644 --- a/validation/poststop.go +++ b/validation/poststop.go @@ -28,14 +28,15 @@ func main() { r.SetID(uuid.NewV4().String()) g := util.GetDefaultGenerator() output = filepath.Join(r.BundleDir, g.Spec().Root.Path, "output") - poststop := rspec.Hook{ + err := g.AddPostStopHook(rspec.Hook{ Path: filepath.Join(r.BundleDir, g.Spec().Root.Path, "/bin/sh"), Args: []string{ "sh", "-c", fmt.Sprintf("echo 'post-stop called' >> %s", output), }, + }) + if err != nil { + return err } - - g.AddPostStopHook(poststop) g.SetProcessArgs([]string{"sh", "-c", fmt.Sprintf("echo 'process called' >> %s", "/output")}) r.SetConfig(g) return nil diff --git a/validation/prestart.go b/validation/prestart.go index f2c86f49..83aee05e 100644 --- a/validation/prestart.go +++ b/validation/prestart.go @@ -26,14 +26,15 @@ func main() { r.SetID(uuid.NewV4().String()) g := util.GetDefaultGenerator() output = filepath.Join(r.BundleDir, g.Spec().Root.Path, "output") - prestart := rspec.Hook{ + err := g.AddPreStartHook(rspec.Hook{ Path: filepath.Join(r.BundleDir, g.Spec().Root.Path, "/bin/sh"), Args: []string{ "sh", "-c", fmt.Sprintf("echo 'pre-start called' >> %s", output), }, + }) + if err != nil { + return err } - - g.AddPreStartHook(prestart) g.SetProcessArgs([]string{"sh", "-c", fmt.Sprintf("echo 'process called' >> %s", "/output")}) r.SetConfig(g) return nil