diff --git a/go.mod b/go.mod index d17642d65..cd53b624f 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/containerd/console v1.0.2 github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e github.com/containerd/fifo v0.0.0-20210316144830-115abcc95a1d - github.com/containerd/go-cni v1.0.1 + github.com/containerd/go-cni v1.0.2 github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0 github.com/containerd/imgcrypt v1.1.1 github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14 diff --git a/go.sum b/go.sum index 9aac58298..eba2b2c90 100644 --- a/go.sum +++ b/go.sum @@ -137,8 +137,9 @@ github.com/containerd/fifo v0.0.0-20200410184934-f15a3290365b/go.mod h1:jPQ2IAeZ github.com/containerd/fifo v0.0.0-20201026212402-0724c46b320c/go.mod h1:jPQ2IAeZRCYxpS/Cm1495vGFww6ecHmMk1YJH2Q5ln0= github.com/containerd/fifo v0.0.0-20210316144830-115abcc95a1d h1:u6sWqdNGAy7+O8qG/r1dqdnZE7IdEjteK3WGuvbfreo= github.com/containerd/fifo v0.0.0-20210316144830-115abcc95a1d/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4= -github.com/containerd/go-cni v1.0.1 h1:VXr2EkOPD0v1gu7CKfof6XzEIDzsE/dI9yj/W7PSWLs= github.com/containerd/go-cni v1.0.1/go.mod h1:+vUpYxKvAF72G9i1WoDOiPGRtQpqsNW/ZHtSlv++smU= +github.com/containerd/go-cni v1.0.2 h1:YbJAhpTevL2v6u8JC1NhCYRwf+3Vzxcc5vGnYoJ7VeE= +github.com/containerd/go-cni v1.0.2/go.mod h1:nrNABBHzu0ZwCug9Ije8hL2xBCYh/pjfMb1aZGrrohk= github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0= github.com/containerd/go-runc v0.0.0-20190911050354-e029b79d8cda/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0= github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328/go.mod h1:PpyHrqVs8FTi9vpyHwPwiNEGaACDxT/N/pLcvMSRA9g= diff --git a/integration/client/go.sum b/integration/client/go.sum index 1db531542..6421a74bf 100644 --- a/integration/client/go.sum +++ b/integration/client/go.sum @@ -82,7 +82,7 @@ github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e h1:6JKvHHt39 github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= github.com/containerd/fifo v0.0.0-20210316144830-115abcc95a1d h1:u6sWqdNGAy7+O8qG/r1dqdnZE7IdEjteK3WGuvbfreo= github.com/containerd/fifo v0.0.0-20210316144830-115abcc95a1d/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4= -github.com/containerd/go-cni v1.0.1/go.mod h1:+vUpYxKvAF72G9i1WoDOiPGRtQpqsNW/ZHtSlv++smU= +github.com/containerd/go-cni v1.0.2/go.mod h1:nrNABBHzu0ZwCug9Ije8hL2xBCYh/pjfMb1aZGrrohk= github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328/go.mod h1:PpyHrqVs8FTi9vpyHwPwiNEGaACDxT/N/pLcvMSRA9g= github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0 h1:e+50zk22gvHLJKe8+d+xSMyA88PPQk/XfWuUw1BdnPA= github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0/go.mod h1:cNU0ZbCgCQVZK4lgG3P+9tn9/PaJNmoDXPpoJhDR+Ok= @@ -352,11 +352,9 @@ github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8= -github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= diff --git a/pkg/cri/server/cni_conf_syncer.go b/pkg/cri/server/cni_conf_syncer.go index 1859d1cc4..401cb34a3 100644 --- a/pkg/cri/server/cni_conf_syncer.go +++ b/pkg/cri/server/cni_conf_syncer.go @@ -36,11 +36,11 @@ type cniNetConfSyncer struct { watcher *fsnotify.Watcher confDir string netPlugin cni.CNI - loadOpts []cni.CNIOpt + loadOpts []cni.Opt } // newCNINetConfSyncer creates cni network conf syncer. -func newCNINetConfSyncer(confDir string, netPlugin cni.CNI, loadOpts []cni.CNIOpt) (*cniNetConfSyncer, error) { +func newCNINetConfSyncer(confDir string, netPlugin cni.CNI, loadOpts []cni.Opt) (*cniNetConfSyncer, error) { watcher, err := fsnotify.NewWatcher() if err != nil { return nil, errors.Wrap(err, "failed to create fsnotify watcher") diff --git a/pkg/cri/server/sandbox_run.go b/pkg/cri/server/sandbox_run.go index af3b5ecd9..cb83b5b5e 100644 --- a/pkg/cri/server/sandbox_run.go +++ b/pkg/cri/server/sandbox_run.go @@ -544,7 +544,7 @@ func (c *criService) getSandboxRuntime(config *runtime.PodSandboxConfig, runtime return handler, nil } -func logDebugCNIResult(ctx context.Context, sandboxID string, result *cni.CNIResult) { +func logDebugCNIResult(ctx context.Context, sandboxID string, result *cni.Result) { if logrus.GetLevel() < logrus.DebugLevel { return } diff --git a/pkg/cri/server/sandbox_status.go b/pkg/cri/server/sandbox_status.go index 8c097a007..f669204f1 100644 --- a/pkg/cri/server/sandbox_status.go +++ b/pkg/cri/server/sandbox_status.go @@ -139,7 +139,7 @@ type SandboxInfo struct { RuntimeOptions interface{} `json:"runtimeOptions"` Config *runtime.PodSandboxConfig `json:"config"` RuntimeSpec *runtimespec.Spec `json:"runtimeSpec"` - CNIResult *cni.CNIResult `json:"cniResult"` + CNIResult *cni.Result `json:"cniResult"` } // toCRISandboxInfo converts internal container object information to CRI sandbox status response info map. diff --git a/pkg/cri/server/service_linux.go b/pkg/cri/server/service_linux.go index 5cd2916ce..1cd2c6aaa 100644 --- a/pkg/cri/server/service_linux.go +++ b/pkg/cri/server/service_linux.go @@ -73,6 +73,6 @@ func (c *criService) initPlatform() error { } // cniLoadOptions returns cni load options for the linux. -func (c *criService) cniLoadOptions() []cni.CNIOpt { - return []cni.CNIOpt{cni.WithLoNetwork, cni.WithDefaultConf} +func (c *criService) cniLoadOptions() []cni.Opt { + return []cni.Opt{cni.WithLoNetwork, cni.WithDefaultConf} } diff --git a/pkg/cri/server/service_other.go b/pkg/cri/server/service_other.go index c17f7ccae..fc6cd51f7 100644 --- a/pkg/cri/server/service_other.go +++ b/pkg/cri/server/service_other.go @@ -28,6 +28,6 @@ func (c *criService) initPlatform() error { } // cniLoadOptions returns cni load options for the linux. -func (c *criService) cniLoadOptions() []cni.CNIOpt { - return []cni.CNIOpt{} +func (c *criService) cniLoadOptions() []cni.Opt { + return []cni.Opt{} } diff --git a/pkg/cri/server/service_windows.go b/pkg/cri/server/service_windows.go index 5f764d452..dff475944 100644 --- a/pkg/cri/server/service_windows.go +++ b/pkg/cri/server/service_windows.go @@ -47,6 +47,6 @@ func (c *criService) initPlatform() error { } // cniLoadOptions returns cni load options for the windows. -func (c *criService) cniLoadOptions() []cni.CNIOpt { - return []cni.CNIOpt{cni.WithDefaultConf} +func (c *criService) cniLoadOptions() []cni.Opt { + return []cni.Opt{cni.WithDefaultConf} } diff --git a/pkg/cri/server/testing/fake_cni_plugin.go b/pkg/cri/server/testing/fake_cni_plugin.go index 71a930f59..15dd49614 100644 --- a/pkg/cri/server/testing/fake_cni_plugin.go +++ b/pkg/cri/server/testing/fake_cni_plugin.go @@ -34,7 +34,7 @@ func NewFakeCNIPlugin() *FakeCNIPlugin { } // Setup setups the network of PodSandbox. -func (f *FakeCNIPlugin) Setup(ctx context.Context, id, path string, opts ...cni.NamespaceOpts) (*cni.CNIResult, error) { +func (f *FakeCNIPlugin) Setup(ctx context.Context, id, path string, opts ...cni.NamespaceOpts) (*cni.Result, error) { return nil, nil } @@ -49,7 +49,7 @@ func (f *FakeCNIPlugin) Status() error { } // Load loads the network config. -func (f *FakeCNIPlugin) Load(opts ...cni.CNIOpt) error { +func (f *FakeCNIPlugin) Load(opts ...cni.Opt) error { return f.LoadErr } diff --git a/pkg/cri/store/sandbox/metadata.go b/pkg/cri/store/sandbox/metadata.go index eb3aa8e83..f8c5d4d33 100644 --- a/pkg/cri/store/sandbox/metadata.go +++ b/pkg/cri/store/sandbox/metadata.go @@ -60,7 +60,7 @@ type Metadata struct { // RuntimeHandler is the runtime handler name of the pod. RuntimeHandler string // CNIresult resulting configuration for attached network namespace interfaces - CNIResult *cni.CNIResult + CNIResult *cni.Result // ProcessLabel is the SELinux process label for the container ProcessLabel string } diff --git a/vendor/github.com/containerd/go-cni/.golangci.yml b/vendor/github.com/containerd/go-cni/.golangci.yml new file mode 100644 index 000000000..75f462ee0 --- /dev/null +++ b/vendor/github.com/containerd/go-cni/.golangci.yml @@ -0,0 +1,23 @@ +linters: + enable: + - structcheck + - varcheck + - staticcheck + - unconvert + - gofmt + - goimports + - golint + - ineffassign + - vet + - unused + - misspell + disable: + - errcheck + +# FIXME: re-enable after fixing GoDoc in this repository +#issues: +# include: +# - EXC0002 + +run: + timeout: 2m diff --git a/vendor/github.com/containerd/go-cni/.travis.yml b/vendor/github.com/containerd/go-cni/.travis.yml deleted file mode 100644 index da541b4cf..000000000 --- a/vendor/github.com/containerd/go-cni/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: go -go: - - 1.13.x - - 1.14.x - - tip - -go_import_path: github.com/containerd/go-cni - -install: - - go get -d - - env GO111MODULE=off go get -u github.com/vbatts/git-validation - - env GO111MODULE=off go get -u github.com/kunalkushwaha/ltag - -before_script: - - pushd ..; git clone https://github.com/containerd/project; popd - -script: - - DCO_VERBOSITY=-q ../project/script/validate/dco - - ../project/script/validate/fileheader ../project/ - - env GO111MODULE=on ../project/script/validate/vendor - - go test -race -coverprofile=coverage.txt -covermode=atomic - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/containerd/go-cni/README.md b/vendor/github.com/containerd/go-cni/README.md index 837cb467d..b2652c48d 100644 --- a/vendor/github.com/containerd/go-cni/README.md +++ b/vendor/github.com/containerd/go-cni/README.md @@ -1,7 +1,10 @@ -[![Build Status](https://travis-ci.org/containerd/go-cni.svg?branch=master)](https://travis-ci.org/containerd/go-cni) [![GoDoc](https://godoc.org/github.com/containerd/go-cni?status.svg)](https://godoc.org/github.com/containerd/go-cni) - # go-cni +[![PkgGoDev](https://pkg.go.dev/badge/github.com/containerd/go-cni)](https://pkg.go.dev/github.com/containerd/go-cni) +[![Build Status](https://github.com/containerd/go-cni/workflows/CI/badge.svg)](https://github.com/containerd/go-cni/actions?query=workflow%3ACI) +[![codecov](https://codecov.io/gh/containerd/go-cni/branch/master/graph/badge.svg)](https://codecov.io/gh/containerd/go-cni) +[![Go Report Card](https://goreportcard.com/badge/github.com/containerd/go-cni)](https://goreportcard.com/report/github.com/containerd/go-cni) + A generic CNI library to provide APIs for CNI plugin interactions. The library provides APIs to: - Load CNI network config from different sources diff --git a/vendor/github.com/containerd/go-cni/cni.go b/vendor/github.com/containerd/go-cni/cni.go index 8acc83b33..2806cafaf 100644 --- a/vendor/github.com/containerd/go-cni/cni.go +++ b/vendor/github.com/containerd/go-cni/cni.go @@ -30,11 +30,11 @@ import ( type CNI interface { // Setup setup the network for the namespace - Setup(ctx context.Context, id string, path string, opts ...NamespaceOpts) (*CNIResult, error) + Setup(ctx context.Context, id string, path string, opts ...NamespaceOpts) (*Result, error) // Remove tears down the network of the namespace. Remove(ctx context.Context, id string, path string, opts ...NamespaceOpts) error // Load loads the cni network config - Load(opts ...CNIOpt) error + Load(opts ...Opt) error // Status checks the status of the cni initialization Status() error // GetConfig returns a copy of the CNI plugin configurations as parsed by CNI @@ -93,7 +93,7 @@ func defaultCNIConfig() *libcni { } // New creates a new libcni instance. -func New(config ...CNIOpt) (CNI, error) { +func New(config ...Opt) (CNI, error) { cni := defaultCNIConfig() var err error for _, c := range config { @@ -105,7 +105,7 @@ func New(config ...CNIOpt) (CNI, error) { } // Load loads the latest config from cni config files. -func (c *libcni) Load(opts ...CNIOpt) error { +func (c *libcni) Load(opts ...Opt) error { var err error c.Lock() defer c.Unlock() @@ -139,8 +139,8 @@ func (c *libcni) Networks() []*Network { return append([]*Network{}, c.networks...) } -// Setup setups the network in the namespace -func (c *libcni) Setup(ctx context.Context, id string, path string, opts ...NamespaceOpts) (*CNIResult, error) { +// Setup setups the network in the namespace and returns a Result +func (c *libcni) Setup(ctx context.Context, id string, path string, opts ...NamespaceOpts) (*Result, error) { if err := c.Status(); err != nil { return nil, err } @@ -148,6 +148,14 @@ func (c *libcni) Setup(ctx context.Context, id string, path string, opts ...Name if err != nil { return nil, err } + result, err := c.attachNetworks(ctx, ns) + if err != nil { + return nil, err + } + return c.createResult(result) +} + +func (c *libcni) attachNetworks(ctx context.Context, ns *Namespace) ([]*current.Result, error) { var results []*current.Result for _, network := range c.Networks() { r, err := network.Attach(ctx, ns) @@ -156,7 +164,7 @@ func (c *libcni) Setup(ctx context.Context, id string, path string, opts ...Name } results = append(results, r) } - return c.GetCNIResultFromResults(results) + return results, nil } // Remove removes the network config from the namespace diff --git a/vendor/github.com/containerd/go-cni/deprecated.go b/vendor/github.com/containerd/go-cni/deprecated.go new file mode 100644 index 000000000..158793b70 --- /dev/null +++ b/vendor/github.com/containerd/go-cni/deprecated.go @@ -0,0 +1,34 @@ +/* + Copyright The containerd 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 cni + +import "github.com/containernetworking/cni/pkg/types/current" + +// Deprecated: use cni.Opt instead +type CNIOpt = Opt //nolint: golint // type name will be used as cni.CNIOpt by other packages, and that stutters + +// Deprecated: use cni.Result instead +type CNIResult = Result //nolint: golint // type name will be used as cni.CNIResult by other packages, and that stutters + +// GetCNIResultFromResults creates a Result from the given slice of current.Result, +// adding structured data containing the interface configuration for each of the +// interfaces created in the namespace. It returns an error if validation of +// results fails, or if a network could not be found. +// Deprecated: do not use +func (c *libcni) GetCNIResultFromResults(results []*current.Result) (*Result, error) { + return c.createResult(results) +} diff --git a/vendor/github.com/containerd/go-cni/go.mod b/vendor/github.com/containerd/go-cni/go.mod index 0185c1805..3c75aa998 100644 --- a/vendor/github.com/containerd/go-cni/go.mod +++ b/vendor/github.com/containerd/go-cni/go.mod @@ -6,9 +6,7 @@ require ( github.com/onsi/ginkgo v1.10.3 // indirect github.com/onsi/gomega v1.7.1 // indirect github.com/pkg/errors v0.9.1 - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f // indirect - github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d + github.com/stretchr/testify v1.6.1 ) go 1.13 diff --git a/vendor/github.com/containerd/go-cni/go.sum b/vendor/github.com/containerd/go-cni/go.sum index d173e02d9..346ca3f40 100644 --- a/vendor/github.com/containerd/go-cni/go.sum +++ b/vendor/github.com/containerd/go-cni/go.sum @@ -1,5 +1,6 @@ github.com/containernetworking/cni v0.8.0 h1:BT9lpgGoH4jw3lFC7Odz2prU5ruiYKcgAjMCbgybcKI= github.com/containernetworking/cni v0.8.0/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= @@ -17,10 +18,10 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f h1:SrOsK2rwonEK9IsdNEU61zcTdKW68/PuV9wuHHpqngk= -github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d h1:YCdGqZILKLGzbyEYbdau30JBEXbKaKYmkBDU5JUW3D0= -github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= @@ -37,3 +38,5 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/vendor/github.com/containerd/go-cni/opts.go b/vendor/github.com/containerd/go-cni/opts.go index 1dd7869a2..9ced1d7e7 100644 --- a/vendor/github.com/containerd/go-cni/opts.go +++ b/vendor/github.com/containerd/go-cni/opts.go @@ -24,11 +24,12 @@ import ( "github.com/pkg/errors" ) -type CNIOpt func(c *libcni) error +// Opt sets options for a CNI instance +type Opt func(c *libcni) error // WithInterfacePrefix sets the prefix for network interfaces // e.g. eth or wlan -func WithInterfacePrefix(prefix string) CNIOpt { +func WithInterfacePrefix(prefix string) Opt { return func(c *libcni) error { c.prefix = prefix return nil @@ -37,7 +38,7 @@ func WithInterfacePrefix(prefix string) CNIOpt { // WithPluginDir can be used to set the locations of // the cni plugin binaries -func WithPluginDir(dirs []string) CNIOpt { +func WithPluginDir(dirs []string) Opt { return func(c *libcni) error { c.pluginDirs = dirs c.cniConfig = &cnilibrary.CNIConfig{Path: dirs} @@ -47,7 +48,7 @@ func WithPluginDir(dirs []string) CNIOpt { // WithPluginConfDir can be used to configure the // cni configuration directory. -func WithPluginConfDir(dir string) CNIOpt { +func WithPluginConfDir(dir string) Opt { return func(c *libcni) error { c.pluginConfDir = dir return nil @@ -56,7 +57,7 @@ func WithPluginConfDir(dir string) CNIOpt { // WithPluginMaxConfNum can be used to configure the // max cni plugin config file num. -func WithPluginMaxConfNum(max int) CNIOpt { +func WithPluginMaxConfNum(max int) Opt { return func(c *libcni) error { c.pluginMaxConfNum = max return nil @@ -66,7 +67,7 @@ func WithPluginMaxConfNum(max int) CNIOpt { // WithMinNetworkCount can be used to configure the // minimum networks to be configured and initialized // for the status to report success. By default its 1. -func WithMinNetworkCount(count int) CNIOpt { +func WithMinNetworkCount(count int) Opt { return func(c *libcni) error { c.networkCount = count return nil @@ -94,13 +95,13 @@ func WithLoNetwork(c *libcni) error { // WithConf can be used to load config directly // from byte. -func WithConf(bytes []byte) CNIOpt { +func WithConf(bytes []byte) Opt { return WithConfIndex(bytes, 0) } // WithConfIndex can be used to load config directly // from byte and set the interface name's index. -func WithConfIndex(bytes []byte, index int) CNIOpt { +func WithConfIndex(bytes []byte, index int) Opt { return func(c *libcni) error { conf, err := cnilibrary.ConfFromBytes(bytes) if err != nil { @@ -122,7 +123,7 @@ func WithConfIndex(bytes []byte, index int) CNIOpt { // WithConfFile can be used to load network config // from an .conf file. Supported with absolute fileName // with path only. -func WithConfFile(fileName string) CNIOpt { +func WithConfFile(fileName string) Opt { return func(c *libcni) error { conf, err := cnilibrary.ConfFromFile(fileName) if err != nil { @@ -144,7 +145,7 @@ func WithConfFile(fileName string) CNIOpt { // WithConfListBytes can be used to load network config list directly // from byte -func WithConfListBytes(bytes []byte) CNIOpt { +func WithConfListBytes(bytes []byte) Opt { return func(c *libcni) error { confList, err := cnilibrary.ConfListFromBytes(bytes) if err != nil { @@ -163,7 +164,7 @@ func WithConfListBytes(bytes []byte) CNIOpt { // WithConfListFile can be used to load network config // from an .conflist file. Supported with absolute fileName // with path only. -func WithConfListFile(fileName string) CNIOpt { +func WithConfListFile(fileName string) Opt { return func(c *libcni) error { confList, err := cnilibrary.ConfListFromFile(fileName) if err != nil { diff --git a/vendor/github.com/containerd/go-cni/result.go b/vendor/github.com/containerd/go-cni/result.go index c2ac94864..3d21d7045 100644 --- a/vendor/github.com/containerd/go-cni/result.go +++ b/vendor/github.com/containerd/go-cni/result.go @@ -29,7 +29,17 @@ type IPConfig struct { Gateway net.IP } -type CNIResult struct { +// Result contains the network information returned by CNI.Setup +// +// a) Interfaces list. Depending on the plugin, this can include the sandbox +// (eg, container or hypervisor) interface name and/or the host interface +// name, the hardware addresses of each interface, and details about the +// sandbox (if any) the interface is in. +// b) IP configuration assigned to each interface. The IPv4 and/or IPv6 addresses, +// gateways, and routes assigned to sandbox and/or host interfaces. +// c) DNS information. Dictionary that includes DNS information for nameservers, +// domain, search domains and options. +type Result struct { Interfaces map[string]*Config DNS []types.DNS Routes []*types.Route @@ -41,23 +51,14 @@ type Config struct { Sandbox string } -// GetCNIResultFromResults returns a structured data containing the -// interface configuration for each of the interfaces created in the namespace. -// Conforms with -// Result: -// a) Interfaces list. Depending on the plugin, this can include the sandbox -// (eg, container or hypervisor) interface name and/or the host interface -// name, the hardware addresses of each interface, and details about the -// sandbox (if any) the interface is in. -// b) IP configuration assigned to each interface. The IPv4 and/or IPv6 addresses, -// gateways, and routes assigned to sandbox and/or host interfaces. -// c) DNS information. Dictionary that includes DNS information for nameservers, -// domain, search domains and options. -func (c *libcni) GetCNIResultFromResults(results []*current.Result) (*CNIResult, error) { +// createResult creates a Result from the given slice of current.Result, adding +// structured data containing the interface configuration for each of the +// interfaces created in the namespace. It returns an error if validation of +// results fails, or if a network could not be found. +func (c *libcni) createResult(results []*current.Result) (*Result, error) { c.RLock() defer c.RUnlock() - - r := &CNIResult{ + r := &Result{ Interfaces: make(map[string]*Config), } diff --git a/vendor/modules.txt b/vendor/modules.txt index 27881d9b5..e3f8a709f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -82,7 +82,7 @@ github.com/containerd/continuity/testutil/loopback # github.com/containerd/fifo v0.0.0-20210316144830-115abcc95a1d ## explicit github.com/containerd/fifo -# github.com/containerd/go-cni v1.0.1 +# github.com/containerd/go-cni v1.0.2 ## explicit github.com/containerd/go-cni # github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0