From 32319d6ef768db638a93c753901c08b15624e0d2 Mon Sep 17 00:00:00 2001 From: fisherxu Date: Mon, 22 Jan 2018 20:37:37 +0800 Subject: [PATCH] add boilerplate.generatego.txt and let all code-generators use it remove YEAR field in boilerplate under staging add Do Not Edit for types_swagger_doc and add apiextensions-apiserver's example in codegen.sh --- hack/boilerplate/boilerplate.generatego.txt | 16 ++++++++++++++++ hack/build-ui.sh | 2 +- hack/lib/protoc.sh | 3 +-- hack/lib/swagger.sh | 4 ++-- hack/update-codegen.sh | 9 +++++---- hack/update-generated-kms-dockerized.sh | 3 +-- hack/update-generated-protobuf-dockerized.sh | 2 +- hack/update-generated-runtime-dockerized.sh | 3 +-- .../hack/boilerplate.go.txt | 2 +- .../code-generator/hack/boilerplate.go.txt | 2 +- .../kube-aggregator/hack/boilerplate.go.txt | 2 +- .../src/k8s.io/metrics/hack/boilerplate.go.txt | 2 +- .../sample-apiserver/hack/boilerplate.go.txt | 2 +- .../sample-controller/hack/boilerplate.go.txt | 2 +- 14 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 hack/boilerplate/boilerplate.generatego.txt diff --git a/hack/boilerplate/boilerplate.generatego.txt b/hack/boilerplate/boilerplate.generatego.txt new file mode 100644 index 00000000000..b7c650da470 --- /dev/null +++ b/hack/boilerplate/boilerplate.generatego.txt @@ -0,0 +1,16 @@ +/* +Copyright 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. +*/ + diff --git a/hack/build-ui.sh b/hack/build-ui.sh index 6e2e0e5d539..540d94ea786 100755 --- a/hack/build-ui.sh +++ b/hack/build-ui.sh @@ -42,7 +42,7 @@ function kube::hack::build_ui() { go-bindata -nocompress -o "${output_file}" -prefix ${PWD} -pkg "${pkg}" "${src}" local year=$(date +%Y) - cat hack/boilerplate/boilerplate.go.txt | sed "s/YEAR/${year}/" > "${TMP_DATAFILE}" + cat hack/boilerplate/boilerplate.generatego.txt > "${TMP_DATAFILE}" echo -e "// generated by hack/build-ui.sh; DO NOT EDIT\n" >> "${TMP_DATAFILE}" cat "${output_file}" >> "${TMP_DATAFILE}" diff --git a/hack/lib/protoc.sh b/hack/lib/protoc.sh index 1adcea4b944..935f3315fa2 100644 --- a/hack/lib/protoc.sh +++ b/hack/lib/protoc.sh @@ -71,8 +71,7 @@ function kube::protoc::format() { local package=${1} # Update boilerplate for the generated file. - echo "$(cat hack/boilerplate/boilerplate.go.txt ${package}/api.pb.go)" > ${package}/api.pb.go - sed -i".bak" "s/Copyright YEAR/Copyright $(date '+%Y')/g" ${package}/api.pb.go + echo "$(cat hack/boilerplate/boilerplate.generatego.txt ${package}/api.pb.go)" > ${package}/api.pb.go # Run gofmt to clean up the generated code. kube::golang::verify_go_version diff --git a/hack/lib/swagger.sh b/hack/lib/swagger.sh index af872d807e5..fc0ac6b068f 100644 --- a/hack/lib/swagger.sh +++ b/hack/lib/swagger.sh @@ -34,7 +34,7 @@ kube::swagger::gen_types_swagger_doc() { echo "Generating swagger type docs for ${group_version} at ${gv_dir}" - sed 's/YEAR/2016/' hack/boilerplate/boilerplate.go.txt > "$TMPFILE" + echo -e "$(cat hack/boilerplate/boilerplate.generatego.txt)\n" > "$TMPFILE" echo "package ${group_version##*/}" >> "$TMPFILE" cat >> "$TMPFILE" < ${KUBE_KMS_GRPC_ROOT}/service.pb.go -sed -i".bak" "s/Copyright YEAR/Copyright $(date '+%Y')/g" ${KUBE_KMS_GRPC_ROOT}/service.pb.go +echo "$(cat hack/boilerplate/boilerplate.generatego.txt ${KUBE_KMS_GRPC_ROOT}/service.pb.go)" > ${KUBE_KMS_GRPC_ROOT}/service.pb.go # Run gofmt to clean up the generated code. kube::golang::verify_go_version diff --git a/hack/update-generated-protobuf-dockerized.sh b/hack/update-generated-protobuf-dockerized.sh index 658a82942f0..2b95f6e27ed 100755 --- a/hack/update-generated-protobuf-dockerized.sh +++ b/hack/update-generated-protobuf-dockerized.sh @@ -94,5 +94,5 @@ PATH="${KUBE_ROOT}/_output/bin:${PATH}" \ --proto-import="${KUBE_ROOT}/vendor" \ --proto-import="${KUBE_ROOT}/third_party/protobuf" \ --packages=$(IFS=, ; echo "${PACKAGES[*]}") \ - --go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.go.txt \ + --go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt \ "$@" diff --git a/hack/update-generated-runtime-dockerized.sh b/hack/update-generated-runtime-dockerized.sh index 724c5d1559a..13d9c224410 100755 --- a/hack/update-generated-runtime-dockerized.sh +++ b/hack/update-generated-runtime-dockerized.sh @@ -54,8 +54,7 @@ PATH="${gogopath}:${PATH}" \ --gogo_out=plugins=grpc:${KUBE_REMOTE_RUNTIME_ROOT} ${KUBE_REMOTE_RUNTIME_ROOT}/api.proto # Update boilerplate for the generated file. -echo "$(cat hack/boilerplate/boilerplate.go.txt ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go)" > ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go -sed -i".bak" "s/Copyright YEAR/Copyright $(date '+%Y')/g" ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go +echo "$(cat hack/boilerplate/boilerplate.generatego.txt ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go)" > ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go # Run gofmt to clean up the generated code. kube::golang::verify_go_version diff --git a/staging/src/k8s.io/apiextensions-apiserver/hack/boilerplate.go.txt b/staging/src/k8s.io/apiextensions-apiserver/hack/boilerplate.go.txt index 59e740c1ee4..b7c650da470 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/hack/boilerplate.go.txt +++ b/staging/src/k8s.io/apiextensions-apiserver/hack/boilerplate.go.txt @@ -1,5 +1,5 @@ /* -Copyright YEAR The Kubernetes Authors. +Copyright 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. diff --git a/staging/src/k8s.io/code-generator/hack/boilerplate.go.txt b/staging/src/k8s.io/code-generator/hack/boilerplate.go.txt index 59e740c1ee4..b7c650da470 100644 --- a/staging/src/k8s.io/code-generator/hack/boilerplate.go.txt +++ b/staging/src/k8s.io/code-generator/hack/boilerplate.go.txt @@ -1,5 +1,5 @@ /* -Copyright YEAR The Kubernetes Authors. +Copyright 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. diff --git a/staging/src/k8s.io/kube-aggregator/hack/boilerplate.go.txt b/staging/src/k8s.io/kube-aggregator/hack/boilerplate.go.txt index 59e740c1ee4..b7c650da470 100644 --- a/staging/src/k8s.io/kube-aggregator/hack/boilerplate.go.txt +++ b/staging/src/k8s.io/kube-aggregator/hack/boilerplate.go.txt @@ -1,5 +1,5 @@ /* -Copyright YEAR The Kubernetes Authors. +Copyright 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. diff --git a/staging/src/k8s.io/metrics/hack/boilerplate.go.txt b/staging/src/k8s.io/metrics/hack/boilerplate.go.txt index 59e740c1ee4..b7c650da470 100644 --- a/staging/src/k8s.io/metrics/hack/boilerplate.go.txt +++ b/staging/src/k8s.io/metrics/hack/boilerplate.go.txt @@ -1,5 +1,5 @@ /* -Copyright YEAR The Kubernetes Authors. +Copyright 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. diff --git a/staging/src/k8s.io/sample-apiserver/hack/boilerplate.go.txt b/staging/src/k8s.io/sample-apiserver/hack/boilerplate.go.txt index 59e740c1ee4..b7c650da470 100644 --- a/staging/src/k8s.io/sample-apiserver/hack/boilerplate.go.txt +++ b/staging/src/k8s.io/sample-apiserver/hack/boilerplate.go.txt @@ -1,5 +1,5 @@ /* -Copyright YEAR The Kubernetes Authors. +Copyright 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. diff --git a/staging/src/k8s.io/sample-controller/hack/boilerplate.go.txt b/staging/src/k8s.io/sample-controller/hack/boilerplate.go.txt index 59e740c1ee4..b7c650da470 100644 --- a/staging/src/k8s.io/sample-controller/hack/boilerplate.go.txt +++ b/staging/src/k8s.io/sample-controller/hack/boilerplate.go.txt @@ -1,5 +1,5 @@ /* -Copyright YEAR The Kubernetes Authors. +Copyright 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.