Skip to content

Commit

Permalink
Merge pull request #502 from miaoyq/part-of-385
Browse files Browse the repository at this point in the history
Compare vendor with hack/versions and update hack/versions
  • Loading branch information
Random-Liu committed Dec 15, 2017
2 parents 072ed48 + 0520ebc commit 04333d0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Makefile
Expand Up @@ -56,7 +56,7 @@ help:
@echo " * 'uninstall' - Remove installed binaries from system locations"
@echo " * 'version' - Print current cri-containerd release version"

verify: lint gofmt boiler
verify: lint gofmt boiler deps-version

version:
@echo $(VERSION)
Expand All @@ -73,6 +73,10 @@ boiler:
@echo "checking boilerplate"
@./hack/verify-boilerplate.sh

deps-version:
@echo "checking /hack/versions"
@./hack/update-vendor.sh -only-verify

$(BUILD_DIR)/cri-containerd: $(SOURCES)
$(GO) build -o $@ \
-tags '$(BUILD_TAGS)' \
Expand Down
30 changes: 26 additions & 4 deletions hack/update-vendor.sh
Expand Up @@ -18,15 +18,37 @@ set -o errexit
set -o nounset
set -o pipefail

# This is a temporary hack, rewrite all `github.com/Sirupsen/logrus` to
# lower case.
# TODO(random-liu): Remove this after #106 is resolved.
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
cd ${ROOT}

echo "Sort vendor.conf..."
sort vendor.conf -o vendor.conf

# TODO(random-liu): Compare vendor with hack/versions.
echo "Compare vendor with hack/versions..."
need_update=false
declare -A map=()
map["RUNC_VERSION"]="github.com/opencontainers/runc"
map["CNI_VERSION"]="github.com/containernetworking/cni"
map["CONTAINERD_VERSION"]="github.com/containerd/containerd"
map["KUBERNETES_VERSION"]="k8s.io/kubernetes"
for key in ${!map[@]}
do
vendor_commitid=$(grep ${map[${key}]} vendor.conf | awk '{print $2}')
version_commitid=$(grep ${key} hack/versions | awk -F "=" '{print $2}')
if [ ${vendor_commitid} != ${version_commitid} ]; then
if [ $# -gt 0 ] && [ ${1} = "-only-verify" ]; then
need_update=true
echo "Need to update the value of ${key} from ${version_commitid} to ${vendor_commitid}."
else
echo "Updating the value of ${key} from ${version_commitid} to ${vendor_commitid}."
sed -i "s/${version_commitid}/${vendor_commitid}/g" hack/versions
fi
fi
done

if [ ${need_update} = true ]; then
echo "Please update \"hack/versions\" by executing \"hack/update-vendor.sh\"!"
exit 1
fi

echo "Please commit the change made by this file..."

0 comments on commit 04333d0

Please sign in to comment.