Skip to content

Commit

Permalink
skel: print out CNI versions supported in help text.
Browse files Browse the repository at this point in the history
Signed-off-by: Casey Callendrello <cdc@redhat.com>
  • Loading branch information
squeed committed Sep 8, 2021
1 parent 1694fd7 commit 2e4887b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/skel/skel.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func (t *dispatcher) pluginMain(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error,
// Print the about string to stderr when no command is set
if err.Code == types.ErrInvalidEnvironmentVariables && t.Getenv("CNI_COMMAND") == "" && about != "" {
_, _ = fmt.Fprintln(t.Stderr, about)
_, _ = fmt.Fprintf(t.Stderr, "CNI protocol versions supported: %s\n", strings.Join(versionInfo.SupportedVersions(), ", "))
return nil
}
return err
Expand Down
8 changes: 4 additions & 4 deletions pkg/skel/skel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var _ = Describe("dispatching to the correct callback", func() {
stdinData = `{ "name":"skel-test", "some": "config", "cniVersion": "9.8.7" }`
stdout = &bytes.Buffer{}
stderr = &bytes.Buffer{}
versionInfo = version.PluginSupports("9.8.7")
versionInfo = version.PluginSupports("9.8.7", "10.0.0")
dispatch = &dispatcher{
Getenv: func(key string) string { return environment[key] },
Stdin: strings.NewReader(stdinData),
Expand Down Expand Up @@ -430,7 +430,7 @@ var _ = Describe("dispatching to the correct callback", func() {
Expect(err).NotTo(HaveOccurred())
Expect(stdout).To(MatchJSON(fmt.Sprintf(`{
"cniVersion": "%s",
"supportedVersions": ["9.8.7"]
"supportedVersions": ["9.8.7", "10.0.0"]
}`, current.ImplementedSpecVersion)))
})

Expand Down Expand Up @@ -461,7 +461,7 @@ var _ = Describe("dispatching to the correct callback", func() {
Expect(r.ReadCount).To(Equal(0))
Expect(stdout).To(MatchJSON(fmt.Sprintf(`{
"cniVersion": "%s",
"supportedVersions": ["9.8.7"]
"supportedVersions": ["9.8.7", "10.0.0"]
}`, current.ImplementedSpecVersion)))
})
})
Expand Down Expand Up @@ -503,7 +503,7 @@ var _ = Describe("dispatching to the correct callback", func() {
Expect(cmdAdd.CallCount).To(Equal(0))
Expect(cmdDel.CallCount).To(Equal(0))
log := stderr.String()
Expect(log).To(Equal("AWESOME PLUGIN\n"))
Expect(log).To(Equal("AWESOME PLUGIN\nCNI protocol versions supported: 9.8.7, 10.0.0\n"))
})

It("fails if there is no about string", func() {
Expand Down

0 comments on commit 2e4887b

Please sign in to comment.