From 4bc91956161a477b96cc7fbb75becd6f16b72870 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Thu, 20 Jul 2017 16:42:26 -0700 Subject: [PATCH] remove update-staging-client-go.sh. Note that client-go/pkg/version is copied from kubernetes --- hack/update-all.sh | 1 - hack/update-staging-client-go.sh | 36 ------ hack/verify-staging-client-go.sh | 29 ----- staging/copy.sh | 198 ------------------------------- 4 files changed, 264 deletions(-) delete mode 100755 hack/update-staging-client-go.sh delete mode 100755 hack/verify-staging-client-go.sh delete mode 100755 staging/copy.sh diff --git a/hack/update-all.sh b/hack/update-all.sh index 02d258ea90d..e999df36772 100755 --- a/hack/update-all.sh +++ b/hack/update-all.sh @@ -73,7 +73,6 @@ BASH_TARGETS=" update-federation-swagger-spec update-federation-generated-swagger-docs update-federation-api-reference-docs - update-staging-client-go update-staging-godeps update-bazel" diff --git a/hack/update-staging-client-go.sh b/hack/update-staging-client-go.sh deleted file mode 100755 index d608ed3e9b3..00000000000 --- a/hack/update-staging-client-go.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# Copyright 2016 The Kubernetes 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 - -KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. -source "${KUBE_ROOT}/hack/lib/util.sh" - -kube::util::ensure_clean_working_dir -kube::util::ensure_godep_version v79 - -cd ${KUBE_ROOT} - -echo "Checking whether godeps are restored" -if ! kube::util::godep_restored 2>&1 | sed 's/^/ /'; then - echo -e '\nExecute script 'hack/godep-restore.sh' to download dependencies.' 1>&2 - exit 1 -fi - -echo "Running staging/copy.sh" -staging/copy.sh -u "$@" 2>&1 | sed 's/^/ /' diff --git a/hack/verify-staging-client-go.sh b/hack/verify-staging-client-go.sh deleted file mode 100755 index 040365196ec..00000000000 --- a/hack/verify-staging-client-go.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Copyright 2016 The Kubernetes 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 - -KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. -cd ${KUBE_ROOT} - -# Smoke test client-go examples -echo "Smoke testing client-go examples" -go install ./staging/src/k8s.io/client-go/examples/... 2>&1 | sed 's/^/ /' - -# Run update-staging-client.sh in dry-run mode, copy nothing into the staging dir, but fail on any diff -hack/update-staging-client-go.sh -d -f "$@" diff --git a/staging/copy.sh b/staging/copy.sh deleted file mode 100755 index b9232a90f3b..00000000000 --- a/staging/copy.sh +++ /dev/null @@ -1,198 +0,0 @@ -#!/bin/bash - -# Copyright 2016 The Kubernetes 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 - - -KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. -source "${KUBE_ROOT}/hack/lib/init.sh" - - -FAIL_ON_CHANGES=false -DRY_RUN=false -RUN_FROM_UPDATE_SCRIPT=false -while getopts ":fdu" opt; do - case $opt in - f) - FAIL_ON_CHANGES=true - ;; - d) - DRY_RUN=true - ;; - u) - RUN_FROM_UPDATE_SCRIPT=true - ;; - \?) - echo "Invalid option: -$OPTARG" >&2 - exit 1 - ;; - esac -done -readonly FAIL_ON_CHANGES DRY_RUN - -if [ "${RUN_FROM_UPDATE_SCRIPT}" != true ]; then - echo "Do not run this script directly, but via hack/update-staging-client-go.sh." - exit 1 -fi - -# PREREQUISITES: run `godep restore` in the main repo before calling this script. -kube::util::ensure-temp-dir -TMP_GOPATH="${KUBE_TEMP}/go" -mkdir -p "${TMP_GOPATH}/src/k8s.io" -CLIENTSET="clientset" -MAIN_REPO_FROM_SRC="k8s.io/kubernetes" -MAIN_REPO="$(cd "${KUBE_ROOT}"; pwd)" # absolute path -CLIENT_REPO_FROM_SRC="k8s.io/client-go" -CLIENT_REPO="${MAIN_REPO}/staging/src/${CLIENT_REPO_FROM_SRC}" -CLIENT_REPO_TEMP="${TMP_GOPATH}/src/k8s.io/construct-client-go" - -if LANG=C sed --help 2>&1 | grep -q GNU; then - SED="sed" -elif which gsed &>/dev/null; then - SED="gsed" -else - echo "Failed to find GNU sed as sed or gsed. If you are on Mac: brew install gnu-sed." >&2 - exit 1 -fi - -# working in the ${CLIENT_REPO_TEMP} so 'godep save' won't complain about dirty working tree. -echo "creating the tmp directory" -mkdir -p "${CLIENT_REPO_TEMP}" -cd "${CLIENT_REPO}" - -# there are two classes of package in staging/client-go, those which are authoritative (client-go has the only copy) -# and those which are copied and rewritten (client-go is not authoritative). -# we first copy out the authoritative packages to the temp location, then copy non-authoritative packages -# then save over the original - - -# save copies code from client-go into the temp folder to make sure we don't lose it by accident -# TODO this is temporary until everything in certain directories is authoritative -function save() { - mkdir -p "$(dirname "${CLIENT_REPO_TEMP}/$1")" - cp -r "${CLIENT_REPO}/$1"* "${CLIENT_REPO_TEMP}/" -} - -# save everything for which the staging directory is the source of truth -save "discovery" -save "dynamic" -save "rest" -save "testing" -save "tools" -save "transport" -save "third_party" -save "plugin" -save "util" -save "examples" -save "OWNERS" -save "Godeps" -save "LICENSE" - -# mkcp copies file from the main repo to the client repo, it creates the directory if it doesn't exist in the client repo. -function mkcp() { - mkdir -p "${CLIENT_REPO_TEMP}/$2" && cp -r "${MAIN_REPO}/$1" "${CLIENT_REPO_TEMP}/$2" -} - -# assemble all the other parts of the staging directory -echo "copying client packages" -# need to copy version. We aren't authoritative here -# version has subdirs which we don't need. Only copy the files we want -mkdir -p "${CLIENT_REPO_TEMP}/pkg/version" -find "${MAIN_REPO}/pkg/version" -maxdepth 1 -type f | xargs -I{} cp {} "${CLIENT_REPO_TEMP}/pkg/version" -# need to copy clientsets, though later we should copy APIs and later generate clientsets -mkcp "pkg/client/clientset_generated/${CLIENTSET}" "pkg/client/clientset_generated" -mkcp "pkg/client/informers/informers_generated/externalversions" "pkg/client/informers/informers_generated" -mkcp "pkg/client/listers" "pkg/client" -# remove internalversion listers -find "${CLIENT_REPO_TEMP}/pkg/client/listers/" -maxdepth 2 -mindepth 2 -name internalversion -exec rm -r {} \; - -echo "rewriting imports" -grep -Rl "\"${MAIN_REPO_FROM_SRC}" "${CLIENT_REPO_TEMP}" | \ - grep "\.go" | \ - grep -v "vendor/" | \ - xargs ${SED} -i "s|\"${MAIN_REPO_FROM_SRC}|\"${CLIENT_REPO_FROM_SRC}|g" - -echo "rearranging directory layout" -# $1 and $2 are relative to ${CLIENT_REPO_TEMP} -function mvfolder { - local src=${1%/#/} - local dst=${2%/#/} - mkdir -p "${CLIENT_REPO_TEMP}/${dst}" - # move - mv "${CLIENT_REPO_TEMP}/${src}"/* "${CLIENT_REPO_TEMP}/${dst}" - # rewrite package - local src_package="${src##*/}" - local dst_package="${dst##*/}" - find "${CLIENT_REPO_TEMP}/${dst}" -type f -name "*.go" -print0 | xargs -0 ${SED} -i "s,package ${src_package},package ${dst_package},g" - - { grep -Rl "\"${CLIENT_REPO_FROM_SRC}/${src}" "${CLIENT_REPO_TEMP}" || true ; } | while read -r target ; do - # rewrite imports - # the first rule is to convert import lines like `restclient "k8s.io/client-go/pkg/client/restclient"`, - # where a package alias is the same the package name. - ${SED} -i "s,\<${src_package} \"${CLIENT_REPO_FROM_SRC}/${src},${dst_package} \"${CLIENT_REPO_FROM_SRC}/${dst},g" "${target}" - ${SED} -i "s,\"${CLIENT_REPO_FROM_SRC}/${src},\"${CLIENT_REPO_FROM_SRC}/${dst},g" "${target}" - # rewrite import invocation - if [ "${src_package}" != "${dst_package}" ]; then - ${SED} -i "s,\<${src_package}\.\([a-zA-Z]\),${dst_package}\.\1,g" "${target}" - fi - done -} - -mvfolder "pkg/client/clientset_generated/${CLIENTSET}" kubernetes -rm -f "${CLIENT_REPO_TEMP}/kubernetes/import_known_versions.go" -mvfolder "pkg/client/informers/informers_generated/externalversions" informers -mvfolder "pkg/client/listers" listers -if [ "$(find "${CLIENT_REPO_TEMP}"/pkg/client -type f -name "*.go")" ]; then - echo "${CLIENT_REPO_TEMP}/pkg/client is expected to be empty" - exit 1 -else - rm -r "${CLIENT_REPO_TEMP}"/pkg/client -fi - -echo "running gofmt" -find "${CLIENT_REPO_TEMP}" -type f -name "*.go" -print0 | xargs -0 gofmt -w - -echo "remove black listed files" -find "${CLIENT_REPO_TEMP}" -type f \( \ - -name "*.json" -not -name "Godeps.json" -o \ - -name "*.yaml" -o \ - -name "*.yml" -o \ - -name "*.sh" \ - \) -delete - -if [ "${FAIL_ON_CHANGES}" = true ]; then - echo "running FAIL_ON_CHANGES" - # ignore base.go in diff - cp "${CLIENT_REPO}/pkg/version/base.go" "${CLIENT_REPO_TEMP}/pkg/version/" - # TODO(mikedanese): figure out what to do with BUILD files here - if diff -NauprB -x '*BUILD' -I '^\s*\"Comment\"' -I "GoVersion.*\|GodepVersion.*" "${CLIENT_REPO}" "${CLIENT_REPO_TEMP}"; then - echo "${CLIENT_REPO} up to date." - exit 0 - else - echo "${CLIENT_REPO} is out of date. Please run hack/update-staging-client-go.sh" - exit 1 - fi -fi - -# clean the ${CLIENT_REPO} -echo "move to the client repo" -if [ "${DRY_RUN}" = false ]; then - ls "${CLIENT_REPO}" | { grep -v '_tmp' || true; } | xargs rm -rf - mv "${CLIENT_REPO_TEMP}"/* "${CLIENT_REPO}" - git checkout HEAD -- $(find "${CLIENT_REPO}" -name BUILD) || true -fi