From e558d6af2f3d411f4f5654d4bd1e0a66317ba589 Mon Sep 17 00:00:00 2001 From: Carolyn Van Slyck Date: Tue, 23 Jan 2018 15:32:23 -0600 Subject: [PATCH] Update relevant glide usage to dep We cannot completely remove glide because we are using `glide nv`. If we had a requirement of Go 1.9+ maybe that could be dropped, since the go tools in that version don't include vendor anymore with `./...`, but until then it needs to stay. --- .travis.yml | 2 +- Makefile | 7 +------ build/verify-errexit.sh | 2 +- contrib/jenkins/init_build.sh | 30 ++++++++++++++++++++++++++++++ docs/devguide.md | 7 ++++--- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78f2a5fdbbc..15458d64696 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ services: - docker cache: directories: - - .glide + - $GOPATH/pkg/dep script: - make verify build build-integration build-e2e test images deploy: diff --git a/Makefile b/Makefile index a5f5d104c17..787f918cce9 100644 --- a/Makefile +++ b/Makefile @@ -81,12 +81,6 @@ SERVICE_CATALOG_MUTABLE_IMAGE = $(REGISTRY)service-catalog-$(ARCH):$(MUTABLE USER_BROKER_IMAGE = $(REGISTRY)user-broker-$(ARCH):$(VERSION) USER_BROKER_MUTABLE_IMAGE = $(REGISTRY)user-broker-$(ARCH):$(MUTABLE_TAG) -# precheck to avoid kubernetes-incubator/service-catalog#361 -$(if $(realpath vendor/k8s.io/apimachinery/vendor), \ - $(error the vendor directory exists in the apimachinery \ - vendored source and must be flattened. \ - run 'glide i -v')) - ifdef UNIT_TESTS UNIT_TEST_FLAGS=-run $(UNIT_TESTS) -v endif @@ -111,6 +105,7 @@ else scBuildImageTarget = .scBuildImage endif +# Even though we migrated to dep, it doesn't replace the `glide nv` command NON_VENDOR_DIRS = $(shell $(DOCKER_CMD) glide nv) # This section builds the output binaries. diff --git a/build/verify-errexit.sh b/build/verify-errexit.sh index 742a1c229ed..b5a4784917d 100755 --- a/build/verify-errexit.sh +++ b/build/verify-errexit.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(dirname "${BASH_SOURCE}")/.. if [ "$*" != "" ]; then args="$*" else - args=$(ls "$REPO_ROOT" | grep -v vendor | grep -v glide) + args=$(ls "$REPO_ROOT" | grep -v vendor | grep -v Gopkg) fi # Gather the list of files that appear to be shell scripts. diff --git a/contrib/jenkins/init_build.sh b/contrib/jenkins/init_build.sh index b1d0c1b169d..95742d53c75 100755 --- a/contrib/jenkins/init_build.sh +++ b/contrib/jenkins/init_build.sh @@ -22,6 +22,7 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" GO_VERSION='1.9' HELM_VERSION='v2.7.0' GLIDE_VERSION='v0.12.3' +DEP_VERSION='v0.3.2' function update-golang() { # Check version of golang @@ -92,10 +93,39 @@ function update-glide() { } +function update-dep() { + # Check version of dep + local current="$(dep --version 2>/dev/null || echo "unknown")" + + # dep version prints its output in the format: + # dep: + # version : v0.3.2 + # build date : + # git hash : + # go version : go1.9.2 + # go compiler : gc + # platform : darwin/amd64 + # To isolate the version string, we include the leading space + # in the comparison, and ommit the trailing wildcard. + if [[ "${current}" == *" ${DEP_VERSION}"* ]]; then + echo "dep is up-to-date: ${current}" + else + echo "Upgrading dep ${current} to ${DEP_VERSION}" + + # Install new dep. + local dep_url='https://github.com/golang/dep/releases/download/' + dep_url+="${DEP_VERSION}/dep-linux-amd64" + + curl -sSL -o /usr/local/bin/dep "${dep_url}" && chmod +x /usr/local/bin/dep \ + || { echo "Cannot upgrade dep to ${DEP_VERSION}"; return 1; } + fi +} + function main() { update-golang || error_exit 'Failed to update golang' update-helm || error_exit 'Failed to update helm' update-glide || error_exit 'Failed to update glide' + update-dep || error_exit 'Failed to update dep' } main diff --git a/docs/devguide.md b/docs/devguide.md index 16cbbb51531..5af9a405918 100644 --- a/docs/devguide.md +++ b/docs/devguide.md @@ -18,7 +18,6 @@ have found possible (or practical). Below is a summary of the repository's layout: . - ├── .glide # Glide cache (untracked) ├── bin # Destination for binaries compiled for linux/amd64 (untracked) ├── build # Contains build-related scripts and subdirectories containing Dockerfiles ├── charts # Helm charts for deployment @@ -40,7 +39,9 @@ layout: ├── pkg # Contains all non-"main" Go packages ├── plugin # Plugins for API server ├── test # Integration and e2e tests - └── vendor # Glide-managed dependencies + ├── vendor # dep-managed dependencies + ├── Gopkg.toml # dep manifest + └── Gopkg.lock # dep lock (autogenerated, do not edit) ## Working on Issues @@ -150,7 +151,7 @@ To build the service-catalog: The above will build all executables and place them in the `bin` directory. This is done within a Docker container-- meaning you do not need to have all of the -necessary tooling installed on your host (such as a golang compiler or glide). +necessary tooling installed on your host (such as a golang compiler or dep). Building outside the container is possible, but not officially supported. Note, this will do the basic build of the service catalog. There are more