diff --git a/hack/verify-codegen.sh b/hack/verify-codegen.sh index 5a403a76..59b4cf78 100755 --- a/hack/verify-codegen.sh +++ b/hack/verify-codegen.sh @@ -14,14 +14,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -source "$(dirname $(readlink -f ${BASH_SOURCE}))/../test/library.sh" - set -o errexit set -o nounset set -o pipefail +readonly BUILD_ROOT_DIR="$(git rev-parse --show-toplevel)" readonly TMP_DIFFROOT="$(mktemp -d -p ${BUILD_ROOT_DIR})" - + cleanup() { rm -rf "${TMP_DIFFROOT}" } @@ -37,7 +36,7 @@ cp -aR "${BUILD_ROOT_DIR}/Gopkg.lock" "${BUILD_ROOT_DIR}/pkg" "${BUILD_ROOT_DIR} "${BUILD_ROOT_DIR}/hack/update-codegen.sh" echo "Diffing ${BUILD_ROOT_DIR} against freshly generated codegen" ret=0 -diff -Naupr "${BUILD_ROOT_DIR}/pkg" "${TMP_DIFFROOT}/pkg" || ret=$? +diff -Naupr "${BUILD_ROOT_DIR}/pkg" "${TMP_DIFFROOT}/pkg" || ret=1 # Restore working tree state rm -fr "${BUILD_ROOT_DIR}/Gopkg.lock" "${BUILD_ROOT_DIR}/pkg" "${BUILD_ROOT_DIR}/vendor" diff --git a/test/library.sh b/test/library.sh deleted file mode 100755 index 335d8545..00000000 --- a/test/library.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash - -# Copyright 2018 The Knative 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. - -# This is a collection of useful bash functions and constants, intended -# to be used in test scripts and the like. It doesn't do anything when -# called from command line. - -# Default GKE version to be used with build-crd -readonly BUILD_GKE_VERSION=1.9.6-gke.1 - -# Useful environment variables -[[ -n "${PROW_JOB_ID}" ]] && IS_PROW=1 || IS_PROW=0 -readonly IS_PROW -readonly BUILD_ROOT_DIR="$(dirname $(readlink -f ${BASH_SOURCE}))/.." -readonly OUTPUT_GOBIN="${BUILD_ROOT_DIR}/_output/bin" - -# Copy of *_OVERRIDE variables -readonly OG_DOCKER_REPO="${DOCKER_REPO_OVERRIDE}" -readonly OG_K8S_CLUSTER="${K8S_CLUSTER_OVERRIDE}" -readonly OG_KO_DOCKER_REPO="${KO_DOCKER_REPO}" - -# Simple header for logging purposes. -function header() { - echo "=================================================" - echo ${1^^} - echo "=================================================" -} - -# Simple subheader for logging purposes. -function subheader() { - echo "-------------------------------------------------" - echo $1 - echo "-------------------------------------------------" -} - -# Restores the *_OVERRIDE variables to their original value. -function restore_override_vars() { - export DOCKER_REPO_OVERRIDE="${OG_DOCKER_REPO}" - export K8S_CLUSTER_OVERRIDE="${OG_K8S_CLUSTER}" - export KO_DOCKER_REPO="${OG_KO_DOCKER_REPO}" -} - -# Remove ALL images in the given GCR repository. -# Parameters: $1 - GCR repository. -function delete_gcr_images() { - for image in $(gcloud --format='value(name)' container images list --repository=$1); do - echo "Checking ${image} for removal" - delete_gcr_images ${image} - for digest in $(gcloud --format='get(digest)' container images list-tags ${image} --limit=99999); do - local full_image="${image}@${digest}" - echo "Removing ${full_image}" - gcloud container images delete -q --force-delete-tags ${full_image} - done - done -} - -# Sets the given user as cluster admin. -# Parameters: $1 - user -# $2 - cluster name -# $3 - cluster zone -function acquire_cluster_admin_role() { - # Get the password of the admin and use it, as the service account (or the user) - # might not have the necessary permission. - local password=$(gcloud --format="value(masterAuth.password)" \ - container clusters describe $2 --zone=$3) - kubectl --username=admin --password=$password \ - create clusterrolebinding cluster-admin-binding \ - --clusterrole=cluster-admin \ - --user=$1 -}