summaryrefslogtreecommitdiff
path: root/vendor/github.com/containernetworking
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/containernetworking')
-rw-r--r--vendor/github.com/containernetworking/cni/LICENSE202
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/skel/skel.go307
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/types/020/types.go140
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/types/args.go112
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/types/current/types.go293
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/types/types.go199
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/version/conf.go37
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/version/plugin.go144
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/version/reconcile.go49
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/version/version.go83
-rw-r--r--vendor/github.com/containernetworking/plugins/LICENSE201
-rw-r--r--vendor/github.com/containernetworking/plugins/pkg/ns/README.md41
-rw-r--r--vendor/github.com/containernetworking/plugins/pkg/ns/ns_linux.go216
-rw-r--r--vendor/github.com/containernetworking/plugins/pkg/testutils/bad_reader.go33
-rw-r--r--vendor/github.com/containernetworking/plugins/pkg/testutils/cmd.go112
-rw-r--r--vendor/github.com/containernetworking/plugins/pkg/testutils/netns_linux.go157
-rw-r--r--vendor/github.com/containernetworking/plugins/pkg/testutils/ping.go55
-rw-r--r--vendor/github.com/containernetworking/plugins/pkg/utils/buildversion/buildversion.go26
-rw-r--r--vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk/backend.go209
-rw-r--r--vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk/lock.go59
-rw-r--r--vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/store.go28
21 files changed, 0 insertions, 2703 deletions
diff --git a/vendor/github.com/containernetworking/cni/LICENSE b/vendor/github.com/containernetworking/cni/LICENSE
deleted file mode 100644
index 8f71f43..0000000
--- a/vendor/github.com/containernetworking/cni/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- 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.
-
diff --git a/vendor/github.com/containernetworking/cni/pkg/skel/skel.go b/vendor/github.com/containernetworking/cni/pkg/skel/skel.go
deleted file mode 100644
index af56b8a..0000000
--- a/vendor/github.com/containernetworking/cni/pkg/skel/skel.go
+++ /dev/null
@@ -1,307 +0,0 @@
-// Copyright 2014-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 skel provides skeleton code for a CNI plugin.
-// In particular, it implements argument parsing and validation.
-package skel
-
-import (
- "bytes"
- "encoding/json"
- "fmt"
- "io"
- "io/ioutil"
- "log"
- "os"
- "strings"
-
- "github.com/containernetworking/cni/pkg/types"
- "github.com/containernetworking/cni/pkg/version"
-)
-
-// CmdArgs captures all the arguments passed in to the plugin
-// via both env vars and stdin
-type CmdArgs struct {
- ContainerID string
- Netns string
- IfName string
- Args string
- Path string
- StdinData []byte
-}
-
-type dispatcher struct {
- Getenv func(string) string
- Stdin io.Reader
- Stdout io.Writer
- Stderr io.Writer
-
- ConfVersionDecoder version.ConfigDecoder
- VersionReconciler version.Reconciler
-}
-
-type reqForCmdEntry map[string]bool
-
-// internal only error to indicate lack of required environment variables
-type missingEnvError struct {
- msg string
-}
-
-func (e missingEnvError) Error() string {
- return e.msg
-}
-
-func (t *dispatcher) getCmdArgsFromEnv() (string, *CmdArgs, error) {
- var cmd, contID, netns, ifName, args, path string
-
- vars := []struct {
- name string
- val *string
- reqForCmd reqForCmdEntry
- }{
- {
- "CNI_COMMAND",
- &cmd,
- reqForCmdEntry{
- "ADD": true,
- "CHECK": true,
- "DEL": true,
- },
- },
- {
- "CNI_CONTAINERID",
- &contID,
- reqForCmdEntry{
- "ADD": true,
- "CHECK": true,
- "DEL": true,
- },
- },
- {
- "CNI_NETNS",
- &netns,
- reqForCmdEntry{
- "ADD": true,
- "CHECK": true,
- "DEL": false,
- },
- },
- {
- "CNI_IFNAME",
- &ifName,
- reqForCmdEntry{
- "ADD": true,
- "CHECK": true,
- "DEL": true,
- },
- },
- {
- "CNI_ARGS",
- &args,
- reqForCmdEntry{
- "ADD": false,
- "CHECK": false,
- "DEL": false,
- },
- },
- {
- "CNI_PATH",
- &path,
- reqForCmdEntry{
- "ADD": true,
- "CHECK": true,
- "DEL": true,
- },
- },
- }
-
- argsMissing := make([]string, 0)
- for _, v := range vars {
- *v.val = t.Getenv(v.name)
- if *v.val == "" {
- if v.reqForCmd[cmd] || v.name == "CNI_COMMAND" {
- argsMissing = append(argsMissing, v.name)
- }
- }
- }
-
- if len(argsMissing) > 0 {
- joined := strings.Join(argsMissing, ",")
- return "", nil, missingEnvError{fmt.Sprintf("required env variables [%s] missing", joined)}
- }
-
- if cmd == "VERSION" {
- t.Stdin = bytes.NewReader(nil)
- }
-
- stdinData, err := ioutil.ReadAll(t.Stdin)
- if err != nil {
- return "", nil, fmt.Errorf("error reading from stdin: %v", err)
- }
-
- cmdArgs := &CmdArgs{
- ContainerID: contID,
- Netns: netns,
- IfName: ifName,
- Args: args,
- Path: path,
- StdinData: stdinData,
- }
- return cmd, cmdArgs, nil
-}
-
-func createTypedError(f string, args ...interface{}) *types.Error {
- return &types.Error{
- Code: 100,
- Msg: fmt.Sprintf(f, args...),
- }
-}
-
-func (t *dispatcher) checkVersionAndCall(cmdArgs *CmdArgs, pluginVersionInfo version.PluginInfo, toCall func(*CmdArgs) error) error {
- configVersion, err := t.ConfVersionDecoder.Decode(cmdArgs.StdinData)
- if err != nil {
- return err
- }
- verErr := t.VersionReconciler.Check(configVersion, pluginVersionInfo)
- if verErr != nil {
- return &types.Error{
- Code: types.ErrIncompatibleCNIVersion,
- Msg: "incompatible CNI versions",
- Details: verErr.Details(),
- }
- }
-
- return toCall(cmdArgs)
-}
-
-func validateConfig(jsonBytes []byte) error {
- var conf struct {
- Name string `json:"name"`
- }
- if err := json.Unmarshal(jsonBytes, &conf); err != nil {
- return fmt.Errorf("error reading network config: %s", err)
- }
- if conf.Name == "" {
- return fmt.Errorf("missing network name")
- }
- return nil
-}
-
-func (t *dispatcher) pluginMain(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error, versionInfo version.PluginInfo, about string) *types.Error {
- cmd, cmdArgs, err := t.getCmdArgsFromEnv()
- if err != nil {
- // Print the about string to stderr when no command is set
- if _, ok := err.(missingEnvError); ok && t.Getenv("CNI_COMMAND") == "" && about != "" {
- fmt.Fprintln(t.Stderr, about)
- return nil
- }
- return createTypedError(err.Error())
- }
-
- if cmd != "VERSION" {
- err = validateConfig(cmdArgs.StdinData)
- if err != nil {
- return createTypedError(err.Error())
- }
- }
-
- switch cmd {
- case "ADD":
- err = t.checkVersionAndCall(cmdArgs, versionInfo, cmdAdd)
- case "CHECK":
- configVersion, err := t.ConfVersionDecoder.Decode(cmdArgs.StdinData)
- if err != nil {
- return createTypedError(err.Error())
- }
- if gtet, err := version.GreaterThanOrEqualTo(configVersion, "0.4.0"); err != nil {
- return createTypedError(err.Error())
- } else if !gtet {
- return &types.Error{
- Code: types.ErrIncompatibleCNIVersion,
- Msg: "config version does not allow CHECK",
- }
- }
- for _, pluginVersion := range versionInfo.SupportedVersions() {
- gtet, err := version.GreaterThanOrEqualTo(pluginVersion, configVersion)
- if err != nil {
- return createTypedError(err.Error())
- } else if gtet {
- if err := t.checkVersionAndCall(cmdArgs, versionInfo, cmdCheck); err != nil {
- return createTypedError(err.Error())
- }
- return nil
- }
- }
- return &types.Error{
- Code: types.ErrIncompatibleCNIVersion,
- Msg: "plugin version does not allow CHECK",
- }
- case "DEL":
- err = t.checkVersionAndCall(cmdArgs, versionInfo, cmdDel)
- case "VERSION":
- err = versionInfo.Encode(t.Stdout)
- default:
- return createTypedError("unknown CNI_COMMAND: %v", cmd)
- }
-
- if err != nil {
- if e, ok := err.(*types.Error); ok {
- // don't wrap Error in Error
- return e
- }
- return createTypedError(err.Error())
- }
- return nil
-}
-
-// PluginMainWithError is the core "main" for a plugin. It accepts
-// callback functions for add, check, and del CNI commands and returns an error.
-//
-// The caller must also specify what CNI spec versions the plugin supports.
-//
-// It is the responsibility of the caller to check for non-nil error return.
-//
-// For a plugin to comply with the CNI spec, it must print any error to stdout
-// as JSON and then exit with nonzero status code.
-//
-// To let this package automatically handle errors and call os.Exit(1) for you,
-// use PluginMain() instead.
-func PluginMainWithError(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error, versionInfo version.PluginInfo, about string) *types.Error {
- return (&dispatcher{
- Getenv: os.Getenv,
- Stdin: os.Stdin,
- Stdout: os.Stdout,
- Stderr: os.Stderr,
- }).pluginMain(cmdAdd, cmdCheck, cmdDel, versionInfo, about)
-}
-
-// PluginMain is the core "main" for a plugin which includes automatic error handling.
-//
-// The caller must also specify what CNI spec versions the plugin supports.
-//
-// The caller can specify an "about" string, which is printed on stderr
-// when no CNI_COMMAND is specified. The recommended output is "CNI plugin <foo> v<version>"
-//
-// When an error occurs in either cmdAdd, cmdCheck, or cmdDel, PluginMain will print the error
-// as JSON to stdout and call os.Exit(1).
-//
-// To have more control over error handling, use PluginMainWithError() instead.
-func PluginMain(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error, versionInfo version.PluginInfo, about string) {
- if e := PluginMainWithError(cmdAdd, cmdCheck, cmdDel, versionInfo, about); e != nil {
- if err := e.Print(); err != nil {
- log.Print("Error writing error JSON to stdout: ", err)
- }
- os.Exit(1)
- }
-}
diff --git a/vendor/github.com/containernetworking/cni/pkg/types/020/types.go b/vendor/github.com/containernetworking/cni/pkg/types/020/types.go
deleted file mode 100644
index 5325616..0000000
--- a/vendor/github.com/containernetworking/cni/pkg/types/020/types.go
+++ /dev/null
@@ -1,140 +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 types020
-
-import (
- "encoding/json"
- "fmt"
- "io"
- "net"
- "os"
-
- "github.com/containernetworking/cni/pkg/types"
-)
-
-const ImplementedSpecVersion string = "0.2.0"
-
-var SupportedVersions = []string{"", "0.1.0", ImplementedSpecVersion}
-
-// Compatibility types for CNI version 0.1.0 and 0.2.0
-
-func NewResult(data []byte) (types.Result, error) {
- result := &Result{}
- if err := json.Unmarshal(data, result); err != nil {
- return nil, err
- }
- return result, nil
-}
-
-func GetResult(r types.Result) (*Result, error) {
- // We expect version 0.1.0/0.2.0 results
- result020, err := r.GetAsVersion(ImplementedSpecVersion)
- if err != nil {
- return nil, err
- }
- result, ok := result020.(*Result)
- if !ok {
- return nil, fmt.Errorf("failed to convert result")
- }
- return result, nil
-}
-
-// 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"`
-}
-
-func (r *Result) Version() string {
- return ImplementedSpecVersion
-}
-
-func (r *Result) GetAsVersion(version string) (types.Result, error) {
- for _, supportedVersion := range SupportedVersions {
- if version == supportedVersion {
- r.CNIVersion = version
- return r, nil
- }
- }
- return nil, fmt.Errorf("cannot convert version %q to %s", SupportedVersions, version)
-}
-
-func (r *Result) Print() error {
- return r.PrintTo(os.Stdout)
-}
-
-func (r *Result) PrintTo(writer io.Writer) error {
- data, err := json.MarshalIndent(r, "", " ")
- if err != nil {
- return err
- }
- _, err = writer.Write(data)
- return err
-}
-
-// String returns a formatted string in the form of "[IP4: $1,][ IP6: $2,] DNS: $3" where
-// $1 represents the receiver's IPv4, $2 represents the receiver's IPv6 and $3 the
-// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string.
-func (r *Result) String() string {
- var str string
- if r.IP4 != nil {
- str = fmt.Sprintf("IP4:%+v, ", *r.IP4)
- }
- if r.IP6 != nil {
- str += fmt.Sprintf("IP6:%+v, ", *r.IP6)
- }
- return fmt.Sprintf("%sDNS:%+v", str, r.DNS)
-}
-
-// IPConfig contains values necessary to configure an interface
-type IPConfig struct {
- IP net.IPNet
- Gateway net.IP
- Routes []types.Route
-}
-
-// net.IPNet is not JSON (un)marshallable so this duality is needed
-// for our custom IPNet type
-
-// JSON (un)marshallable types
-type ipConfig struct {
- IP types.IPNet `json:"ip"`
- Gateway net.IP `json:"gateway,omitempty"`
- Routes []types.Route `json:"routes,omitempty"`
-}
-
-func (c *IPConfig) MarshalJSON() ([]byte, error) {
- ipc := ipConfig{
- IP: types.IPNet(c.IP),
- Gateway: c.Gateway,
- Routes: c.Routes,
- }
-
- return json.Marshal(ipc)
-}
-
-func (c *IPConfig) UnmarshalJSON(data []byte) error {
- ipc := ipConfig{}
- if err := json.Unmarshal(data, &ipc); err != nil {
- return err
- }
-
- c.IP = net.IPNet(ipc.IP)
- c.Gateway = ipc.Gateway
- c.Routes = ipc.Routes
- return nil
-}
diff --git a/vendor/github.com/containernetworking/cni/pkg/types/args.go b/vendor/github.com/containernetworking/cni/pkg/types/args.go
deleted file mode 100644
index bd8640f..0000000
--- a/vendor/github.com/containernetworking/cni/pkg/types/args.go
+++ /dev/null
@@ -1,112 +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 types
-
-import (
- "encoding"
- "fmt"
- "reflect"
- "strings"
-)
-
-// UnmarshallableBool typedef for builtin bool
-// because builtin type's methods can't be declared
-type UnmarshallableBool bool
-
-// UnmarshalText implements the encoding.TextUnmarshaler interface.
-// Returns boolean true if the string is "1" or "[Tt]rue"
-// Returns boolean false if the string is "0" or "[Ff]alse"
-func (b *UnmarshallableBool) UnmarshalText(data []byte) error {
- s := strings.ToLower(string(data))
- switch s {
- case "1", "true":
- *b = true
- case "0", "false":
- *b = false
- default:
- return fmt.Errorf("Boolean unmarshal error: invalid input %s", s)
- }
- return nil
-}
-
-// UnmarshallableString typedef for builtin string
-type UnmarshallableString string
-
-// UnmarshalText implements the encoding.TextUnmarshaler interface.
-// Returns the string
-func (s *UnmarshallableString) UnmarshalText(data []byte) error {
- *s = UnmarshallableString(data)
- return nil
-}
-
-// CommonArgs contains the IgnoreUnknown argument
-// and must be embedded by all Arg structs
-type CommonArgs struct {
- IgnoreUnknown UnmarshallableBool `json:"ignoreunknown,omitempty"`
-}
-
-// GetKeyField is a helper function to receive Values
-// Values that represent a pointer to a struct
-func GetKeyField(keyString string, v reflect.Value) reflect.Value {
- return v.Elem().FieldByName(keyString)
-}
-
-// UnmarshalableArgsError is used to indicate error unmarshalling args
-// from the args-string in the form "K=V;K2=V2;..."
-type UnmarshalableArgsError struct {
- error
-}
-
-// LoadArgs parses args from a string in the form "K=V;K2=V2;..."
-func LoadArgs(args string, container interface{}) error {
- if args == "" {
- return nil
- }
-
- containerValue := reflect.ValueOf(container)
-
- pairs := strings.Split(args, ";")
- unknownArgs := []string{}
- for _, pair := range pairs {
- kv := strings.Split(pair, "=")
- if len(kv) != 2 {
- return fmt.Errorf("ARGS: invalid pair %q", pair)
- }
- keyString := kv[0]
- valueString := kv[1]
- keyField := GetKeyField(keyString, containerValue)
- if !keyField.IsValid() {
- unknownArgs = append(unknownArgs, pair)
- continue
- }
- keyFieldIface := keyField.Addr().Interface()
- u, ok := keyFieldIface.(encoding.TextUnmarshaler)
- if !ok {
- return UnmarshalableArgsError{fmt.Errorf(
- "ARGS: cannot unmarshal into field '%s' - type '%s' does not implement encoding.TextUnmarshaler",
- keyString, reflect.TypeOf(keyFieldIface))}
- }
- err := u.UnmarshalText([]byte(valueString))
- if err != nil {
- return fmt.Errorf("ARGS: error parsing value of pair %q: %v)", pair, err)
- }
- }
-
- isIgnoreUnknown := GetKeyField("IgnoreUnknown", containerValue).Bool()
- if len(unknownArgs) > 0 && !isIgnoreUnknown {
- return fmt.Errorf("ARGS: unknown args %q", unknownArgs)
- }
- return 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
deleted file mode 100644
index 7267a2e..0000000
--- a/vendor/github.com/containernetworking/cni/pkg/types/current/types.go
+++ /dev/null
@@ -1,293 +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 current
-
-import (
- "encoding/json"
- "fmt"
- "io"
- "net"
- "os"
-
- "github.com/containernetworking/cni/pkg/types"
- "github.com/containernetworking/cni/pkg/types/020"
-)
-
-const ImplementedSpecVersion string = "0.4.0"
-
-var SupportedVersions = []string{"0.3.0", "0.3.1", ImplementedSpecVersion}
-
-func NewResult(data []byte) (types.Result, error) {
- result := &Result{}
- if err := json.Unmarshal(data, result); err != nil {
- return nil, err
- }
- return result, nil
-}
-
-func GetResult(r types.Result) (*Result, error) {
- resultCurrent, err := r.GetAsVersion(ImplementedSpecVersion)
- if err != nil {
- return nil, err
- }
- result, ok := resultCurrent.(*Result)
- if !ok {
- return nil, fmt.Errorf("failed to convert result")
- }
- return result, nil
-}
-
-var resultConverters = []struct {
- versions []string
- convert func(types.Result) (*Result, error)
-}{
- {types020.SupportedVersions, convertFrom020},
- {SupportedVersions, convertFrom030},
-}
-
-func convertFrom020(result types.Result) (*Result, error) {
- oldResult, err := types020.GetResult(result)
- if err != nil {
- return nil, err
- }
-
- newResult := &Result{
- CNIVersion: ImplementedSpecVersion,
- DNS: oldResult.DNS,
- Routes: []*types.Route{},
- }
-
- if oldResult.IP4 != nil {
- newResult.IPs = append(newResult.IPs, &IPConfig{
- Version: "4",
- Address: oldResult.IP4.IP,
- Gateway: oldResult.IP4.Gateway,
- })
- for _, route := range oldResult.IP4.Routes {
- newResult.Routes = append(newResult.Routes, &types.Route{
- Dst: route.Dst,
- GW: route.GW,
- })
- }
- }
-
- if oldResult.IP6 != nil {
- newResult.IPs = append(newResult.IPs, &IPConfig{
- Version: "6",
- Address: oldResult.IP6.IP,
- Gateway: oldResult.IP6.Gateway,
- })
- for _, route := range oldResult.IP6.Routes {
- newResult.Routes = append(newResult.Routes, &types.Route{
- Dst: route.Dst,
- GW: route.GW,
- })
- }
- }
-
- return newResult, nil
-}
-
-func convertFrom030(result types.Result) (*Result, error) {
- newResult, ok := result.(*Result)
- if !ok {
- return nil, fmt.Errorf("failed to convert result")
- }
- newResult.CNIVersion = ImplementedSpecVersion
- return newResult, nil
-}
-
-func NewResultFromResult(result types.Result) (*Result, error) {
- version := result.Version()
- for _, converter := range resultConverters {
- for _, supportedVersion := range converter.versions {
- if version == supportedVersion {
- return converter.convert(result)
- }
- }
- }
- return nil, fmt.Errorf("unsupported CNI result22 version %q", version)
-}
-
-// 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"`
- DNS types.DNS `json:"dns,omitempty"`
-}
-
-// 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,
- }
-
- for _, ip := range r.IPs {
- // Only convert the first IP address of each version as 0.2.0
- // and earlier cannot handle multiple IP addresses
- if ip.Version == "4" && oldResult.IP4 == nil {
- oldResult.IP4 = &types020.IPConfig{
- IP: ip.Address,
- Gateway: ip.Gateway,
- }
- } else if ip.Version == "6" && oldResult.IP6 == nil {
- oldResult.IP6 = &types020.IPConfig{
- IP: ip.Address,
- Gateway: ip.Gateway,
- }
- }
-
- if oldResult.IP4 != nil && oldResult.IP6 != nil {
- break
- }
- }
-
- for _, route := range r.Routes {
- is4 := route.Dst.IP.To4() != nil
- if is4 && oldResult.IP4 != nil {
- oldResult.IP4.Routes = append(oldResult.IP4.Routes, types.Route{
- Dst: route.Dst,
- GW: route.GW,
- })
- } else if !is4 && oldResult.IP6 != nil {
- oldResult.IP6.Routes = append(oldResult.IP6.Routes, types.Route{
- Dst: route.Dst,
- GW: route.GW,
- })
- }
- }
-
- if oldResult.IP4 == nil && oldResult.IP6 == nil {
- return nil, fmt.Errorf("cannot convert: no valid IP addresses")
- }
-
- return oldResult, nil
-}
-
-func (r *Result) Version() string {
- return ImplementedSpecVersion
-}
-
-func (r *Result) GetAsVersion(version string) (types.Result, error) {
- switch version {
- case "0.3.0", "0.3.1", ImplementedSpecVersion:
- r.CNIVersion = version
- return r, nil
- case types020.SupportedVersions[0], types020.SupportedVersions[1], types020.SupportedVersions[2]:
- return r.convertTo020()
- }
- return nil, fmt.Errorf("cannot convert version 0.3.x to %q", version)
-}
-
-func (r *Result) Print() error {
- return r.PrintTo(os.Stdout)
-}
-
-func (r *Result) PrintTo(writer io.Writer) error {
- data, err := json.MarshalIndent(r, "", " ")
- if err != nil {
- return err
- }
- _, err = writer.Write(data)
- return err
-}
-
-// String returns a formatted string in the form of "[Interfaces: $1,][ IP: $2,] DNS: $3" where
-// $1 represents the receiver's Interfaces, $2 represents the receiver's IP addresses and $3 the
-// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string.
-func (r *Result) String() string {
- var str string
- if len(r.Interfaces) > 0 {
- str += fmt.Sprintf("Interfaces:%+v, ", r.Interfaces)
- }
- if len(r.IPs) > 0 {
- str += fmt.Sprintf("IP:%+v, ", r.IPs)
- }
- if len(r.Routes) > 0 {
- str += fmt.Sprintf("Routes:%+v, ", r.Routes)
- }
- return fmt.Sprintf("%sDNS:%+v", str, r.DNS)
-}
-
-// Convert this old version result to the current CNI version result
-func (r *Result) Convert() (*Result, error) {
- return r, nil
-}
-
-// Interface contains values about the created interfaces
-type Interface struct {
- Name string `json:"name"`
- Mac string `json:"mac,omitempty"`
- Sandbox string `json:"sandbox,omitempty"`
-}
-
-func (i *Interface) String() string {
- return fmt.Sprintf("%+v", *i)
-}
-
-// Int returns a pointer to the int value passed in. Used to
-// set the IPConfig.Interface field.
-func Int(v int) *int {
- return &v
-}
-
-// IPConfig contains values necessary to configure an IP address on an interface
-type IPConfig struct {
- // IP version, either "4" or "6"
- Version string
- // Index into Result structs Interfaces list
- Interface *int
- Address net.IPNet
- Gateway net.IP
-}
-
-func (i *IPConfig) String() string {
- return fmt.Sprintf("%+v", *i)
-}
-
-// JSON (un)marshallable types
-type ipConfig struct {
- Version string `json:"version"`
- Interface *int `json:"interface,omitempty"`
- Address types.IPNet `json:"address"`
- Gateway net.IP `json:"gateway,omitempty"`
-}
-
-func (c *IPConfig) MarshalJSON() ([]byte, error) {
- ipc := ipConfig{
- Version: c.Version,
- Interface: c.Interface,
- Address: types.IPNet(c.Address),
- Gateway: c.Gateway,
- }
-
- return json.Marshal(ipc)
-}
-
-func (c *IPConfig) UnmarshalJSON(data []byte) error {
- ipc := ipConfig{}
- if err := json.Unmarshal(data, &ipc); err != nil {
- return err
- }
-
- c.Version = ipc.Version
- c.Interface = ipc.Interface
- c.Address = net.IPNet(ipc.Address)
- c.Gateway = ipc.Gateway
- return nil
-}
diff --git a/vendor/github.com/containernetworking/cni/pkg/types/types.go b/vendor/github.com/containernetworking/cni/pkg/types/types.go
deleted file mode 100644
index d0d1100..0000000
--- a/vendor/github.com/containernetworking/cni/pkg/types/types.go
+++ /dev/null
@@ -1,199 +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 types
-
-import (
- "encoding/json"
- "errors"
- "fmt"
- "io"
- "net"
- "os"
-)
-
-// like net.IPNet but adds JSON marshalling and unmarshalling
-type IPNet net.IPNet
-
-// ParseCIDR takes a string like "10.2.3.1/24" and
-// return IPNet with "10.2.3.1" and /24 mask
-func ParseCIDR(s string) (*net.IPNet, error) {
- ip, ipn, err := net.ParseCIDR(s)
- if err != nil {
- return nil, err
- }
-
- ipn.IP = ip
- return ipn, nil
-}
-
-func (n IPNet) MarshalJSON() ([]byte, error) {
- return json.Marshal((*net.IPNet)(&n).String())
-}
-
-func (n *IPNet) UnmarshalJSON(data []byte) error {
- var s string
- if err := json.Unmarshal(data, &s); err != nil {
- return err
- }
-
- tmp, err := ParseCIDR(s)
- if err != nil {
- return err
- }
-
- *n = IPNet(*tmp)
- return nil
-}
-
-// NetConf describes a network.
-type NetConf struct {
- CNIVersion string `json:"cniVersion,omitempty"`
-
- Name string `json:"name,omitempty"`
- Type string `json:"type,omitempty"`
- Capabilities map[string]bool `json:"capabilities,omitempty"`
- IPAM IPAM `json:"ipam,omitempty"`
- DNS DNS `json:"dns"`
-
- RawPrevResult map[string]interface{} `json:"prevResult,omitempty"`
- PrevResult Result `json:"-"`
-}
-
-type IPAM struct {
- Type string `json:"type,omitempty"`
-}
-
-// NetConfList describes an ordered list of networks.
-type NetConfList struct {
- CNIVersion string `json:"cniVersion,omitempty"`
-
- Name string `json:"name,omitempty"`
- DisableCheck bool `json:"disableCheck,omitempty"`
- Plugins []*NetConf `json:"plugins,omitempty"`
-}
-
-type ResultFactoryFunc func([]byte) (Result, error)
-
-// Result is an interface that provides the result of plugin execution
-type Result interface {
- // The highest CNI specification result version the result supports
- // without having to convert
- Version() string
-
- // Returns the result converted into the requested CNI specification
- // result version, or an error if conversion failed
- GetAsVersion(version string) (Result, error)
-
- // Prints the result in JSON format to stdout
- Print() error
-
- // Prints the result in JSON format to provided writer
- PrintTo(writer io.Writer) error
-
- // Returns a JSON string representation of the result
- String() string
-}
-
-func PrintResult(result Result, version string) error {
- newResult, err := result.GetAsVersion(version)
- if err != nil {
- return err
- }
- return newResult.Print()
-}
-
-// DNS contains values interesting for DNS resolvers
-type DNS struct {
- Nameservers []string `json:"nameservers,omitempty"`
- Domain string `json:"domain,omitempty"`
- Search []string `json:"search,omitempty"`
- Options []string `json:"options,omitempty"`
-}
-
-type Route struct {
- Dst net.IPNet
- GW net.IP
-}
-
-func (r *Route) String() string {
- return fmt.Sprintf("%+v", *r)
-}
-
-// Well known error codes
-// see https://github.com/containernetworking/cni/blob/master/SPEC.md#well-known-error-codes
-const (
- ErrUnknown uint = iota // 0
- ErrIncompatibleCNIVersion // 1
- ErrUnsupportedField // 2
-)
-
-type Error struct {
- Code uint `json:"code"`
- Msg string `json:"msg"`
- Details string `json:"details,omitempty"`
-}
-
-func (e *Error) Error() string {
- details := ""
- if e.Details != "" {
- details = fmt.Sprintf("; %v", e.Details)
- }
- return fmt.Sprintf("%v%v", e.Msg, details)
-}
-
-func (e *Error) Print() error {
- return prettyPrint(e)
-}
-
-// net.IPNet is not JSON (un)marshallable so this duality is needed
-// for our custom IPNet type
-
-// JSON (un)marshallable types
-type route struct {
- Dst IPNet `json:"dst"`
- GW net.IP `json:"gw,omitempty"`
-}
-
-func (r *Route) UnmarshalJSON(data []byte) error {
- rt := route{}
- if err := json.Unmarshal(data, &rt); err != nil {
- return err
- }
-
- r.Dst = net.IPNet(rt.Dst)
- r.GW = rt.GW
- return nil
-}
-
-func (r Route) MarshalJSON() ([]byte, error) {
- rt := route{
- Dst: IPNet(r.Dst),
- GW: r.GW,
- }
-
- return json.Marshal(rt)
-}
-
-func prettyPrint(obj interface{}) error {
- data, err := json.MarshalIndent(obj, "", " ")
- if err != nil {
- return err
- }
- _, err = os.Stdout.Write(data)
- return err
-}
-
-// NotImplementedError is used to indicate that a method is not implemented for the given platform
-var NotImplementedError = errors.New("Not Implemented")
diff --git a/vendor/github.com/containernetworking/cni/pkg/version/conf.go b/vendor/github.com/containernetworking/cni/pkg/version/conf.go
deleted file mode 100644
index 3cca58b..0000000
--- a/vendor/github.com/containernetworking/cni/pkg/version/conf.go
+++ /dev/null
@@ -1,37 +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 version
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// ConfigDecoder can decode the CNI version available in network config data
-type ConfigDecoder struct{}
-
-func (*ConfigDecoder) Decode(jsonBytes []byte) (string, error) {
- var conf struct {
- CNIVersion string `json:"cniVersion"`
- }
- err := json.Unmarshal(jsonBytes, &conf)
- if err != nil {
- return "", fmt.Errorf("decoding version from network config: %s", err)
- }
- if conf.CNIVersion == "" {
- return "0.1.0", nil
- }
- return conf.CNIVersion, nil
-}
diff --git a/vendor/github.com/containernetworking/cni/pkg/version/plugin.go b/vendor/github.com/containernetworking/cni/pkg/version/plugin.go
deleted file mode 100644
index 1df4272..0000000
--- a/vendor/github.com/containernetworking/cni/pkg/version/plugin.go
+++ /dev/null
@@ -1,144 +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 version
-
-import (
- "encoding/json"
- "fmt"
- "io"
- "strconv"
- "strings"
-)
-
-// PluginInfo reports information about CNI versioning
-type PluginInfo interface {
- // SupportedVersions returns one or more CNI spec versions that the plugin
- // supports. If input is provided in one of these versions, then the plugin
- // promises to use the same CNI version in its response
- SupportedVersions() []string
-
- // Encode writes this CNI version information as JSON to the given Writer
- Encode(io.Writer) error
-}
-
-type pluginInfo struct {
- CNIVersion_ string `json:"cniVersion"`
- SupportedVersions_ []string `json:"supportedVersions,omitempty"`
-}
-
-// pluginInfo implements the PluginInfo interface
-var _ PluginInfo = &pluginInfo{}
-
-func (p *pluginInfo) Encode(w io.Writer) error {
- return json.NewEncoder(w).Encode(p)
-}
-
-func (p *pluginInfo) SupportedVersions() []string {
- return p.SupportedVersions_
-}
-
-// PluginSupports returns a new PluginInfo that will report the given versions
-// as supported
-func PluginSupports(supportedVersions ...string) PluginInfo {
- if len(supportedVersions) < 1 {
- panic("programmer error: you must support at least one version")
- }
- return &pluginInfo{
- CNIVersion_: Current(),
- SupportedVersions_: supportedVersions,
- }
-}
-
-// PluginDecoder can decode the response returned by a plugin's VERSION command
-type PluginDecoder struct{}
-
-func (*PluginDecoder) Decode(jsonBytes []byte) (PluginInfo, error) {
- var info pluginInfo
- err := json.Unmarshal(jsonBytes, &info)
- if err != nil {
- return nil, fmt.Errorf("decoding version info: %s", err)
- }
- if info.CNIVersion_ == "" {
- return nil, fmt.Errorf("decoding version info: missing field cniVersion")
- }
- if len(info.SupportedVersions_) == 0 {
- if info.CNIVersion_ == "0.2.0" {
- return PluginSupports("0.1.0", "0.2.0"), nil
- }
- return nil, fmt.Errorf("decoding version info: missing field supportedVersions")
- }
- return &info, nil
-}
-
-// ParseVersion parses a version string like "3.0.1" or "0.4.5" into major,
-// minor, and micro numbers or returns an error
-func ParseVersion(version string) (int, int, int, error) {
- var major, minor, micro int
- if version == "" {
- return -1, -1, -1, fmt.Errorf("invalid version %q: the version is empty", version)
- }
-
- parts := strings.Split(version, ".")
- if len(parts) >= 4 {
- return -1, -1, -1, fmt.Errorf("invalid version %q: too many parts", version)
- }
-
- major, err := strconv.Atoi(parts[0])
- if err != nil {
- return -1, -1, -1, fmt.Errorf("failed to convert major version part %q: %v", parts[0], err)
- }
-
- if len(parts) >= 2 {
- minor, err = strconv.Atoi(parts[1])
- if err != nil {
- return -1, -1, -1, fmt.Errorf("failed to convert minor version part %q: %v", parts[1], err)
- }
- }
-
- if len(parts) >= 3 {
- micro, err = strconv.Atoi(parts[2])
- if err != nil {
- return -1, -1, -1, fmt.Errorf("failed to convert micro version part %q: %v", parts[2], err)
- }
- }
-
- return major, minor, micro, nil
-}
-
-// GreaterThanOrEqualTo takes two string versions, parses them into major/minor/micro
-// numbers, and compares them to determine whether the first version is greater
-// than or equal to the second
-func GreaterThanOrEqualTo(version, otherVersion string) (bool, error) {
- firstMajor, firstMinor, firstMicro, err := ParseVersion(version)
- if err != nil {
- return false, err
- }
-
- secondMajor, secondMinor, secondMicro, err := ParseVersion(otherVersion)
- if err != nil {
- return false, err
- }
-
- if firstMajor > secondMajor {
- return true, nil
- } else if firstMajor == secondMajor {
- if firstMinor > secondMinor {
- return true, nil
- } else if firstMinor == secondMinor && firstMicro >= secondMicro {
- return true, nil
- }
- }
- return false, nil
-}
diff --git a/vendor/github.com/containernetworking/cni/pkg/version/reconcile.go b/vendor/github.com/containernetworking/cni/pkg/version/reconcile.go
deleted file mode 100644
index 25c3810..0000000
--- a/vendor/github.com/containernetworking/cni/pkg/version/reconcile.go
+++ /dev/null
@@ -1,49 +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 version
-
-import "fmt"
-
-type ErrorIncompatible struct {
- Config string
- Supported []string
-}
-
-func (e *ErrorIncompatible) Details() string {
- return fmt.Sprintf("config is %q, plugin supports %q", e.Config, e.Supported)
-}
-
-func (e *ErrorIncompatible) Error() string {
- return fmt.Sprintf("incompatible CNI versions: %s", e.Details())
-}
-
-type Reconciler struct{}
-
-func (r *Reconciler) Check(configVersion string, pluginInfo PluginInfo) *ErrorIncompatible {
- return r.CheckRaw(configVersion, pluginInfo.SupportedVersions())
-}
-
-func (*Reconciler) CheckRaw(configVersion string, supportedVersions []string) *ErrorIncompatible {
- for _, supportedVersion := range supportedVersions {
- if configVersion == supportedVersion {
- return nil
- }
- }
-
- return &ErrorIncompatible{
- Config: configVersion,
- Supported: supportedVersions,
- }
-}
diff --git a/vendor/github.com/containernetworking/cni/pkg/version/version.go b/vendor/github.com/containernetworking/cni/pkg/version/version.go
deleted file mode 100644
index 8f3508e..0000000
--- a/vendor/github.com/containernetworking/cni/pkg/version/version.go
+++ /dev/null
@@ -1,83 +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 version
-
-import (
- "encoding/json"
- "fmt"
-
- "github.com/containernetworking/cni/pkg/types"
- "github.com/containernetworking/cni/pkg/types/020"
- "github.com/containernetworking/cni/pkg/types/current"
-)
-
-// Current reports the version of the CNI spec implemented by this library
-func Current() string {
- return "0.4.0"
-}
-
-// Legacy PluginInfo describes a plugin that is backwards compatible with the
-// CNI spec version 0.1.0. In particular, a runtime compiled against the 0.1.0
-// library ought to work correctly with a plugin that reports support for
-// Legacy versions.
-//
-// Any future CNI spec versions which meet this definition should be added to
-// this list.
-var Legacy = PluginSupports("0.1.0", "0.2.0")
-var All = PluginSupports("0.1.0", "0.2.0", "0.3.0", "0.3.1", "0.4.0")
-
-var resultFactories = []struct {
- supportedVersions []string
- newResult types.ResultFactoryFunc
-}{
- {current.SupportedVersions, current.NewResult},
- {types020.SupportedVersions, types020.NewResult},
-}
-
-// Finds a Result object matching the requested version (if any) and asks
-// that object to parse the plugin result, returning an error if parsing failed.
-func NewResult(version string, resultBytes []byte) (types.Result, error) {
- reconciler := &Reconciler{}
- for _, resultFactory := range resultFactories {
- err := reconciler.CheckRaw(version, resultFactory.supportedVersions)
- if err == nil {
- // Result supports this version
- return resultFactory.newResult(resultBytes)
- }
- }
-
- return nil, fmt.Errorf("unsupported CNI result version %q", version)
-}
-
-// ParsePrevResult parses a prevResult in a NetConf structure and sets
-// the NetConf's PrevResult member to the parsed Result object.
-func ParsePrevResult(conf *types.NetConf) error {
- if conf.RawPrevResult == nil {
- return nil
- }
-
- resultBytes, err := json.Marshal(conf.RawPrevResult)
- if err != nil {
- return fmt.Errorf("could not serialize prevResult: %v", err)
- }
-
- conf.RawPrevResult = nil
- conf.PrevResult, err = NewResult(conf.CNIVersion, resultBytes)
- if err != nil {
- return fmt.Errorf("could not parse prevResult: %v", err)
- }
-
- return nil
-}
diff --git a/vendor/github.com/containernetworking/plugins/LICENSE b/vendor/github.com/containernetworking/plugins/LICENSE
deleted file mode 100644
index 8dada3e..0000000
--- a/vendor/github.com/containernetworking/plugins/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- 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.
diff --git a/vendor/github.com/containernetworking/plugins/pkg/ns/README.md b/vendor/github.com/containernetworking/plugins/pkg/ns/README.md
deleted file mode 100644
index 1e265c7..0000000
--- a/vendor/github.com/containernetworking/plugins/pkg/ns/README.md
+++ /dev/null
@@ -1,41 +0,0 @@
-### Namespaces, Threads, and Go
-On Linux each OS thread can have a different network namespace. Go's thread scheduling model switches goroutines between OS threads based on OS thread load and whether the goroutine would block other goroutines. This can result in a goroutine switching network namespaces without notice and lead to errors in your code.
-
-### Namespace Switching
-Switching namespaces with the `ns.Set()` method is not recommended without additional strategies to prevent unexpected namespace changes when your goroutines switch OS threads.
-
-Go provides the `runtime.LockOSThread()` function to ensure a specific goroutine executes on its current OS thread and prevents any other goroutine from running in that thread until the locked one exits. Careful usage of `LockOSThread()` and goroutines can provide good control over which network namespace a given goroutine executes in.
-
-For example, you cannot rely on the `ns.Set()` namespace being the current namespace after the `Set()` call unless you do two things. First, the goroutine calling `Set()` must have previously called `LockOSThread()`. Second, you must ensure `runtime.UnlockOSThread()` is not called somewhere in-between. You also cannot rely on the initial network namespace remaining the current network namespace if any other code in your program switches namespaces, unless you have already called `LockOSThread()` in that goroutine. Note that `LockOSThread()` prevents the Go scheduler from optimally scheduling goroutines for best performance, so `LockOSThread()` should only be used in small, isolated goroutines that release the lock quickly.
-
-### Do() The Recommended Thing
-The `ns.Do()` method provides **partial** control over network namespaces for you by implementing these strategies. All code dependent on a particular network namespace (including the root namespace) should be wrapped in the `ns.Do()` method to ensure the correct namespace is selected for the duration of your code. For example:
-
-```go
-err = targetNs.Do(func(hostNs ns.NetNS) error {
- dummy := &netlink.Dummy{
- LinkAttrs: netlink.LinkAttrs{
- Name: "dummy0",
- },
- }
- return netlink.LinkAdd(dummy)
-})
-```
-
-Note this requirement to wrap every network call is very onerous - any libraries you call might call out to network services such as DNS, and all such calls need to be protected after you call `ns.Do()`. All goroutines spawned from within the `ns.Do` will not inherit the new namespace. The CNI plugins all exit very soon after calling `ns.Do()` which helps to minimize the problem.
-
-When a new thread is spawned in Linux, it inherits the namespace of its parent. In versions of go **prior to 1.10**, if the runtime spawns a new OS thread, it picks the parent randomly. If the chosen parent thread has been moved to a new namespace (even temporarily), the new OS thread will be permanently "stuck in the wrong namespace", and goroutines will non-deterministically switch namespaces as they are rescheduled.
-
-In short, **there was no safe way to change network namespaces, even temporarily, from within a long-lived, multithreaded Go process**. If you wish to do this, you must use go 1.10 or greater.
-
-
-### Creating network namespaces
-Earlier versions of this library managed namespace creation, but as CNI does not actually utilize this feature (and it was essentially unmaintained), it was removed. If you're writing a container runtime, you should implement namespace management yourself. However, there are some gotchas when doing so, especially around handling `/var/run/netns`. A reasonably correct reference implementation, borrowed from `rkt`, can be found in `pkg/testutils/netns_linux.go` if you're in need of a source of inspiration.
-
-
-### Further Reading
- - https://github.com/golang/go/wiki/LockOSThread
- - http://morsmachine.dk/go-scheduler
- - https://github.com/containernetworking/cni/issues/262
- - https://golang.org/pkg/runtime/
- - https://www.weave.works/blog/linux-namespaces-and-go-don-t-mix
diff --git a/vendor/github.com/containernetworking/plugins/pkg/ns/ns_linux.go b/vendor/github.com/containernetworking/plugins/pkg/ns/ns_linux.go
deleted file mode 100644
index 31ad5f6..0000000
--- a/vendor/github.com/containernetworking/plugins/pkg/ns/ns_linux.go
+++ /dev/null
@@ -1,216 +0,0 @@
-// Copyright 2015-2017 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 ns
-
-import (
- "fmt"
- "os"
- "runtime"
- "sync"
- "syscall"
-
- "golang.org/x/sys/unix"
-)
-
-// Returns an object representing the current OS thread's network namespace
-func GetCurrentNS() (NetNS, error) {
- return GetNS(getCurrentThreadNetNSPath())
-}
-
-func getCurrentThreadNetNSPath() string {
- // /proc/self/ns/net returns the namespace of the main thread, not
- // of whatever thread this goroutine is running on. Make sure we
- // use the thread's net namespace since the thread is switching around
- return fmt.Sprintf("/proc/%d/task/%d/ns/net", os.Getpid(), unix.Gettid())
-}
-
-func (ns *netNS) Close() error {
- if err := ns.errorIfClosed(); err != nil {
- return err
- }
-
- if err := ns.file.Close(); err != nil {
- return fmt.Errorf("Failed to close %q: %v", ns.file.Name(), err)
- }
- ns.closed = true
-
- return nil
-}
-
-func (ns *netNS) Set() error {
- if err := ns.errorIfClosed(); err != nil {
- return err
- }
-
- if err := unix.Setns(int(ns.Fd()), unix.CLONE_NEWNET); err != nil {
- return fmt.Errorf("Error switching to ns %v: %v", ns.file.Name(), err)
- }
-
- return nil
-}
-
-type NetNS interface {
- // Executes the passed closure in this object's network namespace,
- // attempting to restore the original namespace before returning.
- // However, since each OS thread can have a different network namespace,
- // and Go's thread scheduling is highly variable, callers cannot
- // guarantee any specific namespace is set unless operations that
- // require that namespace are wrapped with Do(). Also, no code called
- // from Do() should call runtime.UnlockOSThread(), or the risk
- // of executing code in an incorrect namespace will be greater. See
- // https://github.com/golang/go/wiki/LockOSThread for further details.
- Do(toRun func(NetNS) error) error
-
- // Sets the current network namespace to this object's network namespace.
- // Note that since Go's thread scheduling is highly variable, callers
- // cannot guarantee the requested namespace will be the current namespace
- // after this function is called; to ensure this wrap operations that
- // require the namespace with Do() instead.
- Set() error
-
- // Returns the filesystem path representing this object's network namespace
- Path() string
-
- // Returns a file descriptor representing this object's network namespace
- Fd() uintptr
-
- // Cleans up this instance of the network namespace; if this instance
- // is the last user the namespace will be destroyed
- Close() error
-}
-
-type netNS struct {
- file *os.File
- closed bool
-}
-
-// netNS implements the NetNS interface
-var _ NetNS = &netNS{}
-
-const (
- // https://github.com/torvalds/linux/blob/master/include/uapi/linux/magic.h
- NSFS_MAGIC = 0x6e736673
- PROCFS_MAGIC = 0x9fa0
-)
-
-type NSPathNotExistErr struct{ msg string }
-
-func (e NSPathNotExistErr) Error() string { return e.msg }
-
-type NSPathNotNSErr struct{ msg string }
-
-func (e NSPathNotNSErr) Error() string { return e.msg }
-
-func IsNSorErr(nspath string) error {
- stat := syscall.Statfs_t{}
- if err := syscall.Statfs(nspath, &stat); err != nil {
- if os.IsNotExist(err) {
- err = NSPathNotExistErr{msg: fmt.Sprintf("failed to Statfs %q: %v", nspath, err)}
- } else {
- err = fmt.Errorf("failed to Statfs %q: %v", nspath, err)
- }
- return err
- }
-
- switch stat.Type {
- case PROCFS_MAGIC, NSFS_MAGIC:
- return nil
- default:
- return NSPathNotNSErr{msg: fmt.Sprintf("unknown FS magic on %q: %x", nspath, stat.Type)}
- }
-}
-
-// Returns an object representing the namespace referred to by @path
-func GetNS(nspath string) (NetNS, error) {
- err := IsNSorErr(nspath)
- if err != nil {
- return nil, err
- }
-
- fd, err := os.Open(nspath)
- if err != nil {
- return nil, err
- }
-
- return &netNS{file: fd}, nil
-}
-
-func (ns *netNS) Path() string {
- return ns.file.Name()
-}
-
-func (ns *netNS) Fd() uintptr {
- return ns.file.Fd()
-}
-
-func (ns *netNS) errorIfClosed() error {
- if ns.closed {
- return fmt.Errorf("%q has already been closed", ns.file.Name())
- }
- return nil
-}
-
-func (ns *netNS) Do(toRun func(NetNS) error) error {
- if err := ns.errorIfClosed(); err != nil {
- return err
- }
-
- containedCall := func(hostNS NetNS) error {
- threadNS, err := GetCurrentNS()
- if err != nil {
- return fmt.Errorf("failed to open current netns: %v", err)
- }
- defer threadNS.Close()
-
- // switch to target namespace
- if err = ns.Set(); err != nil {
- return fmt.Errorf("error switching to ns %v: %v", ns.file.Name(), err)
- }
- defer threadNS.Set() // switch back
-
- return toRun(hostNS)
- }
-
- // save a handle to current network namespace
- hostNS, err := GetCurrentNS()
- if err != nil {
- return fmt.Errorf("Failed to open current namespace: %v", err)
- }
- defer hostNS.Close()
-
- var wg sync.WaitGroup
- wg.Add(1)
-
- var innerError error
- go func() {
- defer wg.Done()
- runtime.LockOSThread()
- innerError = containedCall(hostNS)
- }()
- wg.Wait()
-
- return innerError
-}
-
-// WithNetNSPath executes the passed closure under the given network
-// namespace, restoring the original namespace afterwards.
-func WithNetNSPath(nspath string, toRun func(NetNS) error) error {
- ns, err := GetNS(nspath)
- if err != nil {
- return err
- }
- defer ns.Close()
- return ns.Do(toRun)
-}
diff --git a/vendor/github.com/containernetworking/plugins/pkg/testutils/bad_reader.go b/vendor/github.com/containernetworking/plugins/pkg/testutils/bad_reader.go
deleted file mode 100644
index f9d0ade..0000000
--- a/vendor/github.com/containernetworking/plugins/pkg/testutils/bad_reader.go
+++ /dev/null
@@ -1,33 +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 testutils
-
-import "errors"
-
-// BadReader is an io.Reader which always errors
-type BadReader struct {
- Error error
-}
-
-func (r *BadReader) Read(buffer []byte) (int, error) {
- if r.Error != nil {
- return 0, r.Error
- }
- return 0, errors.New("banana")
-}
-
-func (r *BadReader) Close() error {
- return nil
-}
diff --git a/vendor/github.com/containernetworking/plugins/pkg/testutils/cmd.go b/vendor/github.com/containernetworking/plugins/pkg/testutils/cmd.go
deleted file mode 100644
index ce600f6..0000000
--- a/vendor/github.com/containernetworking/plugins/pkg/testutils/cmd.go
+++ /dev/null
@@ -1,112 +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 testutils
-
-import (
- "io/ioutil"
- "os"
-
- "github.com/containernetworking/cni/pkg/skel"
- "github.com/containernetworking/cni/pkg/types"
- "github.com/containernetworking/cni/pkg/version"
-)
-
-func envCleanup() {
- os.Unsetenv("CNI_COMMAND")
- os.Unsetenv("CNI_PATH")
- os.Unsetenv("CNI_NETNS")
- os.Unsetenv("CNI_IFNAME")
- os.Unsetenv("CNI_CONTAINERID")
-}
-
-func CmdAdd(cniNetns, cniContainerID, cniIfname string, conf []byte, f func() error) (types.Result, []byte, error) {
- os.Setenv("CNI_COMMAND", "ADD")
- os.Setenv("CNI_PATH", os.Getenv("PATH"))
- os.Setenv("CNI_NETNS", cniNetns)
- os.Setenv("CNI_IFNAME", cniIfname)
- os.Setenv("CNI_CONTAINERID", cniContainerID)
- defer envCleanup()
-
- // Redirect stdout to capture plugin result
- oldStdout := os.Stdout
- r, w, err := os.Pipe()
- if err != nil {
- return nil, nil, err
- }
-
- os.Stdout = w
- err = f()
- w.Close()
-
- var out []byte
- if err == nil {
- out, err = ioutil.ReadAll(r)
- }
- os.Stdout = oldStdout
-
- // Return errors after restoring stdout so Ginkgo will correctly
- // emit verbose error information on stdout
- if err != nil {
- return nil, nil, err
- }
-
- // Plugin must return result in same version as specified in netconf
- versionDecoder := &version.ConfigDecoder{}
- confVersion, err := versionDecoder.Decode(conf)
- if err != nil {
- return nil, nil, err
- }
-
- result, err := version.NewResult(confVersion, out)
- if err != nil {
- return nil, nil, err
- }
-
- return result, out, nil
-}
-
-func CmdAddWithArgs(args *skel.CmdArgs, f func() error) (types.Result, []byte, error) {
- return CmdAdd(args.Netns, args.ContainerID, args.IfName, args.StdinData, f)
-}
-
-func CmdCheck(cniNetns, cniContainerID, cniIfname string, conf []byte, f func() error) error {
- os.Setenv("CNI_COMMAND", "CHECK")
- os.Setenv("CNI_PATH", os.Getenv("PATH"))
- os.Setenv("CNI_NETNS", cniNetns)
- os.Setenv("CNI_IFNAME", cniIfname)
- os.Setenv("CNI_CONTAINERID", cniContainerID)
- defer envCleanup()
-
- return f()
-}
-
-func CmdCheckWithArgs(args *skel.CmdArgs, f func() error) error {
- return CmdCheck(args.Netns, args.ContainerID, args.IfName, args.StdinData, f)
-}
-
-func CmdDel(cniNetns, cniContainerID, cniIfname string, f func() error) error {
- os.Setenv("CNI_COMMAND", "DEL")
- os.Setenv("CNI_PATH", os.Getenv("PATH"))
- os.Setenv("CNI_NETNS", cniNetns)
- os.Setenv("CNI_IFNAME", cniIfname)
- os.Setenv("CNI_CONTAINERID", cniContainerID)
- defer envCleanup()
-
- return f()
-}
-
-func CmdDelWithArgs(args *skel.CmdArgs, f func() error) error {
- return CmdDel(args.Netns, args.ContainerID, args.IfName, f)
-}
diff --git a/vendor/github.com/containernetworking/plugins/pkg/testutils/netns_linux.go b/vendor/github.com/containernetworking/plugins/pkg/testutils/netns_linux.go
deleted file mode 100644
index 6d56e40..0000000
--- a/vendor/github.com/containernetworking/plugins/pkg/testutils/netns_linux.go
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright 2018 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 testutils
-
-import (
- "crypto/rand"
- "fmt"
- "os"
- "path"
- "runtime"
- "strings"
- "sync"
-
- "github.com/containernetworking/plugins/pkg/ns"
- "golang.org/x/sys/unix"
-)
-
-const nsRunDir = "/var/run/netns"
-
-// Creates a new persistent (bind-mounted) network namespace and returns an object
-// representing that namespace, without switching to it.
-func NewNS() (ns.NetNS, error) {
-
- b := make([]byte, 16)
- _, err := rand.Reader.Read(b)
- if err != nil {
- return nil, fmt.Errorf("failed to generate random netns name: %v", err)
- }
-
- // Create the directory for mounting network namespaces
- // This needs to be a shared mountpoint in case it is mounted in to
- // other namespaces (containers)
- err = os.MkdirAll(nsRunDir, 0755)
- if err != nil {
- return nil, err
- }
-
- // Remount the namespace directory shared. This will fail if it is not
- // already a mountpoint, so bind-mount it on to itself to "upgrade" it
- // to a mountpoint.
- err = unix.Mount("", nsRunDir, "none", unix.MS_SHARED|unix.MS_REC, "")
- if err != nil {
- if err != unix.EINVAL {
- return nil, fmt.Errorf("mount --make-rshared %s failed: %q", nsRunDir, err)
- }
-
- // Recursively remount /var/run/netns on itself. The recursive flag is
- // so that any existing netns bindmounts are carried over.
- err = unix.Mount(nsRunDir, nsRunDir, "none", unix.MS_BIND|unix.MS_REC, "")
- if err != nil {
- return nil, fmt.Errorf("mount --rbind %s %s failed: %q", nsRunDir, nsRunDir, err)
- }
-
- // Now we can make it shared
- err = unix.Mount("", nsRunDir, "none", unix.MS_SHARED|unix.MS_REC, "")
- if err != nil {
- return nil, fmt.Errorf("mount --make-rshared %s failed: %q", nsRunDir, err)
- }
-
- }
-
- nsName := fmt.Sprintf("cnitest-%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
-
- // create an empty file at the mount point
- nsPath := path.Join(nsRunDir, nsName)
- mountPointFd, err := os.Create(nsPath)
- if err != nil {
- return nil, err
- }
- mountPointFd.Close()
-
- // Ensure the mount point is cleaned up on errors; if the namespace
- // was successfully mounted this will have no effect because the file
- // is in-use
- defer os.RemoveAll(nsPath)
-
- var wg sync.WaitGroup
- wg.Add(1)
-
- // do namespace work in a dedicated goroutine, so that we can safely
- // Lock/Unlock OSThread without upsetting the lock/unlock state of
- // the caller of this function
- go (func() {
- defer wg.Done()
- runtime.LockOSThread()
- // Don't unlock. By not unlocking, golang will kill the OS thread when the
- // goroutine is done (for go1.10+)
-
- var origNS ns.NetNS
- origNS, err = ns.GetNS(getCurrentThreadNetNSPath())
- if err != nil {
- return
- }
- defer origNS.Close()
-
- // create a new netns on the current thread
- err = unix.Unshare(unix.CLONE_NEWNET)
- if err != nil {
- return
- }
-
- // Put this thread back to the orig ns, since it might get reused (pre go1.10)
- defer origNS.Set()
-
- // bind mount the netns from the current thread (from /proc) onto the
- // mount point. This causes the namespace to persist, even when there
- // are no threads in the ns.
- err = unix.Mount(getCurrentThreadNetNSPath(), nsPath, "none", unix.MS_BIND, "")
- if err != nil {
- err = fmt.Errorf("failed to bind mount ns at %s: %v", nsPath, err)
- }
- })()
- wg.Wait()
-
- if err != nil {
- return nil, fmt.Errorf("failed to create namespace: %v", err)
- }
-
- return ns.GetNS(nsPath)
-}
-
-// UnmountNS unmounts the NS held by the netns object
-func UnmountNS(ns ns.NetNS) error {
- nsPath := ns.Path()
- // Only unmount if it's been bind-mounted (don't touch namespaces in /proc...)
- if strings.HasPrefix(nsPath, nsRunDir) {
- if err := unix.Unmount(nsPath, 0); err != nil {
- return fmt.Errorf("failed to unmount NS: at %s: %v", nsPath, err)
- }
-
- if err := os.Remove(nsPath); err != nil {
- return fmt.Errorf("failed to remove ns path %s: %v", nsPath, err)
- }
- }
-
- return nil
-}
-
-// getCurrentThreadNetNSPath copied from pkg/ns
-func getCurrentThreadNetNSPath() string {
- // /proc/self/ns/net returns the namespace of the main thread, not
- // of whatever thread this goroutine is running on. Make sure we
- // use the thread's net namespace since the thread is switching around
- return fmt.Sprintf("/proc/%d/task/%d/ns/net", os.Getpid(), unix.Gettid())
-}
diff --git a/vendor/github.com/containernetworking/plugins/pkg/testutils/ping.go b/vendor/github.com/containernetworking/plugins/pkg/testutils/ping.go
deleted file mode 100644
index 5ee9db1..0000000
--- a/vendor/github.com/containernetworking/plugins/pkg/testutils/ping.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2017 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 testutils
-
-import (
- "bytes"
- "fmt"
- "os/exec"
- "strconv"
- "syscall"
-)
-
-// Ping shells out to the `ping` command. Returns nil if successful.
-func Ping(saddr, daddr string, isV6 bool, timeoutSec int) error {
- args := []string{
- "-c", "1",
- "-W", strconv.Itoa(timeoutSec),
- "-I", saddr,
- daddr,
- }
-
- bin := "ping"
- if isV6 {
- bin = "ping6"
- }
-
- cmd := exec.Command(bin, args...)
- var stderr bytes.Buffer
- cmd.Stderr = &stderr
-
- if err := cmd.Run(); err != nil {
- switch e := err.(type) {
- case *exec.ExitError:
- return fmt.Errorf("%v exit status %d: %s",
- args, e.Sys().(syscall.WaitStatus).ExitStatus(),
- stderr.String())
- default:
- return err
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/containernetworking/plugins/pkg/utils/buildversion/buildversion.go b/vendor/github.com/containernetworking/plugins/pkg/utils/buildversion/buildversion.go
deleted file mode 100644
index 734d418..0000000
--- a/vendor/github.com/containernetworking/plugins/pkg/utils/buildversion/buildversion.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2019 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.
-
-// Buildversion is a destination for the linker trickery so we can auto
-// set the build-version
-package buildversion
-
-import "fmt"
-
-// This is overridden in the linker script
-var BuildVersion = "version unknown"
-
-func BuildString(pluginName string) string {
- return fmt.Sprintf("CNI %s plugin %s", pluginName, BuildVersion)
-}
diff --git a/vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk/backend.go b/vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk/backend.go
deleted file mode 100644
index 56f1638..0000000
--- a/vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk/backend.go
+++ /dev/null
@@ -1,209 +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 disk
-
-import (
- "io/ioutil"
- "net"
- "os"
- "path/filepath"
- "runtime"
- "strings"
-
- "github.com/containernetworking/plugins/plugins/ipam/host-local/backend"
-)
-
-const lastIPFilePrefix = "last_reserved_ip."
-const LineBreak = "\r\n"
-
-var defaultDataDir = "/var/lib/cni/networks"
-
-// Store is a simple disk-backed store that creates one file per IP
-// address in a given directory. The contents of the file are the container ID.
-type Store struct {
- *FileLock
- dataDir string
-}
-
-// Store implements the Store interface
-var _ backend.Store = &Store{}
-
-func New(network, dataDir string) (*Store, error) {
- if dataDir == "" {
- dataDir = defaultDataDir
- }
- dir := filepath.Join(dataDir, network)
- if err := os.MkdirAll(dir, 0755); err != nil {
- return nil, err
- }
-
- lk, err := NewFileLock(dir)
- if err != nil {
- return nil, err
- }
- return &Store{lk, dir}, nil
-}
-
-func (s *Store) Reserve(id string, ifname string, ip net.IP, rangeID string) (bool, error) {
- fname := GetEscapedPath(s.dataDir, ip.String())
-
- f, err := os.OpenFile(fname, os.O_RDWR|os.O_EXCL|os.O_CREATE, 0644)
- if os.IsExist(err) {
- return false, nil
- }
- if err != nil {
- return false, err
- }
- if _, err := f.WriteString(strings.TrimSpace(id) + LineBreak + ifname); err != nil {
- f.Close()
- os.Remove(f.Name())
- return false, err
- }
- if err := f.Close(); err != nil {
- os.Remove(f.Name())
- return false, err
- }
- // store the reserved ip in lastIPFile
- ipfile := GetEscapedPath(s.dataDir, lastIPFilePrefix+rangeID)
- err = ioutil.WriteFile(ipfile, []byte(ip.String()), 0644)
- if err != nil {
- return false, err
- }
- return true, nil
-}
-
-// LastReservedIP returns the last reserved IP if exists
-func (s *Store) LastReservedIP(rangeID string) (net.IP, error) {
- ipfile := GetEscapedPath(s.dataDir, lastIPFilePrefix+rangeID)
- data, err := ioutil.ReadFile(ipfile)
- if err != nil {
- return nil, err
- }
- return net.ParseIP(string(data)), nil
-}
-
-func (s *Store) Release(ip net.IP) error {
- return os.Remove(GetEscapedPath(s.dataDir, ip.String()))
-}
-
-func (s *Store) FindByKey(id string, ifname string, match string) (bool, error) {
- found := false
-
- err := filepath.Walk(s.dataDir, func(path string, info os.FileInfo, err error) error {
- if err != nil || info.IsDir() {
- return nil
- }
- data, err := ioutil.ReadFile(path)
- if err != nil {
- return nil
- }
- if strings.TrimSpace(string(data)) == match {
- found = true
- }
- return nil
- })
- return found, err
-
-}
-
-func (s *Store) FindByID(id string, ifname string) bool {
- s.Lock()
- defer s.Unlock()
-
- found := false
- match := strings.TrimSpace(id) + LineBreak + ifname
- found, err := s.FindByKey(id, ifname, match)
-
- // Match anything created by this id
- if !found && err == nil {
- match := strings.TrimSpace(id)
- found, err = s.FindByKey(id, ifname, match)
- }
-
- return found
-}
-
-func (s *Store) ReleaseByKey(id string, ifname string, match string) (bool, error) {
- found := false
- err := filepath.Walk(s.dataDir, func(path string, info os.FileInfo, err error) error {
- if err != nil || info.IsDir() {
- return nil
- }
- data, err := ioutil.ReadFile(path)
- if err != nil {
- return nil
- }
- if strings.TrimSpace(string(data)) == match {
- if err := os.Remove(path); err != nil {
- return nil
- }
- found = true
- }
- return nil
- })
- return found, err
-
-}
-
-// N.B. This function eats errors to be tolerant and
-// release as much as possible
-func (s *Store) ReleaseByID(id string, ifname string) error {
- found := false
- match := strings.TrimSpace(id) + LineBreak + ifname
- found, err := s.ReleaseByKey(id, ifname, match)
-
- // For backwards compatibility, look for files written by a previous version
- if !found && err == nil {
- match := strings.TrimSpace(id)
- found, err = s.ReleaseByKey(id, ifname, match)
- }
- return err
-}
-
-// GetByID returns the IPs which have been allocated to the specific ID
-func (s *Store) GetByID(id string, ifname string) []net.IP {
- var ips []net.IP
-
- match := strings.TrimSpace(id) + LineBreak + ifname
- // matchOld for backwards compatibility
- matchOld := strings.TrimSpace(id)
-
- // walk through all ips in this network to get the ones which belong to a specific ID
- _ = filepath.Walk(s.dataDir, func(path string, info os.FileInfo, err error) error {
- if err != nil || info.IsDir() {
- return nil
- }
- data, err := ioutil.ReadFile(path)
- if err != nil {
- return nil
- }
- if strings.TrimSpace(string(data)) == match || strings.TrimSpace(string(data)) == matchOld {
- _, ipString := filepath.Split(path)
- if ip := net.ParseIP(ipString); ip != nil {
- ips = append(ips, ip)
- }
- }
- return nil
- })
-
- return ips
-}
-
-func GetEscapedPath(dataDir string, fname string) string {
- if runtime.GOOS == "windows" {
- fname = strings.Replace(fname, ":", "_", -1)
- }
- return filepath.Join(dataDir, fname)
-}
diff --git a/vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk/lock.go b/vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk/lock.go
deleted file mode 100644
index fe7b480..0000000
--- a/vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk/lock.go
+++ /dev/null
@@ -1,59 +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 disk
-
-import (
- "github.com/alexflint/go-filemutex"
- "os"
- "path"
-)
-
-// FileLock wraps os.File to be used as a lock using flock
-type FileLock struct {
- f *filemutex.FileMutex
-}
-
-// NewFileLock opens file/dir at path and returns unlocked FileLock object
-func NewFileLock(lockPath string) (*FileLock, error) {
- fi, err := os.Stat(lockPath)
- if err != nil {
- return nil, err
- }
-
- if fi.IsDir() {
- lockPath = path.Join(lockPath, "lock")
- }
-
- f, err := filemutex.New(lockPath)
- if err != nil {
- return nil, err
- }
-
- return &FileLock{f}, nil
-}
-
-func (l *FileLock) Close() error {
- return l.f.Close()
-}
-
-// Lock acquires an exclusive lock
-func (l *FileLock) Lock() error {
- return l.f.Lock()
-}
-
-// Unlock releases the lock
-func (l *FileLock) Unlock() error {
- return l.f.Unlock()
-}
diff --git a/vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/store.go b/vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/store.go
deleted file mode 100644
index 7211ddf..0000000
--- a/vendor/github.com/containernetworking/plugins/plugins/ipam/host-local/backend/store.go
+++ /dev/null
@@ -1,28 +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 backend
-
-import "net"
-
-type Store interface {
- Lock() error
- Unlock() error
- Close() error
- Reserve(id string, ifname string, ip net.IP, rangeID string) (bool, error)
- LastReservedIP(rangeID string) (net.IP, error)
- Release(ip net.IP) error
- ReleaseByID(id string, ifname string) error
- GetByID(id string, ifname string) []net.IP
-}