2018-04-16 12:31:44 -04:00
|
|
|
#!/usr/bin/env bash
|
2016-05-13 15:15:11 -04:00
|
|
|
|
|
|
|
|
# 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 pipefail
|
2016-07-29 20:14:11 -04:00
|
|
|
set -o nounset
|
2016-05-13 15:15:11 -04:00
|
|
|
|
2019-02-21 21:49:15 -05:00
|
|
|
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
|
|
|
|
export KUBE_ROOT
|
2018-04-03 21:43:49 -04:00
|
|
|
source "${KUBE_ROOT}/hack/lib/init.sh"
|
2018-01-13 19:25:18 -05:00
|
|
|
source "${KUBE_ROOT}/hack/lib/logging.sh"
|
2016-08-04 20:35:26 -04:00
|
|
|
|
2018-03-15 18:32:24 -04:00
|
|
|
if [[ ! -d "${KUBE_ROOT}/pkg" ]]; then
|
|
|
|
|
echo "${KUBE_ROOT}/pkg not detected. This script should be run from a location where the source dirs are available."
|
2016-05-13 15:15:11 -04:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2016-11-16 20:36:35 -05:00
|
|
|
# kube::golang::build_kube_toolchain installs the vendored go-bindata in
|
|
|
|
|
# $GOPATH/bin, so make sure that's explicitly part of our $PATH.
|
2018-04-03 21:43:49 -04:00
|
|
|
export PATH="${KUBE_OUTPUT_BINPATH}:${PATH}"
|
2016-11-16 20:36:35 -05:00
|
|
|
|
2016-08-02 17:50:12 -04:00
|
|
|
if ! which go-bindata &>/dev/null ; then
|
2016-11-16 20:36:35 -05:00
|
|
|
echo "Cannot find go-bindata."
|
2016-05-13 15:15:11 -04:00
|
|
|
exit 5
|
|
|
|
|
fi
|
|
|
|
|
|
2017-01-10 09:50:39 -05:00
|
|
|
# run the generation from the root directory for stable output
|
2018-01-12 10:29:29 -05:00
|
|
|
pushd "${KUBE_ROOT}" >/dev/null
|
2017-01-10 09:50:39 -05:00
|
|
|
|
2016-12-14 02:18:11 -05:00
|
|
|
# These are files for e2e tests.
|
2017-01-10 09:50:39 -05:00
|
|
|
BINDATA_OUTPUT="test/e2e/generated/bindata.go"
|
2018-04-11 21:49:38 -04:00
|
|
|
# IMPORTANT: if you make any changes to these arguments, you must also update
|
|
|
|
|
# test/e2e/generated/BUILD and/or build/bindata.bzl.
|
2017-01-10 09:50:39 -05:00
|
|
|
go-bindata -nometadata -o "${BINDATA_OUTPUT}.tmp" -pkg generated \
|
2018-04-11 18:22:26 -04:00
|
|
|
-ignore .jpg -ignore .png -ignore .md -ignore 'BUILD(\.bazel)?' \
|
2017-01-10 09:50:39 -05:00
|
|
|
"test/e2e/testing-manifests/..." \
|
|
|
|
|
"test/images/..." \
|
2017-06-14 13:19:47 -04:00
|
|
|
"test/fixtures/..."
|
2016-05-13 15:15:11 -04:00
|
|
|
|
2016-08-15 18:39:40 -04:00
|
|
|
gofmt -s -w "${BINDATA_OUTPUT}.tmp"
|
2016-05-13 15:15:11 -04:00
|
|
|
|
2016-08-15 18:39:40 -04:00
|
|
|
# Here we compare and overwrite only if different to avoid updating the
|
|
|
|
|
# timestamp and triggering a rebuild. The 'cat' redirect trick to preserve file
|
|
|
|
|
# permissions of the target file.
|
|
|
|
|
if ! cmp -s "${BINDATA_OUTPUT}.tmp" "${BINDATA_OUTPUT}" ; then
|
|
|
|
|
cat "${BINDATA_OUTPUT}.tmp" > "${BINDATA_OUTPUT}"
|
|
|
|
|
V=2 kube::log::info "Generated bindata file : ${BINDATA_OUTPUT} has $(wc -l ${BINDATA_OUTPUT}) lines of lovely automated artifacts"
|
|
|
|
|
else
|
|
|
|
|
V=2 kube::log::info "No changes in generated bindata file: ${BINDATA_OUTPUT}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
rm -f "${BINDATA_OUTPUT}.tmp"
|
2016-12-14 02:18:11 -05:00
|
|
|
|
|
|
|
|
# These are files for runtime code
|
2018-10-11 19:03:57 -04:00
|
|
|
BINDATA_OUTPUT="pkg/kubectl/generated/bindata.go"
|
2018-04-11 21:49:38 -04:00
|
|
|
# IMPORTANT: if you make any changes to these arguments, you must also update
|
|
|
|
|
# pkg/generated/BUILD and/or build/bindata.bzl.
|
2017-01-10 09:50:39 -05:00
|
|
|
go-bindata -nometadata -nocompress -o "${BINDATA_OUTPUT}.tmp" -pkg generated \
|
2018-04-11 18:22:26 -04:00
|
|
|
-ignore .jpg -ignore .png -ignore .md -ignore 'BUILD(\.bazel)?' \
|
2017-01-10 09:50:39 -05:00
|
|
|
"translations/..."
|
2016-12-14 02:18:11 -05:00
|
|
|
|
|
|
|
|
gofmt -s -w "${BINDATA_OUTPUT}.tmp"
|
|
|
|
|
|
|
|
|
|
# Here we compare and overwrite only if different to avoid updating the
|
|
|
|
|
# timestamp and triggering a rebuild. The 'cat' redirect trick to preserve file
|
|
|
|
|
# permissions of the target file.
|
|
|
|
|
if ! cmp -s "${BINDATA_OUTPUT}.tmp" "${BINDATA_OUTPUT}" ; then
|
|
|
|
|
cat "${BINDATA_OUTPUT}.tmp" > "${BINDATA_OUTPUT}"
|
|
|
|
|
V=2 kube::log::info "Generated bindata file : ${BINDATA_OUTPUT} has $(wc -l ${BINDATA_OUTPUT}) lines of lovely automated artifacts"
|
|
|
|
|
else
|
|
|
|
|
V=2 kube::log::info "No changes in generated bindata file: ${BINDATA_OUTPUT}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
rm -f "${BINDATA_OUTPUT}.tmp"
|
2017-01-10 09:50:39 -05:00
|
|
|
|
2018-01-12 10:29:29 -05:00
|
|
|
popd >/dev/null
|