From 64e1853910244739c8588e1a35eed1e1230f4dd3 Mon Sep 17 00:00:00 2001 From: Balint Pato Date: Wed, 17 Oct 2018 14:22:26 -0700 Subject: [PATCH] small fixes to boilerplate and integration test scripts (#3212) Introduces hack/boilerplate/fix.sh that automatically fixes the copyright header in files. --- hack/boilerplate/boilerplate.py | 2 +- hack/boilerplate/fix.sh | 49 +++++++++++++++++++ hack/jenkins/common.sh | 12 ++--- .../minishift_linux_integration_tests_kvm.sh | 4 +- .../windows_integration_test_virtualbox.ps1 | 6 +-- ...tegration_test_virtualbox_kubeadm_crio.ps1 | 6 +-- 6 files changed, 62 insertions(+), 17 deletions(-) create mode 100755 hack/boilerplate/fix.sh diff --git a/hack/boilerplate/boilerplate.py b/hack/boilerplate/boilerplate.py index db11b93da0..81f719d745 100755 --- a/hack/boilerplate/boilerplate.py +++ b/hack/boilerplate/boilerplate.py @@ -115,7 +115,7 @@ def normalize_files(files): newfiles.append(pathname) for i, pathname in enumerate(newfiles): if not os.path.isabs(pathname): - newfiles[i] = os.path.join(args.rootdir, pathname) + newfiles[i] = os.path.join(rootdir, pathname) return newfiles def get_files(extensions): diff --git a/hack/boilerplate/fix.sh b/hack/boilerplate/fix.sh new file mode 100755 index 0000000000..4d01cb312c --- /dev/null +++ b/hack/boilerplate/fix.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Copyright 2018 The Kubernetes Authors All rights reserved. +# +# 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. + +export readonly ROOT_DIR=${1:-$(pwd)} + +function prepend() { + local ignore="vendor\|\_gopath\|assets.go" + local pattern=$1 + local ref=$2 + local headers=$3 + local files=$(hack/boilerplate/boilerplate.py --rootdir ${ROOT_DIR} | grep -v "$ignore" | grep "$pattern") + for f in ${files}; do + echo ${f}; + local copyright="$(cat hack/boilerplate/boilerplate.${ref}.txt | sed s/YEAR/$(date +%Y)/g)" + local file_headers="" + + if [ "${headers}" != "" ]; then + file_headers="$(cat ${f} | grep ${headers})" + fi + + if [ "${file_headers}" != "" ]; then + fileContent="$(cat ${f} | grep -v ${headers})" + printf '%s\n\n%s\n%s\n' "$file_headers" "${copyright}" "$fileContent" > ${f} + else + fileContent="$(cat ${f})" + printf '%s\n\n%s\n' "${copyright}" "$fileContent" > ${f} + fi + + done +} + +prepend "\.go" "go" "+build" +prepend "\.py" "py" +prepend "\.sh" "sh" "#!" +prepend Makefile Makefile +prepend Dockerfile Dockerfile diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index 69a7d9fb47..3d8b703022 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -36,14 +36,10 @@ fi # Add the out/ directory to the PATH, for using new drivers. export PATH="$(pwd)/out/":$PATH -gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/minikube-${OS_ARCH} out/ -gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/docker-machine-driver-* out/ -gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/e2e-${OS_ARCH} out/ -gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/busybox.yaml testdata/ -gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/pvc.yaml testdata/ -gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/busybox-mount-test.yaml testdata/ -gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/nginx-pod-svc.yaml testdata/ -gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/nginx-ing.yaml testdata/ +gsutil -m cp gs://minikube-builds/${MINIKUBE_LOCATION}/minikube-${OS_ARCH} out/ +gsutil -m cp gs://minikube-builds/${MINIKUBE_LOCATION}/docker-machine-driver-* out/ +gsutil -m cp gs://minikube-builds/${MINIKUBE_LOCATION}/e2e-${OS_ARCH} out/ +gsutil -m cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/* testdata/ # Set the executable bit on the e2e binary and out binary chmod +x out/e2e-${OS_ARCH} diff --git a/hack/jenkins/minishift_linux_integration_tests_kvm.sh b/hack/jenkins/minishift_linux_integration_tests_kvm.sh index 52bc60d1c9..45f521fc5c 100755 --- a/hack/jenkins/minishift_linux_integration_tests_kvm.sh +++ b/hack/jenkins/minishift_linux_integration_tests_kvm.sh @@ -35,8 +35,8 @@ EXTRA_FLAGS="--show-libmachine-logs" mkdir -p out/ curl -L http://artifacts.ci.centos.org/minishift/minishift/master/latest/linux-amd64/minishift -o out/minishift -gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/docker-machine-driver-* out/ || true -gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/minikube-testing.iso out/ || true +gsutil -m cp gs://minikube-builds/${MINIKUBE_LOCATION}/docker-machine-driver-* out/ || true +gsutil -m cp gs://minikube-builds/${MINIKUBE_LOCATION}/minikube-testing.iso out/ || true # Set the executable bit on the minishift and driver binary chmod +x out/minishift diff --git a/hack/jenkins/windows_integration_test_virtualbox.ps1 b/hack/jenkins/windows_integration_test_virtualbox.ps1 index cd886564dc..04b8a7af15 100644 --- a/hack/jenkins/windows_integration_test_virtualbox.ps1 +++ b/hack/jenkins/windows_integration_test_virtualbox.ps1 @@ -13,9 +13,9 @@ # limitations under the License. mkdir -p out -gsutil.cmd cp gs://minikube-builds/$env:MINIKUBE_LOCATION/minikube-windows-amd64.exe out/ -gsutil.cmd cp gs://minikube-builds/$env:MINIKUBE_LOCATION/e2e-windows-amd64.exe out/ -gsutil.cmd cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata . +gsutil.cmd -m cp gs://minikube-builds/$env:MINIKUBE_LOCATION/minikube-windows-amd64.exe out/ +gsutil.cmd -m cp gs://minikube-builds/$env:MINIKUBE_LOCATION/e2e-windows-amd64.exe out/ +gsutil.cmd -m cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata . ./out/minikube-windows-amd64.exe delete diff --git a/hack/jenkins/windows_integration_test_virtualbox_kubeadm_crio.ps1 b/hack/jenkins/windows_integration_test_virtualbox_kubeadm_crio.ps1 index 104df0ab90..53cab8ee12 100644 --- a/hack/jenkins/windows_integration_test_virtualbox_kubeadm_crio.ps1 +++ b/hack/jenkins/windows_integration_test_virtualbox_kubeadm_crio.ps1 @@ -13,9 +13,9 @@ # limitations under the License. mkdir -p out -gsutil.cmd cp gs://minikube-builds/$env:MINIKUBE_LOCATION/minikube-windows-amd64.exe out/ -gsutil.cmd cp gs://minikube-builds/$env:MINIKUBE_LOCATION/e2e-windows-amd64.exe out/ -gsutil.cmd cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata . +gsutil.cmd -m cp gs://minikube-builds/$env:MINIKUBE_LOCATION/minikube-windows-amd64.exe out/ +gsutil.cmd -m cp gs://minikube-builds/$env:MINIKUBE_LOCATION/e2e-windows-amd64.exe out/ +gsutil.cmd -m cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata . ./out/minikube-windows-amd64.exe delete