From 84139b42415b023998a595a16e2b83c0cca02910 Mon Sep 17 00:00:00 2001 From: Mike Brown Date: Tue, 6 Feb 2018 19:58:28 -0600 Subject: [PATCH] removes hack versions; splits update vendor and makes it optional Signed-off-by: Mike Brown --- Makefile | 19 +++++++++++---- README.md | 2 +- docs/crictl.md | 2 +- hack/install-deps.sh | 11 +++++---- hack/sort-vendor.sh | 28 +++++++++++++++++++++++ hack/{update-vendor.sh => sync-vendor.sh} | 8 +------ hack/test-utils.sh | 3 +-- hack/utils.sh | 15 ++++++++++++ hack/versions | 14 ------------ 9 files changed, 67 insertions(+), 35 deletions(-) create mode 100755 hack/sort-vendor.sh rename hack/{update-vendor.sh => sync-vendor.sh} (92%) mode change 100644 => 100755 hack/test-utils.sh mode change 100644 => 100755 hack/utils.sh delete mode 100644 hack/versions diff --git a/Makefile b/Makefile index 46707e225..6f4141eab 100644 --- a/Makefile +++ b/Makefile @@ -57,8 +57,9 @@ help: @echo " * 'install.deps' - Install dependencies of cri-containerd (containerd, runc, cni) Note: BUILDTAGS defaults to 'seccomp apparmor' for runc build" @echo " * 'uninstall' - Remove installed binaries from system locations" @echo " * 'version' - Print current cri-containerd release version" + @echo " * 'update-vendor' - Syncs containerd/vendor.conf -> vendor.conf and sorts vendor.conf" -verify: lint gofmt boiler deps-version +verify: lint gofmt boiler version: @echo $(VERSION) @@ -75,9 +76,17 @@ boiler: @echo "checking boilerplate" @./hack/verify-boilerplate.sh -deps-version: - @echo "checking /hack/versions" - @./hack/update-vendor.sh -only-verify +.PHONY: sort-vendor sync-vendor update-vendor + +sort-vendor: + @echo "sorting vendor.conf" + @./hack/sort-vendor.sh + +sync-vendor: + @echo "syncing vendor.conf from containerd" + @./hack/sync-vendor.sh + +update-vendor: sync-vendor sort-vendor $(BUILD_DIR)/cri-containerd: $(SOURCES) $(GO) build -o $@ \ @@ -134,7 +143,7 @@ uninstall: rm -f $(BINDIR)/cri-containerd rm -f $(BINDIR)/ctrcri -$(BUILD_DIR)/$(TARBALL): static-binaries hack/versions +$(BUILD_DIR)/$(TARBALL): static-binaries vendor.conf @BUILD_DIR=$(BUILD_DIR) TARBALL=$(TARBALL) ./hack/release.sh release: $(BUILD_DIR)/$(TARBALL) diff --git a/README.md b/README.md index fd34b7561..0c0909bab 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ The current release of `cri-containerd` has the following dependencies: * [runc](https://github.com/opencontainers/runc) * [CNI](https://github.com/containernetworking/cni) -See [versions](./hack/versions) of these dependencies `cri-containerd` is tested with. +See [versions](./vendor.conf) of these dependencies `cri-containerd` is tested with. As containerd and runc move to their respective general availability releases, we will do our best to rebase/retest `cri-containerd` with these releases on a diff --git a/docs/crictl.md b/docs/crictl.md index 49d6baceb..82e182eda 100644 --- a/docs/crictl.md +++ b/docs/crictl.md @@ -13,7 +13,7 @@ or `crictl` please make sure the issue has not already been submitted. If you have not already installed crictl please install the version compatible with the `cri-containerd` you are using. If you are a user, your deployment should have installed crictl for you. If not, get it from your release tarball. -If you are a developer the current version of crictl is specified [here](../hack/versions). +If you are a developer the current version of crictl is specified [here](../hack/utils.sh). A helper command has been included to install the dependencies at the right version: ```console $ make install.deps diff --git a/hack/install-deps.sh b/hack/install-deps.sh index 7d48c4f48..81d1d1524 100755 --- a/hack/install-deps.sh +++ b/hack/install-deps.sh @@ -30,7 +30,6 @@ set -o pipefail source $(dirname "${BASH_SOURCE[0]}")/utils.sh ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/.. -. ${ROOT}/hack/versions # DESTDIR is the dest path to install dependencies. DESTDIR=${DESTDIR:-"/"} @@ -141,13 +140,15 @@ checkout_repo ${CONTAINERD_PKG} ${CONTAINERD_VERSION} ${CONTAINERD_REPO} cd ${GOPATH}/src/${CONTAINERD_PKG} if ${COOK_CONTAINERD}; then # Verify that vendor.conf is in sync with containerd before cook containerd, - # this is a hard requirement. - if ! ${ROOT}/hack/update-vendor.sh -only-verify; then - echo "Please run hack/update-vendor.sh before cook containerd." + # this is a hard requirement for now because of below overwrite of + # containerd's vendor tree. + # TODO(random-liu): Remove this and the below import code after containerd + # starts to vendor cri plugin. + if ! ${ROOT}/hack/sync-vendor.sh -only-verify; then + echo "Please run hack/sync-vendor.sh before cook containerd." exit 1 fi # Import cri plugin into containerd. - # TODO(random-liu): Remove this after containerd starts to vendor cri plugin. echo "import _ \"${CRI_CONTAINERD_PKG}\"" >> cmd/containerd/builtins_linux.go # 1. Copy all cri-containerd vendors into containerd vendor. This makes sure # all dependencies introduced by cri-containerd will be updated. There might diff --git a/hack/sort-vendor.sh b/hack/sort-vendor.sh new file mode 100755 index 000000000..f1c1e7ab0 --- /dev/null +++ b/hack/sort-vendor.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Copyright 2017 The Kubernetes Authors. +# Copyright 2018 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. + +set -o errexit +set -o nounset +set -o pipefail + +source $(dirname "${BASH_SOURCE[0]}")/utils.sh +cd ${ROOT} + +echo "Sort vendor.conf..." +sort vendor.conf -o vendor.conf + +echo "Please commit the change made by this file..." diff --git a/hack/update-vendor.sh b/hack/sync-vendor.sh similarity index 92% rename from hack/update-vendor.sh rename to hack/sync-vendor.sh index 5d9298247..ea00062ab 100755 --- a/hack/update-vendor.sh +++ b/hack/sync-vendor.sh @@ -1,6 +1,7 @@ #!/bin/bash # Copyright 2017 The Kubernetes Authors. +# Copyright 2018 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. @@ -21,9 +22,7 @@ set -o pipefail source $(dirname "${BASH_SOURCE[0]}")/utils.sh cd ${ROOT} -# hack/versions should be correct now. echo "Compare vendor with containerd vendors..." -source hack/versions containerd_vendor=$(mktemp /tmp/containerd-vendor.conf.XXXX) curl -s https://raw.githubusercontent.com/${CONTAINERD_REPO#*/}/${CONTAINERD_VERSION}/vendor.conf > ${containerd_vendor} # Create a temporary vendor file to update. @@ -58,8 +57,3 @@ if ! diff vendor.conf ${tmp_vendor} > /dev/null; then fi fi rm ${containerd_vendor} - -echo "Sort vendor.conf..." -sort vendor.conf -o vendor.conf - -echo "Please commit the change made by this file..." diff --git a/hack/test-utils.sh b/hack/test-utils.sh old mode 100644 new mode 100755 index 86f56a2b8..0968a6581 --- a/hack/test-utils.sh +++ b/hack/test-utils.sh @@ -16,7 +16,6 @@ source $(dirname "${BASH_SOURCE[0]}")/utils.sh -source ${ROOT}/hack/versions # CRI_CONTAINERD_FLAGS are the extra flags to use when start cri-containerd. CRI_CONTAINERD_FLAGS=${CRI_CONTAINERD_FLAGS:-""} # RESTART_WAIT_PERIOD is the period to wait before restarting cri-containerd/containerd. @@ -34,7 +33,7 @@ containerd_pid= # test_setup starts containerd and cri-containerd. test_setup() { - local report_dir=$1 + local report_dir=$1 if [ ! -x ${ROOT}/_output/cri-containerd ]; then echo "cri-containerd is not built" exit 1 diff --git a/hack/utils.sh b/hack/utils.sh old mode 100644 new mode 100755 index 1e765c1a4..d151ede88 --- a/hack/utils.sh +++ b/hack/utils.sh @@ -16,6 +16,10 @@ ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/.. +# Not from vendor.conf. +CRITOOL_VERSION=c87ea764cecbcbabbb51c5bdd10ea317181fdd62 +CRITOOL_REPO=github.com/kubernetes-incubator/cri-tools + # upload_logs_to_gcs uploads test logs to gcs. # Var set: # 1. Bucket: gcs bucket to upload logs. @@ -87,3 +91,14 @@ from-vendor() { fi eval $setvars } + +from-vendor RUNC github.com/opencontainers/runc +from-vendor CNI github.com/containernetworking/plugins +from-vendor CONTAINERD github.com/containerd/containerd +from-vendor KUBERNETES k8s.io/kubernetes + +# k8s.io is actually a redirect, but we do not handle the go-import +# metadata which `go get` and `vndr` etc do. Handle it manually here. +if [ x"$KUBERNETES_REPO" = "xk8s.io" ] ; then + KUBERNETES_REPO="https://github.com/kubernetes/kubernetes" +fi diff --git a/hack/versions b/hack/versions deleted file mode 100644 index 9e456e7dd..000000000 --- a/hack/versions +++ /dev/null @@ -1,14 +0,0 @@ -from-vendor RUNC github.com/opencontainers/runc -from-vendor CNI github.com/containernetworking/plugins -from-vendor CONTAINERD github.com/containerd/containerd -from-vendor KUBERNETES k8s.io/kubernetes - -# k8s.io is actually a redirect, but we do not handle the go-import -# metadata which `go get` and `vndr` etc do. Handle it manually here. -if [ x"$KUBERNETES_REPO" = "xk8s.io" ] ; then - KUBERNETES_REPO="https://github.com/kubernetes/kubernetes" -fi - -# Not from vendor.conf. -CRITOOL_VERSION=c87ea764cecbcbabbb51c5bdd10ea317181fdd62 -CRITOOL_REPO=github.com/kubernetes-incubator/cri-tools