From ec7851cf770bf59a77b94c70ca9ce18c44657f65 Mon Sep 17 00:00:00 2001 From: Nikhil Simha Date: Thu, 28 May 2020 16:43:59 -0400 Subject: [PATCH] Restructured multus to use Go standard project layout. --- .../workflows/docker-build-push-master.yml | 8 +- .../workflows/docker-build-push-release.yml | 8 +- .github/workflows/docker-build.yml | 6 +- .github/workflows/go-build-arm64.yml | 2 +- .github/workflows/go-build-ppc64.yml | 2 +- .github/workflows/go-build-test-amd64.yml | 4 +- .github/workflows/kind-e2e.yml | 2 +- .travis.yml | 116 +++++++++++ cmd/main.go | 60 ++++++ Dockerfile => deployments/Dockerfile | 2 +- .../Dockerfile.arm64 | 2 +- .../Dockerfile.openshift | 3 +- .../Dockerfile.ppc64le | 2 +- {doc => docs}/configuration.md | 0 {doc => docs}/development.md | 6 +- {doc => docs}/how-to-use.md | 0 {doc => docs}/images/Multus.png | Bin {doc => docs}/images/multus-pod-image.svg | 0 {doc => docs}/images/multus_cni_pod.png | Bin .../images/multus_crd_usage_diagram.JPG | Bin {doc => docs}/images/workflow.png | Bin {doc => docs}/node-kubeconfig.yaml | 0 {doc => docs}/quickstart.md | 0 build => hack/build-go.sh | 5 +- hack/nikhil-build.sh | 51 +++++ test.sh => hack/test-go.sh | 0 {checkpoint => pkg/checkpoint}/checkpoint.go | 4 +- .../checkpoint}/checkpoint_test.go | 2 +- {k8sclient => pkg/k8sclient}/k8sclient.go | 6 +- .../k8sclient}/k8sclient_test.go | 4 +- .../kubeletclient}/kubeletclient.go | 6 +- .../kubeletclient}/kubeletclient_test.go | 2 +- {logging => pkg/logging}/logging.go | 0 {logging => pkg/logging}/logging_test.go | 0 {multus => pkg/multus}/multus.go | 38 ++-- {multus => pkg/multus}/multus_test.go | 181 +++++++++--------- {netutils => pkg/netutils}/netutils.go | 2 +- {testing => pkg/testing}/testing.go | 0 {types => pkg/types}/conf.go | 2 +- {types => pkg/types}/conf_test.go | 2 +- {types => pkg/types}/types.go | 0 restructure.txt | 45 +++++ .../github.com/json-iterator/go/.travis.yml | 2 +- .../modern-go/concurrent/.travis.yml | 2 +- .../github.com/modern-go/reflect2/.travis.yml | 2 +- 45 files changed, 424 insertions(+), 155 deletions(-) create mode 100644 .travis.yml create mode 100644 cmd/main.go rename Dockerfile => deployments/Dockerfile (96%) rename Dockerfile.arm64 => deployments/Dockerfile.arm64 (94%) rename Dockerfile.openshift => deployments/Dockerfile.openshift (92%) rename Dockerfile.ppc64le => deployments/Dockerfile.ppc64le (96%) rename {doc => docs}/configuration.md (100%) rename {doc => docs}/development.md (93%) rename {doc => docs}/how-to-use.md (100%) rename {doc => docs}/images/Multus.png (100%) rename {doc => docs}/images/multus-pod-image.svg (100%) rename {doc => docs}/images/multus_cni_pod.png (100%) rename {doc => docs}/images/multus_crd_usage_diagram.JPG (100%) rename {doc => docs}/images/workflow.png (100%) rename {doc => docs}/node-kubeconfig.yaml (100%) rename {doc => docs}/quickstart.md (100%) rename build => hack/build-go.sh (85%) create mode 100755 hack/nikhil-build.sh rename test.sh => hack/test-go.sh (100%) rename {checkpoint => pkg/checkpoint}/checkpoint.go (97%) rename {checkpoint => pkg/checkpoint}/checkpoint_test.go (99%) rename {k8sclient => pkg/k8sclient}/k8sclient.go (99%) rename {k8sclient => pkg/k8sclient}/k8sclient_test.go (99%) rename {kubeletclient => pkg/kubeletclient}/kubeletclient.go (96%) rename {kubeletclient => pkg/kubeletclient}/kubeletclient_test.go (99%) rename {logging => pkg/logging}/logging.go (100%) rename {logging => pkg/logging}/logging_test.go (100%) rename {multus => pkg/multus}/multus.go (96%) rename {multus => pkg/multus}/multus_test.go (95%) rename {netutils => pkg/netutils}/netutils.go (98%) rename {testing => pkg/testing}/testing.go (100%) rename {types => pkg/types}/conf.go (99%) rename {types => pkg/types}/conf_test.go (99%) rename {types => pkg/types}/types.go (100%) create mode 100644 restructure.txt diff --git a/.github/workflows/docker-build-push-master.yml b/.github/workflows/docker-build-push-master.yml index 1e6357681..de0433102 100644 --- a/.github/workflows/docker-build-push-master.yml +++ b/.github/workflows/docker-build-push-master.yml @@ -18,16 +18,16 @@ jobs: uses: actions/checkout@v2 - name: Build latest-amd64 - run: docker build -t ${REPOSITORY}:latest-amd64 . + run: docker build -t ${REPOSITORY}:latest-amd64 -f deployments/Dockerfile . - name: Build latest-ppc64le - run: docker build -t ${REPOSITORY}:latest-ppc64le -f Dockerfile.ppc64le . + run: docker build -t ${REPOSITORY}:latest-ppc64le -f deployments/Dockerfile.ppc64le . - name: Build latest-arm64v8 - run: docker build -t ${REPOSITORY}:latest-arm64v8 -f Dockerfile.arm64 . + run: docker build -t ${REPOSITORY}:latest-arm64v8 -f deployments/Dockerfile.arm64 . - name: Build latest-origin - run: docker build -t ${REPOSITORY}:latest-origin -f Dockerfile.openshift . + run: docker build -t ${REPOSITORY}:latest-origin -f deployments/Dockerfile.openshift . - name: Tag snapshot run: | diff --git a/.github/workflows/docker-build-push-release.yml b/.github/workflows/docker-build-push-release.yml index 64c5972a0..e0ba6bd8c 100644 --- a/.github/workflows/docker-build-push-release.yml +++ b/.github/workflows/docker-build-push-release.yml @@ -18,16 +18,16 @@ jobs: uses: actions/checkout@v2 - name: Build latest-amd64 - run: docker build -t ${REPOSITORY}:latest-amd64 . + run: docker build -t ${REPOSITORY}:latest-amd64 -f deployments/Dockerfile . - name: Build latest-ppc64le - run: docker build -t ${REPOSITORY}:latest-ppc64le -f Dockerfile.ppc64le . + run: docker build -t ${REPOSITORY}:latest-ppc64le -f deployments/Dockerfile.ppc64le . - name: Build latest-arm64v8 - run: docker build -t ${REPOSITORY}:latest-arm64v8 -f Dockerfile.arm64 . + run: docker build -t ${REPOSITORY}:latest-arm64v8 -f deployments/Dockerfile.arm64 . - name: Build latest-origin - run: docker build -t ${REPOSITORY}:latest-origin -f Dockerfile.openshift . + run: docker build -t ${REPOSITORY}:latest-origin -f deployments/Dockerfile.openshift . - name: Tag stable run: | diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index d83e8a348..fcea47efc 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -13,10 +13,10 @@ jobs: uses: actions/checkout@v2 - name: Build latest-amd64 - run: docker build -t ${REPOSITORY}:latest-amd64 . + run: docker build -t ${REPOSITORY}:latest-amd64 -f deployments/Dockerfile . - name: Build latest-ppc64le - run: docker build -t ${REPOSITORY}:latest-ppc64le -f Dockerfile.ppc64le . + run: docker build -t ${REPOSITORY}:latest-ppc64le -f deployments/Dockerfile.ppc64le . - name: Build latest-origin - run: docker build -t ${REPOSITORY}:latest-origin -f Dockerfile.openshift . + run: docker build -t ${REPOSITORY}:latest-origin -f deployments/Dockerfile.openshift . diff --git a/.github/workflows/go-build-arm64.yml b/.github/workflows/go-build-arm64.yml index c44629609..f6658e76f 100644 --- a/.github/workflows/go-build-arm64.yml +++ b/.github/workflows/go-build-arm64.yml @@ -22,4 +22,4 @@ jobs: uses: actions/checkout@v2 - name: Build - run: GOARCH="${TARGET}" ./build + run: GOARCH="${TARGET}" ./hack/build-go.sh diff --git a/.github/workflows/go-build-ppc64.yml b/.github/workflows/go-build-ppc64.yml index a185a1672..ba6242371 100644 --- a/.github/workflows/go-build-ppc64.yml +++ b/.github/workflows/go-build-ppc64.yml @@ -22,4 +22,4 @@ jobs: uses: actions/checkout@v2 - name: Build - run: GOARCH="${TARGET}" ./build + run: GOARCH="${TARGET}" ./hack/build-go.sh diff --git a/.github/workflows/go-build-test-amd64.yml b/.github/workflows/go-build-test-amd64.yml index c17b0996d..26498af48 100644 --- a/.github/workflows/go-build-test-amd64.yml +++ b/.github/workflows/go-build-test-amd64.yml @@ -37,10 +37,10 @@ jobs: run: go vet ./... - name: Build - run: GOARCH="${TARGET}" ./build + run: GOARCH="${TARGET}" ./hack/build-go.sh - name: Go test - run: sudo ./test.sh + run: sudo ./hack/test-go.sh - name: goveralls uses: shogo82148/actions-goveralls@v1 diff --git a/.github/workflows/kind-e2e.yml b/.github/workflows/kind-e2e.yml index 308dd3f8c..b5a374cc9 100644 --- a/.github/workflows/kind-e2e.yml +++ b/.github/workflows/kind-e2e.yml @@ -16,7 +16,7 @@ jobs: run: docker run -d --restart=always -p "5000:5000" --name "kind-registry" registry:2 - name: Build latest-amd64 - run: docker build -t localhost:5000/multus:e2e . + run: docker build -t localhost:5000/multus:e2e -f deployments/Dockerfile . - name: Push to local registry run: docker push localhost:5000/multus:e2e diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..e48b1bf77 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,116 @@ +os: linux +language: go +# see https://docs.travis-ci.com/user/reference/overview/#Virtualization-environments +# for the detail +# sudo: requried +dist: bionic + +services: + - docker + +go: + - 1.13.x + +env: + global: + - GO111MODULE=on + - REGISTRY_USER=${REGISTRY_USER:-nfvpe} + - REGISTRY_PASS=${REGISTRY_PASS} + - REPOSITORY_NAME=${REPOSITORY_NAME} + - REPOSITORY_USER=${REPOSITORY_USER} + - DOCKER_CLI_EXPERIMENTAL="enabled" + - secure: "${REGISTRY_SECURE}" + jobs: + - TARGET=amd64 + - TARGET=ppc64le + +before_install: + - if [ "${REPOSITORY_NAME}" = "" ]; then export REPOSITORY_NAME=multus; fi + - sudo apt-get update -qq + - go get github.com/mattn/goveralls + +install: + - go get -u golang.org/x/lint/golint + +before_script: + # Make gopath... to run golint/go fmt/go vet + # Suppress golint for fixing lint later. + - golint ./... | grep -v vendor | grep -v ALL_CAPS | xargs -r false + - go fmt ./... + - go vet ./... +# - gocyclo -over 15 ./multus + +script: + - GOARCH="${TARGET}" ./hack/build-go.sh + - | + if [ "${TARGET}" == "amd64" ]; then + sudo env PATH=${PATH} ./scripts/test.sh + goveralls -coverprofile=coverage.out -service=travis-ci + docker build -t ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64 . + docker build -t ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-ppc64le -f Dockerfile.ppc64le . + docker build -t ${REPOSITORY_USER}/${REPOSITORY_NAME}-origin:latest -f Dockerfile.openshift . + fi + +deploy: + # Release on versioned tag (e.g. v1.0) + - provider: script + #cleanup: false + script: curl -sL https://git.io/goreleaser + on: + tags: true + all_branches: true + condition: "$TARGET = amd64 && $TRAVIS_TAG =~ ^v[0-9].*$ && ! -z $GITHUB_TOKEN && $TRAVIS_OS_NAME = linux" + # Push images to Dockerhub on tag + - provider: script + cleanup: false + script: > + bash -c ' + docker tag ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64 ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest; + docker tag ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64 ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable; + docker tag ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64 ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable-amd64; + docker tag ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64 ${REPOSITORY_USER}/${REPOSITORY_NAME}:$TRAVIS_TAG; + docker tag ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-ppc64le ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable-ppc64le; + docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASS"; + docker push ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64; + docker push ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-ppc64le; + docker push ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable-amd64; + docker push ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable-ppc64le; + docker push ${REPOSITORY_USER}/${REPOSITORY_NAME}:$TRAVIS_TAG; + export DOCKER_CLI_EXPERIMENTAL="enabled"; + docker manifest create ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64 ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-ppc64le; + docker manifest annotate ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64 --arch amd64; + docker manifest annotate ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-ppc64le --arch ppc64le; + docker manifest push ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest; + docker manifest create ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable-amd64 ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable-ppc64le; + docker manifest annotate ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable-amd64 --arch amd64; + docker manifest annotate ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable-ppc64le --arch ppc64le; + docker manifest push ${REPOSITORY_USER}/${REPOSITORY_NAME}:stable; + echo done' + on: + tags: true + all_branches: true + condition: "$TRAVIS_TAG =~ ^v[0-9].*$ && -n $REGISTRY_USER && -n $REGISTRY_PASS && -n $REPOSITORY_NAME && -n $REPOSITORY_USER" + # Push images to Dockerhub on merge to master + - provider: script + on: + branch: master + condition: "-n $REGISTRY_USER && -n $REGISTRY_PASS && -n $REPOSITORY_NAME && -n $REPOSITORY_USER" + script: > + bash -c ' + docker tag ${REPOSITORY_USER}/:latest-amd64 ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot; + docker tag ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64 ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot-amd64; + docker tag ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-ppc64le ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot-ppc64le; + docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASS"; + docker push ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot-amd64; + docker push ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot-ppc64le; + docker push ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64; + docker push ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-ppc64le; + docker manifest create ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot-amd64 ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot-ppc64le; + docker manifest annotate ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot-amd64 --arch amd64; + docker manifest annotate ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot-ppc64le --arch ppc64le; + docker manifest push ${REPOSITORY_USER}/${REPOSITORY_NAME}:snapshot; + docker manifest create ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64 ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-ppc64le; + docker manifest annotate ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-amd64 --arch amd64; + docker manifest annotate ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest-ppc64le --arch ppc64le; + docker manifest push ${REPOSITORY_USER}/${REPOSITORY_NAME}:latest; + echo done' diff --git a/cmd/main.go b/cmd/main.go new file mode 100644 index 000000000..4cb421ad9 --- /dev/null +++ b/cmd/main.go @@ -0,0 +1,60 @@ +// Copyright (c) 2017 Intel Corporation +// +// 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. + +// This is a "Multi-plugin".The delegate concept refered from CNI project +// It reads other plugin netconf, and then invoke them, e.g. +// flannel or sriov plugin. + +package main + +import ( + "flag" + "fmt" + "os" + + "gopkg.in/intel/multus-cni.v3/pkg/multus" + "github.com/containernetworking/cni/pkg/skel" + cniversion "github.com/containernetworking/cni/pkg/version" +) + + +func main() { + + // Init command line flags to clear vendored packages' one, especially in init() + flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError) + + // add version flag + versionOpt := false + flag.BoolVar(&versionOpt, "version", false, "Show application version") + flag.BoolVar(&versionOpt, "v", false, "Show application version") + flag.Parse() + if versionOpt == true { + fmt.Printf("%s\n", multus.PrintVersionString()) + return + } + + skel.PluginMain( + func(args *skel.CmdArgs) error { + result, err := multus.CmdAdd(args, nil, nil) + if err != nil { + return err + } + return result.Print() + }, + func(args *skel.CmdArgs) error { + return multus.CmdCheck(args, nil, nil) + }, + func(args *skel.CmdArgs) error { return multus.CmdDel(args, nil, nil) }, + cniversion.All, "meta-plugin that delegates to other CNI plugins") +} diff --git a/Dockerfile b/deployments/Dockerfile similarity index 96% rename from Dockerfile rename to deployments/Dockerfile index 396afe46d..4593c6287 100644 --- a/Dockerfile +++ b/deployments/Dockerfile @@ -10,7 +10,7 @@ RUN rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO && \ yum install -y $INSTALL_PKGS && \ rpm -V $INSTALL_PKGS && \ cd /usr/src/multus-cni && \ - ./build + ./hack/build-go.sh FROM centos:centos7 COPY --from=build /usr/src/multus-cni /usr/src/multus-cni diff --git a/Dockerfile.arm64 b/deployments/Dockerfile.arm64 similarity index 94% rename from Dockerfile.arm64 rename to deployments/Dockerfile.arm64 index 2105f2ad3..de13da74b 100644 --- a/Dockerfile.arm64 +++ b/deployments/Dockerfile.arm64 @@ -8,7 +8,7 @@ ENV GOARCH "arm64" ENV GOOS "linux" RUN cd /usr/src/multus-cni && \ - ./build + ./hack/build-go.sh # build arm64 container FROM arm64v8/centos:7 diff --git a/Dockerfile.openshift b/deployments/Dockerfile.openshift similarity index 92% rename from Dockerfile.openshift rename to deployments/Dockerfile.openshift index c0431eada..ddb3b9d2d 100644 --- a/Dockerfile.openshift +++ b/deployments/Dockerfile.openshift @@ -5,7 +5,8 @@ ADD . /usr/src/multus-cni WORKDIR /usr/src/multus-cni ENV GO111MODULE=off -RUN ./build +ENV GOBIN=/usr/src/multus-cni/bin +RUN ./hack/build-go.sh FROM openshift/origin-base RUN mkdir -p /usr/src/multus-cni/images && mkdir -p /usr/src/multus-cni/bin diff --git a/Dockerfile.ppc64le b/deployments/Dockerfile.ppc64le similarity index 96% rename from Dockerfile.ppc64le rename to deployments/Dockerfile.ppc64le index d56ff3751..7e26f1f2e 100644 --- a/Dockerfile.ppc64le +++ b/deployments/Dockerfile.ppc64le @@ -13,7 +13,7 @@ RUN rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO && \ yum install -y $INSTALL_PKGS && \ rpm -V $INSTALL_PKGS && \ cd /usr/src/multus-cni && \ - ./build + ./hack/build-go.sh # build ppc container FROM ppc64le/centos:latest diff --git a/doc/configuration.md b/docs/configuration.md similarity index 100% rename from doc/configuration.md rename to docs/configuration.md diff --git a/doc/development.md b/docs/development.md similarity index 93% rename from doc/development.md rename to docs/development.md index 466a0b156..da3c4527f 100644 --- a/doc/development.md +++ b/docs/development.md @@ -22,12 +22,12 @@ If an issue is closed that you don't feel is sufficiently resolved, please feel ## How do I build multus-cni? -You can use the built in `./build` script! +You can use the built in `./hack/build-go.sh` script! ``` git clone https://github.com/intel/multus-cni.git cd multus-cni -./build +./hack/build-go.sh ``` ## How do I run CI tests? @@ -35,7 +35,7 @@ cd multus-cni Multus has go unit tests (based on ginkgo framework).The following commands drive CI tests manually in your environment: ``` -sudo ./test.sh +sudo ./scripts/test.sh ``` ## What are the best practices for logging? diff --git a/doc/how-to-use.md b/docs/how-to-use.md similarity index 100% rename from doc/how-to-use.md rename to docs/how-to-use.md diff --git a/doc/images/Multus.png b/docs/images/Multus.png similarity index 100% rename from doc/images/Multus.png rename to docs/images/Multus.png diff --git a/doc/images/multus-pod-image.svg b/docs/images/multus-pod-image.svg similarity index 100% rename from doc/images/multus-pod-image.svg rename to docs/images/multus-pod-image.svg diff --git a/doc/images/multus_cni_pod.png b/docs/images/multus_cni_pod.png similarity index 100% rename from doc/images/multus_cni_pod.png rename to docs/images/multus_cni_pod.png diff --git a/doc/images/multus_crd_usage_diagram.JPG b/docs/images/multus_crd_usage_diagram.JPG similarity index 100% rename from doc/images/multus_crd_usage_diagram.JPG rename to docs/images/multus_crd_usage_diagram.JPG diff --git a/doc/images/workflow.png b/docs/images/workflow.png similarity index 100% rename from doc/images/workflow.png rename to docs/images/workflow.png diff --git a/doc/node-kubeconfig.yaml b/docs/node-kubeconfig.yaml similarity index 100% rename from doc/node-kubeconfig.yaml rename to docs/node-kubeconfig.yaml diff --git a/doc/quickstart.md b/docs/quickstart.md similarity index 100% rename from doc/quickstart.md rename to docs/quickstart.md diff --git a/build b/hack/build-go.sh similarity index 85% rename from build rename to hack/build-go.sh index 60b5d0404..f0cb2aa02 100755 --- a/build +++ b/hack/build-go.sh @@ -40,7 +40,8 @@ if [ "$GO111MODULE" == "off" ]; then export GO15VENDOREXPERIMENT=1 export GOBIN=${PWD}/bin export GOPATH=${PWD}/gopath - go install -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/multus + # go build -o ${PWD}/bin/multus -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/cmd + go build -o multus -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/cmd else # build with go modules export GO111MODULE=on @@ -50,5 +51,5 @@ else fi echo "Building plugins" - go build ${BUILD_ARGS[*]} -ldflags "${LDFLAGS}" "$@" ./multus + go build ${BUILD_ARGS[*]} -ldflags "${LDFLAGS}" "$@" ./cmd fi diff --git a/hack/nikhil-build.sh b/hack/nikhil-build.sh new file mode 100755 index 000000000..0b5690aaa --- /dev/null +++ b/hack/nikhil-build.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +set -e + +DEST_DIR="bin" + +if [ ! -d ${DEST_DIR} ]; then + mkdir ${DEST_DIR} +fi + +# Add version/commit/date into binary +# In case of TravisCI, need to check error code of 'git describe'. +if [ -z "$VERSION" ]; then + set +e + git describe --tags --abbrev=0 > /dev/null 2>&1 + if [ "$?" != "0" ]; then + VERSION="master" + else + VERSION=$(git describe --tags --abbrev=0) + fi + set -e +fi +DATE=$(date --iso-8601=seconds) +COMMIT=${COMMIT:-$(git rev-parse --verify HEAD)} +LDFLAGS="-X main.version=${VERSION:-master} -X main.commit=${COMMIT} -X main.date=${DATE}" +export CGO_ENABLED=0 + +# this if... will be removed when gomodules goes default +if [ "$GO111MODULE" == "off" ]; then + echo "Building plugin without go module" + echo "Warning: this will be deprecated in near future so please use go modules!" + + ORG_PATH="gopkg.in/intel" + REPO_PATH="${ORG_PATH}/multus-cni.v3" + + if [ ! -h gopath/src/${REPO_PATH} ]; then + mkdir -p gopath/src/${ORG_PATH} + ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255 + fi + + export GO15VENDOREXPERIMENT=1 + export GOBIN=${PWD}/bin + export GOPATH=${PWD}/gopath + go install -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/multus +else + # build with go modules + export GO111MODULE=on + + echo "Building plugins" + go build -o ${DEST_DIR}/multus -tags no_openssl -ldflags "${LDFLAGS}" "$@" ./pkg/multus +fi + diff --git a/test.sh b/hack/test-go.sh similarity index 100% rename from test.sh rename to hack/test-go.sh diff --git a/checkpoint/checkpoint.go b/pkg/checkpoint/checkpoint.go similarity index 97% rename from checkpoint/checkpoint.go rename to pkg/checkpoint/checkpoint.go index c448b5ff0..12cef7a18 100644 --- a/checkpoint/checkpoint.go +++ b/pkg/checkpoint/checkpoint.go @@ -19,8 +19,8 @@ import ( "encoding/json" "io/ioutil" - "gopkg.in/intel/multus-cni.v3/logging" - "gopkg.in/intel/multus-cni.v3/types" + "gopkg.in/intel/multus-cni.v3/pkg/logging" + "gopkg.in/intel/multus-cni.v3/pkg/types" v1 "k8s.io/api/core/v1" ) diff --git a/checkpoint/checkpoint_test.go b/pkg/checkpoint/checkpoint_test.go similarity index 99% rename from checkpoint/checkpoint_test.go rename to pkg/checkpoint/checkpoint_test.go index 4f5ddddbf..4964bd9b0 100644 --- a/checkpoint/checkpoint_test.go +++ b/pkg/checkpoint/checkpoint_test.go @@ -10,7 +10,7 @@ import ( "io/ioutil" "testing" - "gopkg.in/intel/multus-cni.v3/types" + "gopkg.in/intel/multus-cni.v3/pkg/types" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8sTypes "k8s.io/apimachinery/pkg/types" diff --git a/k8sclient/k8sclient.go b/pkg/k8sclient/k8sclient.go similarity index 99% rename from k8sclient/k8sclient.go rename to pkg/k8sclient/k8sclient.go index 0adb84905..1cd2859f3 100644 --- a/k8sclient/k8sclient.go +++ b/pkg/k8sclient/k8sclient.go @@ -38,12 +38,12 @@ import ( "github.com/containernetworking/cni/libcni" "github.com/containernetworking/cni/pkg/skel" cnitypes "github.com/containernetworking/cni/pkg/types" + "gopkg.in/intel/multus-cni.v3/pkg/kubeletclient" + "gopkg.in/intel/multus-cni.v3/pkg/logging" + "gopkg.in/intel/multus-cni.v3/pkg/types" nettypes "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" netclient "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/typed/k8s.cni.cncf.io/v1" netutils "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/utils" - "gopkg.in/intel/multus-cni.v3/kubeletclient" - "gopkg.in/intel/multus-cni.v3/logging" - "gopkg.in/intel/multus-cni.v3/types" ) const ( diff --git a/k8sclient/k8sclient_test.go b/pkg/k8sclient/k8sclient_test.go similarity index 99% rename from k8sclient/k8sclient_test.go rename to pkg/k8sclient/k8sclient_test.go index 84d1e9586..32aff2344 100644 --- a/k8sclient/k8sclient_test.go +++ b/pkg/k8sclient/k8sclient_test.go @@ -23,10 +23,10 @@ import ( "testing" types020 "github.com/containernetworking/cni/pkg/types/020" - testutils "gopkg.in/intel/multus-cni.v3/testing" + testutils "gopkg.in/intel/multus-cni.v3/pkg/testing" "github.com/containernetworking/cni/pkg/skel" - "gopkg.in/intel/multus-cni.v3/types" + "gopkg.in/intel/multus-cni.v3/pkg/types" nettypes "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" netfake "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/fake" diff --git a/kubeletclient/kubeletclient.go b/pkg/kubeletclient/kubeletclient.go similarity index 96% rename from kubeletclient/kubeletclient.go rename to pkg/kubeletclient/kubeletclient.go index 6f6061f9e..d480585cc 100644 --- a/kubeletclient/kubeletclient.go +++ b/pkg/kubeletclient/kubeletclient.go @@ -5,10 +5,10 @@ import ( "path/filepath" "time" + "gopkg.in/intel/multus-cni.v3/pkg/checkpoint" + "gopkg.in/intel/multus-cni.v3/pkg/logging" + "gopkg.in/intel/multus-cni.v3/pkg/types" "golang.org/x/net/context" - "gopkg.in/intel/multus-cni.v3/checkpoint" - "gopkg.in/intel/multus-cni.v3/logging" - "gopkg.in/intel/multus-cni.v3/types" v1 "k8s.io/api/core/v1" "k8s.io/kubernetes/pkg/kubelet/apis/podresources" podresourcesapi "k8s.io/kubernetes/pkg/kubelet/apis/podresources/v1alpha1" diff --git a/kubeletclient/kubeletclient_test.go b/pkg/kubeletclient/kubeletclient_test.go similarity index 99% rename from kubeletclient/kubeletclient_test.go rename to pkg/kubeletclient/kubeletclient_test.go index 759a42cf8..091fb2efa 100644 --- a/kubeletclient/kubeletclient_test.go +++ b/pkg/kubeletclient/kubeletclient_test.go @@ -15,7 +15,7 @@ import ( k8sTypes "k8s.io/apimachinery/pkg/types" "k8s.io/kubernetes/pkg/kubelet/util" - mtypes "gopkg.in/intel/multus-cni.v3/types" + mtypes "gopkg.in/intel/multus-cni.v3/pkg/types" podresourcesapi "k8s.io/kubernetes/pkg/kubelet/apis/podresources/v1alpha1" ) diff --git a/logging/logging.go b/pkg/logging/logging.go similarity index 100% rename from logging/logging.go rename to pkg/logging/logging.go diff --git a/logging/logging_test.go b/pkg/logging/logging_test.go similarity index 100% rename from logging/logging_test.go rename to pkg/logging/logging_test.go diff --git a/multus/multus.go b/pkg/multus/multus.go similarity index 96% rename from multus/multus.go rename to pkg/multus/multus.go index 8fc90917b..18dc6e28b 100644 --- a/multus/multus.go +++ b/pkg/multus/multus.go @@ -12,11 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// This is a "Multi-plugin".The delegate concept refered from CNI project -// It reads other plugin netconf, and then invoke them, e.g. -// flannel or sriov plugin. - -package main +package multus import ( "context" @@ -37,13 +33,13 @@ import ( cnicurrent "github.com/containernetworking/cni/pkg/types/current" cniversion "github.com/containernetworking/cni/pkg/version" "github.com/containernetworking/plugins/pkg/ns" + k8s "gopkg.in/intel/multus-cni.v3/pkg/k8sclient" + "gopkg.in/intel/multus-cni.v3/pkg/logging" + "gopkg.in/intel/multus-cni.v3/pkg/netutils" + "gopkg.in/intel/multus-cni.v3/pkg/types" nettypes "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" nadutils "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/utils" "github.com/vishvananda/netlink" - k8s "gopkg.in/intel/multus-cni.v3/k8sclient" - "gopkg.in/intel/multus-cni.v3/logging" - "gopkg.in/intel/multus-cni.v3/netutils" - "gopkg.in/intel/multus-cni.v3/types" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/util/wait" @@ -60,7 +56,7 @@ var ( pollTimeout = 45 * time.Second ) -func printVersionString() string { +func PrintVersionString() string { return fmt.Sprintf("multus-cni version:%s, commit:%s, date:%s", version, commit, date) } @@ -508,9 +504,9 @@ func cmdPluginErr(k8sArgs *types.K8sArgs, confName string, format string, args . return logging.Errorf(msg+format, args...) } -func cmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (cnitypes.Result, error) { +func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (cnitypes.Result, error) { n, err := types.LoadNetConf(args.StdinData) - logging.Debugf("cmdAdd: %v, %v, %v", args, exec, kubeClient) + logging.Debugf("CmdAdd: %v, %v, %v", args, exec, kubeClient) if err != nil { return nil, cmdErr(nil, "error loading netconf: %v", err) } @@ -689,9 +685,9 @@ func cmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c return result, nil } -func cmdCheck(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) error { +func CmdCheck(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) error { in, err := types.LoadNetConf(args.StdinData) - logging.Debugf("cmdCheck: %v, %v, %v", args, exec, kubeClient) + logging.Debugf("CmdCheck: %v, %v, %v", args, exec, kubeClient) if err != nil { return err } @@ -714,9 +710,9 @@ func cmdCheck(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) return nil } -func cmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) error { +func CmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) error { in, err := types.LoadNetConf(args.StdinData) - logging.Debugf("cmdDel: %v, %v, %v", args, exec, kubeClient) + logging.Debugf("CmdDel: %v, %v, %v", args, exec, kubeClient) if err != nil { return err } @@ -730,7 +726,7 @@ func cmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) er _, ok := err.(ns.NSPathNotExistErr) if ok { netnsfound = false - logging.Debugf("cmdDel: WARNING netns may not exist, netns: %s, err: %s", args.Netns, err) + logging.Debugf("CmdDel: WARNING netns may not exist, netns: %s, err: %s", args.Netns, err) } else { return cmdErr(nil, "failed to open netns %q: %v", netns, err) } @@ -868,21 +864,21 @@ func main() { flag.BoolVar(&versionOpt, "v", false, "Show application version") flag.Parse() if versionOpt == true { - fmt.Printf("%s\n", printVersionString()) + fmt.Printf("%s\n", PrintVersionString()) return } skel.PluginMain( func(args *skel.CmdArgs) error { - result, err := cmdAdd(args, nil, nil) + result, err := CmdAdd(args, nil, nil) if err != nil { return err } return result.Print() }, func(args *skel.CmdArgs) error { - return cmdCheck(args, nil, nil) + return CmdCheck(args, nil, nil) }, - func(args *skel.CmdArgs) error { return cmdDel(args, nil, nil) }, + func(args *skel.CmdArgs) error { return CmdDel(args, nil, nil) }, cniversion.All, "meta-plugin that delegates to other CNI plugins") } diff --git a/multus/multus_test.go b/pkg/multus/multus_test.go similarity index 95% rename from multus/multus_test.go rename to pkg/multus/multus_test.go index 0184e597b..3665bed18 100644 --- a/multus/multus_test.go +++ b/pkg/multus/multus_test.go @@ -13,7 +13,7 @@ // limitations under the License. // -package main +package multus import ( "bytes" @@ -34,12 +34,11 @@ import ( cniversion "github.com/containernetworking/cni/pkg/version" "github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/testutils" + "gopkg.in/intel/multus-cni.v3/pkg/k8sclient" + "gopkg.in/intel/multus-cni.v3/pkg/logging" + testhelpers "gopkg.in/intel/multus-cni.v3/pkg/testing" + "gopkg.in/intel/multus-cni.v3/pkg/types" netfake "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/fake" - "gopkg.in/intel/multus-cni.v3/k8sclient" - "gopkg.in/intel/multus-cni.v3/logging" - testhelpers "gopkg.in/intel/multus-cni.v3/testing" - "gopkg.in/intel/multus-cni.v3/types" - "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/fake" @@ -296,7 +295,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -305,7 +304,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -372,7 +371,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -381,7 +380,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -392,7 +391,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { } }) - It("returns the previous result using cmdCheck", func() { + It("returns the previous result using CmdCheck", func() { args := &skel.CmdArgs{ ContainerID: "123456789", Netns: testNS.Path(), @@ -449,7 +448,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -457,12 +456,12 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { Expect(reflect.DeepEqual(r, expectedResult1)).To(BeTrue()) // Check is not supported until v 0.4.0 - err = cmdCheck(args, fExec, nil) + err = CmdCheck(args, fExec, nil) Expect(err).To(HaveOccurred()) os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -529,7 +528,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -538,7 +537,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -549,7 +548,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { } }) - It("returns the previous result using cmdCheck", func() { + It("returns the previous result using CmdCheck", func() { args := &skel.CmdArgs{ ContainerID: "123456789", Netns: testNS.Path(), @@ -606,7 +605,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -614,12 +613,12 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { Expect(reflect.DeepEqual(r, expectedResult1)).To(BeTrue()) // Check is not supported until v 0.4.0 - err = cmdCheck(args, fExec, nil) + err = CmdCheck(args, fExec, nil) Expect(err).To(HaveOccurred()) os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -687,7 +686,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -696,7 +695,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -707,7 +706,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { } }) - It("returns the previous result using cmdCheck", func() { + It("returns the previous result using CmdCheck", func() { args := &skel.CmdArgs{ ContainerID: "123456789", Netns: testNS.Path(), @@ -764,7 +763,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -772,12 +771,12 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { Expect(reflect.DeepEqual(r, expectedResult1)).To(BeTrue()) // Check is not supported until v 0.4.0 - err = cmdCheck(args, fExec, nil) + err = CmdCheck(args, fExec, nil) Expect(err).To(HaveOccurred()) os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -844,7 +843,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -853,7 +852,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -864,7 +863,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { } }) - It("returns the previous result using cmdCheck", func() { + It("returns the previous result using CmdCheck", func() { args := &skel.CmdArgs{ ContainerID: "123456789", Netns: testNS.Path(), @@ -921,7 +920,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -929,12 +928,12 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { Expect(reflect.DeepEqual(r, expectedResult1)).To(BeTrue()) // Check is not supported until v 0.4.0 - err = cmdCheck(args, fExec, nil) + err = CmdCheck(args, fExec, nil) Expect(err).To(HaveOccurred()) os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -1001,7 +1000,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -1010,7 +1009,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -1021,7 +1020,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { } }) - It("returns the previous result using cmdCheck", func() { + It("returns the previous result using CmdCheck", func() { args := &skel.CmdArgs{ ContainerID: "123456789", Netns: testNS.Path(), @@ -1076,7 +1075,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -1084,12 +1083,12 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { Expect(reflect.DeepEqual(r, expectedResult1)).To(BeTrue()) // Check is not supported until v 0.4.0 - err = cmdCheck(args, fExec, nil) + err = CmdCheck(args, fExec, nil) Expect(err).To(HaveOccurred()) os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -1100,7 +1099,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { } }) - It("fails to load NetConf with bad json in cmdAdd/Del", func() { + It("fails to load NetConf with bad json in CmdAdd/Del", func() { args := &skel.CmdArgs{ ContainerID: "123456789", Netns: testNS.Path(), @@ -1156,10 +1155,10 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - _, err := cmdAdd(args, fExec, nil) + _, err := CmdAdd(args, fExec, nil) Expect(err).To(HaveOccurred()) - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).To(HaveOccurred()) }) @@ -1226,7 +1225,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - _, err = cmdAdd(args, fExec, nil) + _, err = CmdAdd(args, fExec, nil) Expect(fExec.addIndex).To(Equal(2)) Expect(fExec.delIndex).To(Equal(2)) Expect(err).To(MatchError("[/:other1]: error adding container to network \"other1\": expected plugin failure")) @@ -1250,7 +1249,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { "cniVersion": "0.2.0", "type": "other-plugin" }` - // took out the name in expectedConf2, expecting a new value to be filled in by cmdAdd + // took out the name in expectedConf2, expecting a new value to be filled in by CmdAdd args := &skel.CmdArgs{ ContainerID: "123456789", @@ -1284,7 +1283,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - _, err = cmdAdd(args, fExec, nil) + _, err = CmdAdd(args, fExec, nil) Expect(fExec.addIndex).To(Equal(2)) Expect(fExec.delIndex).To(Equal(2)) Expect(err).To(HaveOccurred()) @@ -1405,7 +1404,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, clientInfo) + result, err := CmdAdd(args, fExec, clientInfo) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*current.Result) @@ -1491,7 +1490,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, clientInfo) + result, err := CmdAdd(args, fExec, clientInfo) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -1561,7 +1560,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, clientInfo) + result, err := CmdAdd(args, fExec, clientInfo) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -1578,7 +1577,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { Expect(nilPod).To(BeNil()) Expect(errors.IsNotFound(err)).To(BeTrue()) - err = cmdDel(args, fExec, clientInfo) + err = CmdDel(args, fExec, clientInfo) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -1635,7 +1634,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, fKubeClient) + result, err := CmdAdd(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -1646,7 +1645,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_IFNAME", "eth0") // set fKubeClient to nil to emulate no pod info fKubeClient.DeletePod(fakePod.ObjectMeta.Namespace, fakePod.ObjectMeta.Name) - err = cmdDel(args, fExec, fKubeClient) + err = CmdDel(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -1703,7 +1702,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, fKubeClient) + result, err := CmdAdd(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -1714,7 +1713,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_IFNAME", "eth0") // set fKubeClient to nil to emulate no pod info fKubeClient.DeletePod(fakePod.ObjectMeta.Namespace, fakePod.ObjectMeta.Name) - err = cmdDel(args, fExec, fKubeClient) + err = CmdDel(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -1760,7 +1759,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { fExec.addPlugin020(nil, "eth0", expectedConf1, nil, nil) os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - _, err := cmdAdd(args, fExec, nil) + _, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) }) @@ -1802,7 +1801,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, fKubeClient) + result, err := CmdAdd(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -1810,7 +1809,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, fKubeClient) + err = CmdDel(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -1871,7 +1870,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { Expect(err).NotTo(HaveOccurred()) os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, fKubeClient) + result, err := CmdAdd(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -1886,7 +1885,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { By("Delete and check net count is not incremented") os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, fKubeClient) + err = CmdDel(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -1947,7 +1946,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { Expect(err).NotTo(HaveOccurred()) os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, fKubeClient) + result, err := CmdAdd(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*types020.Result) @@ -1965,7 +1964,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { By("Delete and check pod/net count is incremented") os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, fKubeClient) + err = CmdDel(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -2082,9 +2081,9 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() { fExec.addPlugin020(nil, "eth0", expectedConf1, nil, nil) os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - _, err := cmdAdd(args, fExec, nil) + _, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) }) }) @@ -2173,7 +2172,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) @@ -2181,12 +2180,12 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { Expect(reflect.DeepEqual(result, expectedResult1)).To(BeTrue()) os.Setenv("CNI_COMMAND", "CHECK") - err = cmdCheck(args, fExec, nil) + err = CmdCheck(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -2255,7 +2254,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) // plugin 1 is the masterplugin @@ -2263,7 +2262,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -2274,7 +2273,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { } }) - It("returns the previous result using cmdCheck", func() { + It("returns the previous result using CmdCheck", func() { args := &skel.CmdArgs{ ContainerID: "123456789", Netns: testNS.Path(), @@ -2341,7 +2340,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, nil) + result, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) @@ -2349,12 +2348,12 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { Expect(reflect.DeepEqual(result, expectedResult1)).To(BeTrue()) os.Setenv("CNI_COMMAND", "CHECK") - err = cmdCheck(args, fExec, nil) + err = CmdCheck(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) @@ -2365,7 +2364,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { } }) - It("fails to load NetConf with bad json in cmdAdd/Del", func() { + It("fails to load NetConf with bad json in CmdAdd/Del", func() { args := &skel.CmdArgs{ ContainerID: "123456789", Netns: testNS.Path(), @@ -2423,10 +2422,10 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - _, err := cmdAdd(args, fExec, nil) + _, err := CmdAdd(args, fExec, nil) Expect(err).To(HaveOccurred()) - err = cmdDel(args, fExec, nil) + err = CmdDel(args, fExec, nil) Expect(err).To(HaveOccurred()) }) @@ -2474,7 +2473,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - _, err = cmdAdd(args, fExec, nil) + _, err = CmdAdd(args, fExec, nil) Expect(fExec.addIndex).To(Equal(2)) Expect(fExec.delIndex).To(Equal(2)) Expect(err).To(MatchError("[/:other1]: error adding container to network \"other1\": expected plugin failure")) @@ -2498,7 +2497,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { "cniVersion": "0.4.0", "type": "other-plugin" }` - // took out the name in expectedConf2, expecting a new value to be filled in by cmdAdd + // took out the name in expectedConf2, expecting a new value to be filled in by CmdAdd args := &skel.CmdArgs{ ContainerID: "123456789", @@ -2533,7 +2532,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - _, err = cmdAdd(args, fExec, nil) + _, err = CmdAdd(args, fExec, nil) Expect(fExec.addIndex).To(Equal(2)) Expect(fExec.delIndex).To(Equal(2)) Expect(err).To(HaveOccurred()) @@ -2654,7 +2653,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, clientInfo) + result, err := CmdAdd(args, fExec, clientInfo) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) r := result.(*current.Result) @@ -2744,7 +2743,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, clientInfo) + result, err := CmdAdd(args, fExec, clientInfo) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) // plugin 1 is the masterplugin @@ -2808,7 +2807,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, clientInfo) + result, err := CmdAdd(args, fExec, clientInfo) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) // plugin 1 is the masterplugin @@ -2818,7 +2817,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_IFNAME", "eth0") // set fKubeClient to nil to emulate no pod info clientInfo.DeletePod(fakePod.ObjectMeta.Namespace, fakePod.ObjectMeta.Name) - err = cmdDel(args, fExec, clientInfo) + err = CmdDel(args, fExec, clientInfo) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -2877,7 +2876,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, fKubeClient) + result, err := CmdAdd(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) // plugin 1 is the masterplugin @@ -2887,7 +2886,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_IFNAME", "eth0") // set fKubeClient to nil to emulate no pod info fKubeClient.DeletePod(fakePod.ObjectMeta.Namespace, fakePod.ObjectMeta.Name) - err = cmdDel(args, fExec, fKubeClient) + err = CmdDel(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -2946,7 +2945,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, fKubeClient) + result, err := CmdAdd(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) // plugin 1 is the masterplugin @@ -2956,7 +2955,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_IFNAME", "eth0") // set fKubeClient to nil to emulate no pod info fKubeClient.DeletePod(fakePod.ObjectMeta.Namespace, fakePod.ObjectMeta.Name) - err = cmdDel(args, fExec, fKubeClient) + err = CmdDel(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -3002,7 +3001,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { fExec.addPlugin(nil, "eth0", expectedConf1, nil, nil) os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - _, err := cmdAdd(args, fExec, nil) + _, err := CmdAdd(args, fExec, nil) Expect(err).NotTo(HaveOccurred()) }) @@ -3045,14 +3044,14 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, fKubeClient) + result, err := CmdAdd(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) Expect(reflect.DeepEqual(result, expectedResult1)).To(BeTrue()) os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, fKubeClient) + err = CmdDel(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -3115,7 +3114,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { Expect(err).NotTo(HaveOccurred()) os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, fKubeClient) + result, err := CmdAdd(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) // plugin 1 is the masterplugin @@ -3129,7 +3128,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { By("Delete and check net count is not incremented") os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, fKubeClient) + err = CmdDel(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) @@ -3192,7 +3191,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { Expect(err).NotTo(HaveOccurred()) os.Setenv("CNI_COMMAND", "ADD") os.Setenv("CNI_IFNAME", "eth0") - result, err := cmdAdd(args, fExec, fKubeClient) + result, err := CmdAdd(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.addIndex).To(Equal(len(fExec.plugins))) // plugin 1 is the masterplugin @@ -3209,7 +3208,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() { By("Delete and check pod/net count is incremented") os.Setenv("CNI_COMMAND", "DEL") os.Setenv("CNI_IFNAME", "eth0") - err = cmdDel(args, fExec, fKubeClient) + err = CmdDel(args, fExec, fKubeClient) Expect(err).NotTo(HaveOccurred()) Expect(fExec.delIndex).To(Equal(len(fExec.plugins))) }) diff --git a/netutils/netutils.go b/pkg/netutils/netutils.go similarity index 98% rename from netutils/netutils.go rename to pkg/netutils/netutils.go index fe4675ab5..6a3bfc85d 100644 --- a/netutils/netutils.go +++ b/pkg/netutils/netutils.go @@ -20,8 +20,8 @@ import ( cnitypes "github.com/containernetworking/cni/pkg/types" "github.com/containernetworking/cni/pkg/types/current" "github.com/containernetworking/plugins/pkg/ns" + "gopkg.in/intel/multus-cni.v3/pkg/logging" "github.com/vishvananda/netlink" - "gopkg.in/intel/multus-cni.v3/logging" "net" "strings" ) diff --git a/testing/testing.go b/pkg/testing/testing.go similarity index 100% rename from testing/testing.go rename to pkg/testing/testing.go diff --git a/types/conf.go b/pkg/types/conf.go similarity index 99% rename from types/conf.go rename to pkg/types/conf.go index 7101d7a62..b0ca49176 100644 --- a/types/conf.go +++ b/pkg/types/conf.go @@ -26,7 +26,7 @@ import ( "github.com/containernetworking/cni/pkg/types/current" "github.com/containernetworking/cni/pkg/version" nadutils "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/utils" - "gopkg.in/intel/multus-cni.v3/logging" + "gopkg.in/intel/multus-cni.v3/pkg/logging" ) const ( diff --git a/types/conf_test.go b/pkg/types/conf_test.go similarity index 99% rename from types/conf_test.go rename to pkg/types/conf_test.go index 9d2eb1dcb..58e156af8 100644 --- a/types/conf_test.go +++ b/pkg/types/conf_test.go @@ -26,8 +26,8 @@ import ( types020 "github.com/containernetworking/cni/pkg/types/020" "github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/testutils" + testhelpers "gopkg.in/intel/multus-cni.v3/pkg/testing" netutils "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/utils" - testhelpers "gopkg.in/intel/multus-cni.v3/testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/types/types.go b/pkg/types/types.go similarity index 100% rename from types/types.go rename to pkg/types/types.go diff --git a/restructure.txt b/restructure.txt new file mode 100644 index 000000000..2d253ef32 --- /dev/null +++ b/restructure.txt @@ -0,0 +1,45 @@ +Delete this document after restructure is about to be merged. +X - restructured +O - not needed +U - needs to be restructured + +*Note that after moving code into the pkg directory, tests try to run on directories like the cmd dir which contains main. This may be undesired behavior.* + +/cmd X + +/internal O + +/pkg X + +/vendor X + +/api O + +/web O + +/configs O + +/init O + +/scripts X + +/build O + +/deployments X + +/test O + +/docs X + +/tools O + +/examples X + +/third_party O + +/githooks O + +/assets O + +/website O + diff --git a/vendor/github.com/json-iterator/go/.travis.yml b/vendor/github.com/json-iterator/go/.travis.yml index 449e67cd0..ae5508f2f 100644 --- a/vendor/github.com/json-iterator/go/.travis.yml +++ b/vendor/github.com/json-iterator/go/.travis.yml @@ -8,7 +8,7 @@ before_install: - go get -t -v ./... script: - - ./test.sh + - ./scripts/test.sh after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/modern-go/concurrent/.travis.yml b/vendor/github.com/modern-go/concurrent/.travis.yml index 449e67cd0..ae5508f2f 100644 --- a/vendor/github.com/modern-go/concurrent/.travis.yml +++ b/vendor/github.com/modern-go/concurrent/.travis.yml @@ -8,7 +8,7 @@ before_install: - go get -t -v ./... script: - - ./test.sh + - ./scripts/test.sh after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/modern-go/reflect2/.travis.yml b/vendor/github.com/modern-go/reflect2/.travis.yml index fbb43744d..03f987fe2 100644 --- a/vendor/github.com/modern-go/reflect2/.travis.yml +++ b/vendor/github.com/modern-go/reflect2/.travis.yml @@ -9,7 +9,7 @@ before_install: - go get -t -v github.com/modern-go/reflect2-tests/... script: - - ./test.sh + - ./scripts/test.sh after_success: - bash <(curl -s https://codecov.io/bash)