diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 16d8fa4cd9..fd7fc87a14 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -8,68 +8,68 @@ "Deps": [ { "ImportPath": "github.com/containernetworking/cni/pkg/invoke", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/ip", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/ipam", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/ns", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/skel", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/testutils", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/types", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/types/020", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/types/current", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/utils", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/utils/hwaddr", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/utils/sysctl", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/containernetworking/cni/pkg/version", - "Comment": "v0.5.0", - "Rev": "1a9288c3c09cea4e580fdb1a636f1c5e185a391f" + "Comment": "v0.5.2", + "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" }, { "ImportPath": "github.com/coreos/go-iptables/iptables", diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/exec_test.go b/vendor/github.com/containernetworking/cni/pkg/invoke/exec_test.go deleted file mode 100644 index 33ffc2ded7..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/invoke/exec_test.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke_test - -import ( - "encoding/json" - "errors" - - "github.com/containernetworking/cni/pkg/invoke" - "github.com/containernetworking/cni/pkg/invoke/fakes" - "github.com/containernetworking/cni/pkg/types/current" - "github.com/containernetworking/cni/pkg/version" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Executing a plugin, unit tests", func() { - var ( - pluginExec *invoke.PluginExec - rawExec *fakes.RawExec - versionDecoder *fakes.VersionDecoder - - pluginPath string - netconf []byte - cniargs *fakes.CNIArgs - ) - - BeforeEach(func() { - rawExec = &fakes.RawExec{} - rawExec.ExecPluginCall.Returns.ResultBytes = []byte(`{ "ips": [ { "version": "4", "address": "1.2.3.4/24" } ] }`) - - versionDecoder = &fakes.VersionDecoder{} - versionDecoder.DecodeCall.Returns.PluginInfo = version.PluginSupports("0.42.0") - - pluginExec = &invoke.PluginExec{ - RawExec: rawExec, - VersionDecoder: versionDecoder, - } - pluginPath = "/some/plugin/path" - netconf = []byte(`{ "some": "stdin", "cniVersion": "0.3.1" }`) - cniargs = &fakes.CNIArgs{} - cniargs.AsEnvCall.Returns.Env = []string{"SOME=ENV"} - }) - - Describe("returning a result", func() { - It("unmarshals the result bytes into the Result type", func() { - r, err := pluginExec.WithResult(pluginPath, netconf, cniargs) - Expect(err).NotTo(HaveOccurred()) - - result, err := current.GetResult(r) - Expect(err).NotTo(HaveOccurred()) - Expect(len(result.IPs)).To(Equal(1)) - Expect(result.IPs[0].Address.IP.String()).To(Equal("1.2.3.4")) - }) - - It("passes its arguments through to the rawExec", func() { - pluginExec.WithResult(pluginPath, netconf, cniargs) - Expect(rawExec.ExecPluginCall.Received.PluginPath).To(Equal(pluginPath)) - Expect(rawExec.ExecPluginCall.Received.StdinData).To(Equal(netconf)) - Expect(rawExec.ExecPluginCall.Received.Environ).To(Equal([]string{"SOME=ENV"})) - }) - - Context("when the rawExec fails", func() { - BeforeEach(func() { - rawExec.ExecPluginCall.Returns.Error = errors.New("banana") - }) - It("returns the error", func() { - _, err := pluginExec.WithResult(pluginPath, netconf, cniargs) - Expect(err).To(MatchError("banana")) - }) - }) - }) - - Describe("without returning a result", func() { - It("passes its arguments through to the rawExec", func() { - pluginExec.WithoutResult(pluginPath, netconf, cniargs) - Expect(rawExec.ExecPluginCall.Received.PluginPath).To(Equal(pluginPath)) - Expect(rawExec.ExecPluginCall.Received.StdinData).To(Equal(netconf)) - Expect(rawExec.ExecPluginCall.Received.Environ).To(Equal([]string{"SOME=ENV"})) - }) - - Context("when the rawExec fails", func() { - BeforeEach(func() { - rawExec.ExecPluginCall.Returns.Error = errors.New("banana") - }) - It("returns the error", func() { - err := pluginExec.WithoutResult(pluginPath, netconf, cniargs) - Expect(err).To(MatchError("banana")) - }) - }) - }) - - Describe("discovering the plugin version", func() { - BeforeEach(func() { - rawExec.ExecPluginCall.Returns.ResultBytes = []byte(`{ "some": "version-info" }`) - }) - - It("execs the plugin with the command VERSION", func() { - pluginExec.GetVersionInfo(pluginPath) - Expect(rawExec.ExecPluginCall.Received.PluginPath).To(Equal(pluginPath)) - Expect(rawExec.ExecPluginCall.Received.Environ).To(ContainElement("CNI_COMMAND=VERSION")) - expectedStdin, _ := json.Marshal(map[string]string{"cniVersion": version.Current()}) - Expect(rawExec.ExecPluginCall.Received.StdinData).To(MatchJSON(expectedStdin)) - }) - - It("decodes and returns the version info", func() { - versionInfo, err := pluginExec.GetVersionInfo(pluginPath) - Expect(err).NotTo(HaveOccurred()) - Expect(versionInfo.SupportedVersions()).To(Equal([]string{"0.42.0"})) - Expect(versionDecoder.DecodeCall.Received.JSONBytes).To(MatchJSON(`{ "some": "version-info" }`)) - }) - - Context("when the rawExec fails", func() { - BeforeEach(func() { - rawExec.ExecPluginCall.Returns.Error = errors.New("banana") - }) - It("returns the error", func() { - _, err := pluginExec.GetVersionInfo(pluginPath) - Expect(err).To(MatchError("banana")) - }) - }) - - Context("when the plugin is too old to recognize the VERSION command", func() { - BeforeEach(func() { - rawExec.ExecPluginCall.Returns.Error = errors.New("unknown CNI_COMMAND: VERSION") - }) - - It("interprets the error as a 0.1.0 version", func() { - versionInfo, err := pluginExec.GetVersionInfo(pluginPath) - Expect(err).NotTo(HaveOccurred()) - Expect(versionInfo.SupportedVersions()).To(ConsistOf("0.1.0")) - }) - - It("sets dummy values for env vars required by very old plugins", func() { - pluginExec.GetVersionInfo(pluginPath) - - env := rawExec.ExecPluginCall.Received.Environ - Expect(env).To(ContainElement("CNI_NETNS=dummy")) - Expect(env).To(ContainElement("CNI_IFNAME=dummy")) - Expect(env).To(ContainElement("CNI_PATH=dummy")) - }) - }) - }) -}) diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/fakes/cni_args.go b/vendor/github.com/containernetworking/cni/pkg/invoke/fakes/cni_args.go deleted file mode 100644 index 5b1ba29e7c..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/invoke/fakes/cni_args.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package fakes - -type CNIArgs struct { - AsEnvCall struct { - Returns struct { - Env []string - } - } -} - -func (a *CNIArgs) AsEnv() []string { - return a.AsEnvCall.Returns.Env -} diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/fakes/raw_exec.go b/vendor/github.com/containernetworking/cni/pkg/invoke/fakes/raw_exec.go deleted file mode 100644 index 5432cdf763..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/invoke/fakes/raw_exec.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package fakes - -type RawExec struct { - ExecPluginCall struct { - Received struct { - PluginPath string - StdinData []byte - Environ []string - } - Returns struct { - ResultBytes []byte - Error error - } - } -} - -func (e *RawExec) ExecPlugin(pluginPath string, stdinData []byte, environ []string) ([]byte, error) { - e.ExecPluginCall.Received.PluginPath = pluginPath - e.ExecPluginCall.Received.StdinData = stdinData - e.ExecPluginCall.Received.Environ = environ - return e.ExecPluginCall.Returns.ResultBytes, e.ExecPluginCall.Returns.Error -} diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/fakes/version_decoder.go b/vendor/github.com/containernetworking/cni/pkg/invoke/fakes/version_decoder.go deleted file mode 100644 index 72d29733a3..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/invoke/fakes/version_decoder.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package fakes - -import "github.com/containernetworking/cni/pkg/version" - -type VersionDecoder struct { - DecodeCall struct { - Received struct { - JSONBytes []byte - } - Returns struct { - PluginInfo version.PluginInfo - Error error - } - } -} - -func (e *VersionDecoder) Decode(jsonData []byte) (version.PluginInfo, error) { - e.DecodeCall.Received.JSONBytes = jsonData - return e.DecodeCall.Returns.PluginInfo, e.DecodeCall.Returns.Error -} diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/find_test.go b/vendor/github.com/containernetworking/cni/pkg/invoke/find_test.go deleted file mode 100644 index 5854313100..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/invoke/find_test.go +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke_test - -import ( - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strings" - - "github.com/containernetworking/cni/pkg/invoke" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("FindInPath", func() { - var ( - multiplePaths []string - pluginName string - plugin2NameWithExt string - plugin2NameWithoutExt string - pluginDir string - anotherTempDir string - ) - - BeforeEach(func() { - tempDir, err := ioutil.TempDir("", "cni-find") - Expect(err).NotTo(HaveOccurred()) - - plugin, err := ioutil.TempFile(tempDir, "a-cni-plugin") - Expect(err).NotTo(HaveOccurred()) - - plugin2Name := "a-plugin-with-extension" + invoke.ExecutableFileExtensions[0] - plugin2, err := os.Create(filepath.Join(tempDir, plugin2Name)) - Expect(err).NotTo(HaveOccurred()) - - anotherTempDir, err = ioutil.TempDir("", "nothing-here") - Expect(err).NotTo(HaveOccurred()) - - multiplePaths = []string{anotherTempDir, tempDir} - pluginDir, pluginName = filepath.Split(plugin.Name()) - _, plugin2NameWithExt = filepath.Split(plugin2.Name()) - plugin2NameWithoutExt = strings.Split(plugin2NameWithExt, ".")[0] - }) - - AfterEach(func() { - os.RemoveAll(pluginDir) - os.RemoveAll(anotherTempDir) - }) - - Context("when multiple paths are provided", func() { - It("returns only the path to the plugin", func() { - pluginPath, err := invoke.FindInPath(pluginName, multiplePaths) - Expect(err).NotTo(HaveOccurred()) - Expect(pluginPath).To(Equal(filepath.Join(pluginDir, pluginName))) - }) - }) - - Context("when a plugin name without its file name extension is provided", func() { - It("returns the path to the plugin, including its extension", func() { - pluginPath, err := invoke.FindInPath(plugin2NameWithoutExt, multiplePaths) - Expect(err).NotTo(HaveOccurred()) - Expect(pluginPath).To(Equal(filepath.Join(pluginDir, plugin2NameWithExt))) - }) - }) - - Context("when an error occurs", func() { - Context("when no paths are provided", func() { - It("returns an error noting no paths were provided", func() { - _, err := invoke.FindInPath(pluginName, []string{}) - Expect(err).To(MatchError("no paths provided")) - }) - }) - - Context("when no plugin is provided", func() { - It("returns an error noting the plugin name wasn't found", func() { - _, err := invoke.FindInPath("", multiplePaths) - Expect(err).To(MatchError("no plugin name provided")) - }) - }) - - Context("when the plugin cannot be found", func() { - It("returns an error noting the path", func() { - pathsWithNothing := []string{anotherTempDir} - _, err := invoke.FindInPath(pluginName, pathsWithNothing) - Expect(err).To(MatchError(fmt.Sprintf("failed to find plugin %q in path %s", pluginName, pathsWithNothing))) - }) - }) - }) -}) diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/get_version_integration_test.go b/vendor/github.com/containernetworking/cni/pkg/invoke/get_version_integration_test.go deleted file mode 100644 index 7e58a9be3f..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/invoke/get_version_integration_test.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke_test - -import ( - "io/ioutil" - "os" - "path/filepath" - - "github.com/containernetworking/cni/pkg/invoke" - "github.com/containernetworking/cni/pkg/version" - "github.com/containernetworking/cni/pkg/version/testhelpers" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" - . "github.com/onsi/gomega" -) - -var _ = Describe("GetVersion, integration tests", func() { - var ( - pluginDir string - pluginPath string - ) - - BeforeEach(func() { - pluginDir, err := ioutil.TempDir("", "plugins") - Expect(err).NotTo(HaveOccurred()) - pluginPath = filepath.Join(pluginDir, "test-plugin") - }) - - AfterEach(func() { - Expect(os.RemoveAll(pluginDir)).To(Succeed()) - }) - - DescribeTable("correctly reporting plugin versions", - func(gitRef string, pluginSource string, expectedVersions version.PluginInfo) { - Expect(testhelpers.BuildAt([]byte(pluginSource), gitRef, pluginPath)).To(Succeed()) - versionInfo, err := invoke.GetVersionInfo(pluginPath) - Expect(err).NotTo(HaveOccurred()) - - Expect(versionInfo.SupportedVersions()).To(ConsistOf(expectedVersions.SupportedVersions())) - }, - - Entry("historical: before VERSION was introduced", - git_ref_v010, plugin_source_no_custom_versions, - version.PluginSupports("0.1.0"), - ), - - Entry("historical: when VERSION was introduced but plugins couldn't customize it", - git_ref_v020_no_custom_versions, plugin_source_no_custom_versions, - version.PluginSupports("0.1.0", "0.2.0"), - ), - - Entry("historical: when plugins started reporting their own version list", - git_ref_v020_custom_versions, plugin_source_v020_custom_versions, - version.PluginSupports("0.2.0", "0.999.0"), - ), - - // this entry tracks the current behavior. Before you change it, ensure - // that its previous behavior is captured in the most recent "historical" entry - Entry("current", - "HEAD", plugin_source_v020_custom_versions, - version.PluginSupports("0.2.0", "0.999.0"), - ), - ) -}) - -// a 0.2.0 plugin that can report its own versions -const plugin_source_v020_custom_versions = `package main - -import ( - "github.com/containernetworking/cni/pkg/skel" - "github.com/containernetworking/cni/pkg/version" - "fmt" -) - -func c(_ *skel.CmdArgs) error { fmt.Println("{}"); return nil } - -func main() { skel.PluginMain(c, c, version.PluginSupports("0.2.0", "0.999.0")) } -` -const git_ref_v020_custom_versions = "bf31ed15" - -// a minimal 0.1.0 / 0.2.0 plugin that cannot report it's own version support -const plugin_source_no_custom_versions = `package main - -import "github.com/containernetworking/cni/pkg/skel" -import "fmt" - -func c(_ *skel.CmdArgs) error { fmt.Println("{}"); return nil } - -func main() { skel.PluginMain(c, c) } -` - -const git_ref_v010 = "2c482f4" -const git_ref_v020_no_custom_versions = "349d66d" diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/invoke_suite_test.go b/vendor/github.com/containernetworking/cni/pkg/invoke/invoke_suite_test.go deleted file mode 100644 index 7285878a64..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/invoke/invoke_suite_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/onsi/gomega/gexec" - - "testing" -) - -func TestInvoke(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Invoke Suite") -} - -const packagePath = "github.com/containernetworking/cni/plugins/test/noop" - -var pathToPlugin string - -var _ = SynchronizedBeforeSuite(func() []byte { - var err error - pathToPlugin, err = gexec.Build(packagePath) - Expect(err).NotTo(HaveOccurred()) - return []byte(pathToPlugin) -}, func(crossNodeData []byte) { - pathToPlugin = string(crossNodeData) -}) - -var _ = SynchronizedAfterSuite(func() {}, func() { - gexec.CleanupBuildArtifacts() -}) diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/raw_exec_test.go b/vendor/github.com/containernetworking/cni/pkg/invoke/raw_exec_test.go deleted file mode 100644 index 5d759f2497..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/invoke/raw_exec_test.go +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke_test - -import ( - "bytes" - "io/ioutil" - "os" - - "github.com/containernetworking/cni/pkg/invoke" - - noop_debug "github.com/containernetworking/cni/plugins/test/noop/debug" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("RawExec", func() { - var ( - debugFileName string - debug *noop_debug.Debug - environ []string - stdin []byte - execer *invoke.RawExec - ) - - const reportResult = `{ "some": "result" }` - - BeforeEach(func() { - debugFile, err := ioutil.TempFile("", "cni_debug") - Expect(err).NotTo(HaveOccurred()) - Expect(debugFile.Close()).To(Succeed()) - debugFileName = debugFile.Name() - - debug = &noop_debug.Debug{ - ReportResult: reportResult, - ReportStderr: "some stderr message", - } - Expect(debug.WriteDebug(debugFileName)).To(Succeed()) - - environ = []string{ - "CNI_COMMAND=ADD", - "CNI_CONTAINERID=some-container-id", - "CNI_ARGS=DEBUG=" + debugFileName, - "CNI_NETNS=/some/netns/path", - "CNI_PATH=/some/bin/path", - "CNI_IFNAME=some-eth0", - } - stdin = []byte(`{"some":"stdin-json", "cniVersion": "0.3.1"}`) - execer = &invoke.RawExec{} - }) - - AfterEach(func() { - Expect(os.Remove(debugFileName)).To(Succeed()) - }) - - It("runs the plugin with the given stdin and environment", func() { - _, err := execer.ExecPlugin(pathToPlugin, stdin, environ) - Expect(err).NotTo(HaveOccurred()) - - debug, err := noop_debug.ReadDebug(debugFileName) - Expect(err).NotTo(HaveOccurred()) - Expect(debug.Command).To(Equal("ADD")) - Expect(debug.CmdArgs.StdinData).To(Equal(stdin)) - Expect(debug.CmdArgs.Netns).To(Equal("/some/netns/path")) - }) - - It("returns the resulting stdout as bytes", func() { - resultBytes, err := execer.ExecPlugin(pathToPlugin, stdin, environ) - Expect(err).NotTo(HaveOccurred()) - - Expect(resultBytes).To(BeEquivalentTo(reportResult)) - }) - - Context("when the Stderr writer is set", func() { - var stderrBuffer *bytes.Buffer - - BeforeEach(func() { - stderrBuffer = &bytes.Buffer{} - execer.Stderr = stderrBuffer - }) - - It("forwards any stderr bytes to the Stderr writer", func() { - _, err := execer.ExecPlugin(pathToPlugin, stdin, environ) - Expect(err).NotTo(HaveOccurred()) - - Expect(stderrBuffer.String()).To(Equal("some stderr message")) - }) - }) - - Context("when the plugin errors", func() { - BeforeEach(func() { - debug.ReportError = "banana" - Expect(debug.WriteDebug(debugFileName)).To(Succeed()) - }) - - It("wraps and returns the error", func() { - _, err := execer.ExecPlugin(pathToPlugin, stdin, environ) - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError("banana")) - }) - }) - - Context("when the system is unable to execute the plugin", func() { - It("returns the error", func() { - _, err := execer.ExecPlugin("/tmp/some/invalid/plugin/path", stdin, environ) - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(ContainSubstring("/tmp/some/invalid/plugin/path"))) - }) - }) -}) diff --git a/vendor/github.com/containernetworking/cni/pkg/ip/ip_suite_test.go b/vendor/github.com/containernetworking/cni/pkg/ip/ip_suite_test.go deleted file mode 100644 index 3fdd57e474..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/ip/ip_suite_test.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestIp(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Ip Suite") -} diff --git a/vendor/github.com/containernetworking/cni/pkg/ip/link_test.go b/vendor/github.com/containernetworking/cni/pkg/ip/link_test.go deleted file mode 100644 index 23182a5468..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/ip/link_test.go +++ /dev/null @@ -1,273 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip_test - -import ( - "bytes" - "crypto/rand" - "fmt" - "net" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/containernetworking/cni/pkg/ip" - "github.com/containernetworking/cni/pkg/ns" - - "github.com/vishvananda/netlink" - "github.com/vishvananda/netlink/nl" -) - -func getHwAddr(linkname string) string { - veth, err := netlink.LinkByName(linkname) - Expect(err).NotTo(HaveOccurred()) - return fmt.Sprintf("%s", veth.Attrs().HardwareAddr) -} - -var _ = Describe("Link", func() { - const ( - ifaceFormatString string = "i%d" - mtu int = 1400 - ip4onehwaddr = "0a:58:01:01:01:01" - ) - var ( - hostNetNS ns.NetNS - containerNetNS ns.NetNS - ifaceCounter int = 0 - hostVeth net.Interface - containerVeth net.Interface - hostVethName string - containerVethName string - - ip4one = net.ParseIP("1.1.1.1") - ip4two = net.ParseIP("1.1.1.2") - originalRandReader = rand.Reader - ) - - BeforeEach(func() { - var err error - - hostNetNS, err = ns.NewNS() - Expect(err).NotTo(HaveOccurred()) - - containerNetNS, err = ns.NewNS() - Expect(err).NotTo(HaveOccurred()) - - fakeBytes := make([]byte, 20) - //to be reset in AfterEach block - rand.Reader = bytes.NewReader(fakeBytes) - - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - hostVeth, containerVeth, err = ip.SetupVeth(fmt.Sprintf(ifaceFormatString, ifaceCounter), mtu, hostNetNS) - if err != nil { - return err - } - Expect(err).NotTo(HaveOccurred()) - - hostVethName = hostVeth.Name - containerVethName = containerVeth.Name - - return nil - }) - }) - - AfterEach(func() { - Expect(containerNetNS.Close()).To(Succeed()) - Expect(hostNetNS.Close()).To(Succeed()) - ifaceCounter++ - rand.Reader = originalRandReader - }) - - It("SetupVeth must put the veth endpoints into the separate namespaces", func() { - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - containerVethFromName, err := netlink.LinkByName(containerVethName) - Expect(err).NotTo(HaveOccurred()) - Expect(containerVethFromName.Attrs().Index).To(Equal(containerVeth.Index)) - - return nil - }) - - _ = hostNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - hostVethFromName, err := netlink.LinkByName(hostVethName) - Expect(err).NotTo(HaveOccurred()) - Expect(hostVethFromName.Attrs().Index).To(Equal(hostVeth.Index)) - - return nil - }) - }) - - Context("when container already has an interface with the same name", func() { - It("returns useful error", func() { - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - _, _, err := ip.SetupVeth(containerVethName, mtu, hostNetNS) - Expect(err.Error()).To(Equal(fmt.Sprintf("container veth name provided (%s) already exists", containerVethName))) - - return nil - }) - }) - }) - - Context("deleting an non-existent device", func() { - It("returns known error", func() { - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - // This string should match the expected error codes in the cmdDel functions of some of the plugins - _, err := ip.DelLinkByNameAddr("THIS_DONT_EXIST", netlink.FAMILY_V4) - Expect(err).To(Equal(ip.ErrLinkNotFound)) - - return nil - }) - }) - }) - - Context("when there is no name available for the host-side", func() { - BeforeEach(func() { - //adding different interface to container ns - containerVethName += "0" - }) - It("returns useful error", func() { - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - _, _, err := ip.SetupVeth(containerVethName, mtu, hostNetNS) - Expect(err.Error()).To(Equal("failed to move veth to host netns: file exists")) - - return nil - }) - }) - }) - - Context("when there is no name conflict for the host or container interfaces", func() { - BeforeEach(func() { - //adding different interface to container and host ns - containerVethName += "0" - rand.Reader = originalRandReader - }) - It("successfully creates the second veth pair", func() { - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - hostVeth, _, err := ip.SetupVeth(containerVethName, mtu, hostNetNS) - Expect(err).NotTo(HaveOccurred()) - hostVethName = hostVeth.Name - return nil - }) - - //verify veths are in different namespaces - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - _, err := netlink.LinkByName(containerVethName) - Expect(err).NotTo(HaveOccurred()) - - return nil - }) - - _ = hostNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - _, err := netlink.LinkByName(hostVethName) - Expect(err).NotTo(HaveOccurred()) - - return nil - }) - }) - - }) - - It("DelLinkByName must delete the veth endpoints", func() { - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - // this will delete the host endpoint too - err := ip.DelLinkByName(containerVethName) - Expect(err).NotTo(HaveOccurred()) - - _, err = netlink.LinkByName(containerVethName) - Expect(err).To(HaveOccurred()) - - return nil - }) - - _ = hostNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - _, err := netlink.LinkByName(hostVethName) - Expect(err).To(HaveOccurred()) - - return nil - }) - }) - - It("DelLinkByNameAddr must throw an error for configured interfaces", func() { - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - // this will delete the host endpoint too - addr, err := ip.DelLinkByNameAddr(containerVethName, nl.FAMILY_V4) - Expect(err).To(HaveOccurred()) - - var ipNetNil *net.IPNet - Expect(addr).To(Equal(ipNetNil)) - return nil - }) - }) - - It("SetHWAddrByIP must change the interface hwaddr and be predictable", func() { - - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - var err error - hwaddrBefore := getHwAddr(containerVethName) - - err = ip.SetHWAddrByIP(containerVethName, ip4one, nil) - Expect(err).NotTo(HaveOccurred()) - hwaddrAfter1 := getHwAddr(containerVethName) - - Expect(hwaddrBefore).NotTo(Equal(hwaddrAfter1)) - Expect(hwaddrAfter1).To(Equal(ip4onehwaddr)) - - return nil - }) - }) - - It("SetHWAddrByIP must be injective", func() { - - _ = containerNetNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - err := ip.SetHWAddrByIP(containerVethName, ip4one, nil) - Expect(err).NotTo(HaveOccurred()) - hwaddrAfter1 := getHwAddr(containerVethName) - - err = ip.SetHWAddrByIP(containerVethName, ip4two, nil) - Expect(err).NotTo(HaveOccurred()) - hwaddrAfter2 := getHwAddr(containerVethName) - - Expect(hwaddrAfter1).NotTo(Equal(hwaddrAfter2)) - return nil - }) - }) -}) diff --git a/vendor/github.com/containernetworking/cni/pkg/ipam/ipam_suite_test.go b/vendor/github.com/containernetworking/cni/pkg/ipam/ipam_suite_test.go deleted file mode 100644 index e80c86755d..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/ipam/ipam_suite_test.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ipam_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestIpam(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Ipam Suite") -} diff --git a/vendor/github.com/containernetworking/cni/pkg/ipam/ipam_test.go b/vendor/github.com/containernetworking/cni/pkg/ipam/ipam_test.go deleted file mode 100644 index 2d27825d5d..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/ipam/ipam_test.go +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ipam - -import ( - "net" - "syscall" - - "github.com/containernetworking/cni/pkg/ns" - "github.com/containernetworking/cni/pkg/types" - "github.com/containernetworking/cni/pkg/types/current" - - "github.com/vishvananda/netlink" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -const LINK_NAME = "eth0" - -func ipNetEqual(a, b *net.IPNet) bool { - aPrefix, aBits := a.Mask.Size() - bPrefix, bBits := b.Mask.Size() - if aPrefix != bPrefix || aBits != bBits { - return false - } - return a.IP.Equal(b.IP) -} - -var _ = Describe("IPAM Operations", func() { - var originalNS ns.NetNS - var ipv4, ipv6, routev4, routev6 *net.IPNet - var ipgw4, ipgw6, routegwv4, routegwv6 net.IP - var result *current.Result - - BeforeEach(func() { - // Create a new NetNS so we don't modify the host - var err error - originalNS, err = ns.NewNS() - Expect(err).NotTo(HaveOccurred()) - - err = originalNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - // Add master - err = netlink.LinkAdd(&netlink.Dummy{ - LinkAttrs: netlink.LinkAttrs{ - Name: LINK_NAME, - }, - }) - Expect(err).NotTo(HaveOccurred()) - _, err = netlink.LinkByName(LINK_NAME) - Expect(err).NotTo(HaveOccurred()) - return nil - }) - Expect(err).NotTo(HaveOccurred()) - - ipv4, err = types.ParseCIDR("1.2.3.30/24") - Expect(err).NotTo(HaveOccurred()) - Expect(ipv4).NotTo(BeNil()) - - _, routev4, err = net.ParseCIDR("15.5.6.8/24") - Expect(err).NotTo(HaveOccurred()) - Expect(routev4).NotTo(BeNil()) - routegwv4 = net.ParseIP("1.2.3.5") - Expect(routegwv4).NotTo(BeNil()) - - ipgw4 = net.ParseIP("1.2.3.1") - Expect(ipgw4).NotTo(BeNil()) - - ipv6, err = types.ParseCIDR("abcd:1234:ffff::cdde/64") - Expect(err).NotTo(HaveOccurred()) - Expect(ipv6).NotTo(BeNil()) - - _, routev6, err = net.ParseCIDR("1111:dddd::aaaa/80") - Expect(err).NotTo(HaveOccurred()) - Expect(routev6).NotTo(BeNil()) - routegwv6 = net.ParseIP("abcd:1234:ffff::10") - Expect(routegwv6).NotTo(BeNil()) - - ipgw6 = net.ParseIP("abcd:1234:ffff::1") - Expect(ipgw6).NotTo(BeNil()) - - result = ¤t.Result{ - Interfaces: []*current.Interface{ - { - Name: "eth0", - Mac: "00:11:22:33:44:55", - Sandbox: "/proc/3553/ns/net", - }, - { - Name: "fake0", - Mac: "00:33:44:55:66:77", - Sandbox: "/proc/1234/ns/net", - }, - }, - IPs: []*current.IPConfig{ - { - Version: "4", - Interface: 0, - Address: *ipv4, - Gateway: ipgw4, - }, - { - Version: "6", - Interface: 0, - Address: *ipv6, - Gateway: ipgw6, - }, - }, - Routes: []*types.Route{ - {Dst: *routev4, GW: routegwv4}, - {Dst: *routev6, GW: routegwv6}, - }, - } - }) - - AfterEach(func() { - Expect(originalNS.Close()).To(Succeed()) - }) - - It("configures a link with addresses and routes", func() { - err := originalNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - err := ConfigureIface(LINK_NAME, result) - Expect(err).NotTo(HaveOccurred()) - - link, err := netlink.LinkByName(LINK_NAME) - Expect(err).NotTo(HaveOccurred()) - Expect(link.Attrs().Name).To(Equal(LINK_NAME)) - - v4addrs, err := netlink.AddrList(link, syscall.AF_INET) - Expect(err).NotTo(HaveOccurred()) - Expect(len(v4addrs)).To(Equal(1)) - Expect(ipNetEqual(v4addrs[0].IPNet, ipv4)).To(Equal(true)) - - v6addrs, err := netlink.AddrList(link, syscall.AF_INET6) - Expect(err).NotTo(HaveOccurred()) - Expect(len(v6addrs)).To(Equal(2)) - - var found bool - for _, a := range v6addrs { - if ipNetEqual(a.IPNet, ipv6) { - found = true - break - } - } - Expect(found).To(Equal(true)) - - // Ensure the v4 route, v6 route, and subnet route - routes, err := netlink.RouteList(link, 0) - Expect(err).NotTo(HaveOccurred()) - - var v4found, v6found bool - for _, route := range routes { - isv4 := route.Dst.IP.To4() != nil - if isv4 && ipNetEqual(route.Dst, routev4) && route.Gw.Equal(routegwv4) { - v4found = true - } - if !isv4 && ipNetEqual(route.Dst, routev6) && route.Gw.Equal(routegwv6) { - v6found = true - } - - if v4found && v6found { - break - } - } - Expect(v4found).To(Equal(true)) - Expect(v6found).To(Equal(true)) - - return nil - }) - Expect(err).NotTo(HaveOccurred()) - }) - - It("configures a link with routes using address gateways", func() { - result.Routes[0].GW = nil - result.Routes[1].GW = nil - err := originalNS.Do(func(ns.NetNS) error { - defer GinkgoRecover() - - err := ConfigureIface(LINK_NAME, result) - Expect(err).NotTo(HaveOccurred()) - - link, err := netlink.LinkByName(LINK_NAME) - Expect(err).NotTo(HaveOccurred()) - Expect(link.Attrs().Name).To(Equal(LINK_NAME)) - - // Ensure the v4 route, v6 route, and subnet route - routes, err := netlink.RouteList(link, 0) - Expect(err).NotTo(HaveOccurred()) - - var v4found, v6found bool - for _, route := range routes { - isv4 := route.Dst.IP.To4() != nil - if isv4 && ipNetEqual(route.Dst, routev4) && route.Gw.Equal(ipgw4) { - v4found = true - } - if !isv4 && ipNetEqual(route.Dst, routev6) && route.Gw.Equal(ipgw6) { - v6found = true - } - - if v4found && v6found { - break - } - } - Expect(v4found).To(Equal(true)) - Expect(v6found).To(Equal(true)) - - return nil - }) - Expect(err).NotTo(HaveOccurred()) - }) - - It("returns an error when the interface index doesn't match the link name", func() { - result.IPs[0].Interface = 1 - err := originalNS.Do(func(ns.NetNS) error { - return ConfigureIface(LINK_NAME, result) - }) - Expect(err).To(HaveOccurred()) - }) - - It("returns an error when the interface index is too big", func() { - result.IPs[0].Interface = 2 - err := originalNS.Do(func(ns.NetNS) error { - return ConfigureIface(LINK_NAME, result) - }) - Expect(err).To(HaveOccurred()) - }) - - It("returns an error when there are no interfaces to configure", func() { - result.Interfaces = []*current.Interface{} - err := originalNS.Do(func(ns.NetNS) error { - return ConfigureIface(LINK_NAME, result) - }) - Expect(err).To(HaveOccurred()) - }) - - It("returns an error when configuring the wrong interface", func() { - err := originalNS.Do(func(ns.NetNS) error { - return ConfigureIface("asdfasdf", result) - }) - Expect(err).To(HaveOccurred()) - }) -}) diff --git a/vendor/github.com/containernetworking/cni/pkg/types/020/types.go b/vendor/github.com/containernetworking/cni/pkg/types/020/types.go index 2833aba787..666cfe93e7 100644 --- a/vendor/github.com/containernetworking/cni/pkg/types/020/types.go +++ b/vendor/github.com/containernetworking/cni/pkg/types/020/types.go @@ -23,9 +23,9 @@ import ( "github.com/containernetworking/cni/pkg/types" ) -const ImplementedSpecVersion string = "0.2.0" +const implementedSpecVersion string = "0.2.0" -var SupportedVersions = []string{"", "0.1.0", ImplementedSpecVersion} +var SupportedVersions = []string{"", "0.1.0", implementedSpecVersion} // Compatibility types for CNI version 0.1.0 and 0.2.0 @@ -39,7 +39,7 @@ func NewResult(data []byte) (types.Result, error) { func GetResult(r types.Result) (*Result, error) { // We expect version 0.1.0/0.2.0 results - result020, err := r.GetAsVersion(ImplementedSpecVersion) + result020, err := r.GetAsVersion(implementedSpecVersion) if err != nil { return nil, err } @@ -52,20 +52,18 @@ func GetResult(r types.Result) (*Result, error) { // Result is what gets returned from the plugin (via stdout) to the caller type Result struct { - CNIVersion string `json:"cniVersion,omitempty"` - IP4 *IPConfig `json:"ip4,omitempty"` - IP6 *IPConfig `json:"ip6,omitempty"` - DNS types.DNS `json:"dns,omitempty"` + IP4 *IPConfig `json:"ip4,omitempty"` + IP6 *IPConfig `json:"ip6,omitempty"` + DNS types.DNS `json:"dns,omitempty"` } func (r *Result) Version() string { - return ImplementedSpecVersion + return implementedSpecVersion } func (r *Result) GetAsVersion(version string) (types.Result, error) { for _, supportedVersion := range SupportedVersions { if version == supportedVersion { - r.CNIVersion = version return r, nil } } diff --git a/vendor/github.com/containernetworking/cni/pkg/types/current/types.go b/vendor/github.com/containernetworking/cni/pkg/types/current/types.go index b5715fe66c..b89a5d3a07 100644 --- a/vendor/github.com/containernetworking/cni/pkg/types/current/types.go +++ b/vendor/github.com/containernetworking/cni/pkg/types/current/types.go @@ -24,9 +24,9 @@ import ( "github.com/containernetworking/cni/pkg/types/020" ) -const ImplementedSpecVersion string = "0.3.1" +const implementedSpecVersion string = "0.3.1" -var SupportedVersions = []string{"0.3.0", ImplementedSpecVersion} +var SupportedVersions = []string{"0.3.0", implementedSpecVersion} func NewResult(data []byte) (types.Result, error) { result := &Result{} @@ -37,7 +37,7 @@ func NewResult(data []byte) (types.Result, error) { } func GetResult(r types.Result) (*Result, error) { - resultCurrent, err := r.GetAsVersion(ImplementedSpecVersion) + resultCurrent, err := r.GetAsVersion(implementedSpecVersion) if err != nil { return nil, err } @@ -63,9 +63,8 @@ func convertFrom020(result types.Result) (*Result, error) { } newResult := &Result{ - CNIVersion: ImplementedSpecVersion, - DNS: oldResult.DNS, - Routes: []*types.Route{}, + DNS: oldResult.DNS, + Routes: []*types.Route{}, } if oldResult.IP4 != nil { @@ -118,7 +117,6 @@ func convertFrom030(result types.Result) (*Result, error) { if !ok { return nil, fmt.Errorf("failed to convert result") } - newResult.CNIVersion = ImplementedSpecVersion return newResult, nil } @@ -136,7 +134,6 @@ func NewResultFromResult(result types.Result) (*Result, error) { // Result is what gets returned from the plugin (via stdout) to the caller type Result struct { - CNIVersion string `json:"cniVersion,omitempty"` Interfaces []*Interface `json:"interfaces,omitempty"` IPs []*IPConfig `json:"ips,omitempty"` Routes []*types.Route `json:"routes,omitempty"` @@ -146,8 +143,7 @@ type Result struct { // Convert to the older 0.2.0 CNI spec Result type func (r *Result) convertTo020() (*types020.Result, error) { oldResult := &types020.Result{ - CNIVersion: types020.ImplementedSpecVersion, - DNS: r.DNS, + DNS: r.DNS, } for _, ip := range r.IPs { @@ -193,13 +189,12 @@ func (r *Result) convertTo020() (*types020.Result, error) { } func (r *Result) Version() string { - return ImplementedSpecVersion + return implementedSpecVersion } func (r *Result) GetAsVersion(version string) (types.Result, error) { switch version { - case "0.3.0", ImplementedSpecVersion: - r.CNIVersion = version + case "0.3.0", implementedSpecVersion: return r, nil case types020.SupportedVersions[0], types020.SupportedVersions[1], types020.SupportedVersions[2]: return r.convertTo020() diff --git a/vendor/github.com/containernetworking/cni/pkg/utils/hwaddr/hwaddr_suite_test.go b/vendor/github.com/containernetworking/cni/pkg/utils/hwaddr/hwaddr_suite_test.go deleted file mode 100644 index e3bbfe97c1..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/utils/hwaddr/hwaddr_suite_test.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package hwaddr_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestHwaddr(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Hwaddr Suite") -} diff --git a/vendor/github.com/containernetworking/cni/pkg/utils/hwaddr/hwaddr_test.go b/vendor/github.com/containernetworking/cni/pkg/utils/hwaddr/hwaddr_test.go deleted file mode 100644 index b77ccd899a..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/utils/hwaddr/hwaddr_test.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package hwaddr_test - -import ( - "net" - - "github.com/containernetworking/cni/pkg/utils/hwaddr" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Hwaddr", func() { - Context("Generate Hardware Address", func() { - It("generate hardware address based on ipv4 address", func() { - testCases := []struct { - ip net.IP - expectedMAC net.HardwareAddr - }{ - { - ip: net.ParseIP("10.0.0.2"), - expectedMAC: (net.HardwareAddr)(append(hwaddr.PrivateMACPrefix, 0x0a, 0x00, 0x00, 0x02)), - }, - { - ip: net.ParseIP("10.250.0.244"), - expectedMAC: (net.HardwareAddr)(append(hwaddr.PrivateMACPrefix, 0x0a, 0xfa, 0x00, 0xf4)), - }, - { - ip: net.ParseIP("172.17.0.2"), - expectedMAC: (net.HardwareAddr)(append(hwaddr.PrivateMACPrefix, 0xac, 0x11, 0x00, 0x02)), - }, - { - ip: net.IPv4(byte(172), byte(17), byte(0), byte(2)), - expectedMAC: (net.HardwareAddr)(append(hwaddr.PrivateMACPrefix, 0xac, 0x11, 0x00, 0x02)), - }, - } - - for _, tc := range testCases { - mac, err := hwaddr.GenerateHardwareAddr4(tc.ip, hwaddr.PrivateMACPrefix) - Expect(err).NotTo(HaveOccurred()) - Expect(mac).To(Equal(tc.expectedMAC)) - } - }) - - It("return error if input is not ipv4 address", func() { - testCases := []net.IP{ - net.ParseIP(""), - net.ParseIP("2001:db8:0:1:1:1:1:1"), - } - for _, tc := range testCases { - _, err := hwaddr.GenerateHardwareAddr4(tc, hwaddr.PrivateMACPrefix) - Expect(err).To(BeAssignableToTypeOf(hwaddr.SupportIp4OnlyErr{})) - } - }) - - It("return error if prefix is invalid", func() { - _, err := hwaddr.GenerateHardwareAddr4(net.ParseIP("10.0.0.2"), []byte{0x58}) - Expect(err).To(BeAssignableToTypeOf(hwaddr.InvalidPrefixLengthErr{})) - }) - }) -}) diff --git a/vendor/github.com/containernetworking/cni/pkg/utils/utils_suite_test.go b/vendor/github.com/containernetworking/cni/pkg/utils/utils_suite_test.go deleted file mode 100644 index ee614a7078..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/utils/utils_suite_test.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package utils_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestUtils(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Utils Suite") -} diff --git a/vendor/github.com/containernetworking/cni/pkg/utils/utils_test.go b/vendor/github.com/containernetworking/cni/pkg/utils/utils_test.go deleted file mode 100644 index d703de423e..0000000000 --- a/vendor/github.com/containernetworking/cni/pkg/utils/utils_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package utils - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Utils", func() { - It("must format a short name", func() { - chain := FormatChainName("test", "1234") - Expect(len(chain)).To(Equal(maxChainLength)) - Expect(chain).To(Equal("CNI-2bbe0c48b91a7d1b8a6753a8")) - }) - - It("must truncate a long name", func() { - chain := FormatChainName("testalongnamethatdoesnotmakesense", "1234") - Expect(len(chain)).To(Equal(maxChainLength)) - Expect(chain).To(Equal("CNI-374f33fe84ab0ed84dcdebe3")) - }) - - It("must be predictable", func() { - chain1 := FormatChainName("testalongnamethatdoesnotmakesense", "1234") - chain2 := FormatChainName("testalongnamethatdoesnotmakesense", "1234") - Expect(len(chain1)).To(Equal(maxChainLength)) - Expect(len(chain2)).To(Equal(maxChainLength)) - Expect(chain1).To(Equal(chain2)) - }) - - It("must change when a character changes", func() { - chain1 := FormatChainName("testalongnamethatdoesnotmakesense", "1234") - chain2 := FormatChainName("testalongnamethatdoesnotmakesense", "1235") - Expect(len(chain1)).To(Equal(maxChainLength)) - Expect(len(chain2)).To(Equal(maxChainLength)) - Expect(chain1).To(Equal("CNI-374f33fe84ab0ed84dcdebe3")) - Expect(chain1).NotTo(Equal(chain2)) - }) -})