From: Gabe Rosenhouse Date: Thu, 14 Jul 2016 02:54:22 +0000 (-0400) Subject: pkg/skel: improve error message for missing CNI_COMMAND env var X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=eda79f7645de017ad5e13e506ecbfbf7cc8ffd02;p=plugins.git pkg/skel: improve error message for missing CNI_COMMAND env var This makes the error message for missing CNI_COMMAND consistent with that of other required environment variables. --- diff --git a/skel/skel.go b/skel/skel.go index bed405c..4325ec6 100644 --- a/skel/skel.go +++ b/skel/skel.go @@ -106,9 +106,11 @@ func (t *dispatcher) getCmdArgsFromEnv() (string, *CmdArgs, error) { argsMissing := false for _, v := range vars { *v.val = t.Getenv(v.name) - if v.reqForCmd[cmd] && *v.val == "" { - fmt.Fprintf(t.Stderr, "%v env variable missing\n", v.name) - argsMissing = true + if *v.val == "" { + if v.reqForCmd[cmd] || v.name == "CNI_COMMAND" { + fmt.Fprintf(t.Stderr, "%v env variable missing\n", v.name) + argsMissing = true + } } } diff --git a/skel/skel_test.go b/skel/skel_test.go index 9974c9a..39df271 100644 --- a/skel/skel_test.go +++ b/skel/skel_test.go @@ -115,7 +115,7 @@ var _ = Describe("dispatching to the correct callback", func() { }) DescribeTable("required / optional env vars", envVarChecker, - // TODO: Entry("command", "CNI_COMMAND", true), + Entry("command", "CNI_COMMAND", true), Entry("container id", "CNI_CONTAINER_ID", false), Entry("net ns", "CNI_NETNS", true), Entry("if name", "CNI_IFNAME", true), @@ -162,7 +162,7 @@ var _ = Describe("dispatching to the correct callback", func() { }) DescribeTable("required / optional env vars", envVarChecker, - // TODO: Entry("command", "CNI_COMMAND", true), + Entry("command", "CNI_COMMAND", true), Entry("container id", "CNI_CONTAINER_ID", false), Entry("net ns", "CNI_NETNS", false), Entry("if name", "CNI_IFNAME", true),