mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-19 22:44:21 +00:00
Support cross-compiling for clients
Signed-off-by: Andy Goldstein <andy.goldstein@gmail.com>
This commit is contained in:
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 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
|
||||
|
||||
if [ -z "${PKG}" ]; then
|
||||
echo "PKG must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${BIN}" ]; then
|
||||
echo "BIN must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${GOOS}" ]; then
|
||||
echo "GOOS must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${GOARCH}" ]; then
|
||||
echo "GOARCH must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${VERSION}" ]; then
|
||||
echo "VERSION must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export CGO_ENABLED=0
|
||||
|
||||
GIT_SHA=$(git describe --tags --always)
|
||||
GIT_DIRTY=$(git status --porcelain 2> /dev/null)
|
||||
if [[ -z "${GIT_DIRTY}" ]]; then
|
||||
GIT_TREE_STATE=clean
|
||||
else
|
||||
GIT_TREE_STATE=dirty
|
||||
fi
|
||||
|
||||
LDFLAGS="-X ${PKG}/pkg/buildinfo.Version=${VERSION}"
|
||||
LDFLAGS="${LDFLAGS} -X ${PKG}/pkg/buildinfo.GitSHA=${GIT_SHA}"
|
||||
LDFLAGS="${LDFLAGS} -X ${PKG}/pkg/buildinfo.GitTreeState=${GIT_TREE_STATE}"
|
||||
|
||||
OUTPUT=/output/${GOOS}/${GOARCH}/${BIN}
|
||||
if [[ "${GOOS}" = "windows" ]]; then
|
||||
OUTPUT="${OUTPUT}.exe"
|
||||
fi
|
||||
|
||||
go build -i \
|
||||
-o ${OUTPUT} \
|
||||
-installsuffix "static" \
|
||||
-ldflags "${LDFLAGS}" \
|
||||
${PKG}/cmd/${BIN}
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 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
|
||||
|
||||
export CGO_ENABLED=0
|
||||
|
||||
TARGETS=$(for d in "$@"; do echo ./$d/...; done)
|
||||
|
||||
echo "Running tests:"
|
||||
go test -i -installsuffix "static" ${TARGETS}
|
||||
go test -installsuffix "static" -timeout 60s ${TARGETS}
|
||||
echo
|
||||
|
||||
echo -n "Checking gofmt: "
|
||||
ERRS=$(find "$@" -type f -name \*.go | xargs gofmt -l 2>&1 || true)
|
||||
if [ -n "${ERRS}" ]; then
|
||||
echo "FAIL - the following files need to be gofmt'ed:"
|
||||
for e in ${ERRS}; do
|
||||
echo " $e"
|
||||
done
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
echo "PASS"
|
||||
echo
|
||||
|
||||
# TODO(ncdc): there are govet failures in the generated clientset and the log error location hook
|
||||
# that prevent us from running vet at this time.
|
||||
#
|
||||
# echo -n "Checking go vet: "
|
||||
# ERRS=$(go vet ${TARGETS} 2>&1 || true)
|
||||
# if [ -n "${ERRS}" ]; then
|
||||
# echo "FAIL"
|
||||
# echo "${ERRS}"
|
||||
# echo
|
||||
# exit 1
|
||||
# fi
|
||||
# echo "PASS"
|
||||
# echo
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash -e
|
||||
#
|
||||
# Copyright 2017 the Heptio Ark contributors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
HACK_DIR=$(dirname "${BASH_SOURCE}")
|
||||
|
||||
echo "Running all update scripts"
|
||||
|
||||
for f in ${HACK_DIR}/update-*.sh; do
|
||||
if [[ $f = "${HACK_DIR}/update-all.sh" ]]; then
|
||||
continue
|
||||
fi
|
||||
$f
|
||||
done
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash -e
|
||||
#
|
||||
# Copyright 2017 the Heptio Ark contributors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
HACK_DIR=$(dirname "${BASH_SOURCE}")
|
||||
|
||||
echo "Updating formatting"
|
||||
|
||||
gofmt -w=true $(find . -type f -name "*.go" -not -path "./vendor/*" -not -path "./pkg/generated/*")
|
||||
goimports -w=true -d $(find . -type f -name "*.go" -not -path "./vendor/*" -not -path "./pkg/generated/*")
|
||||
|
||||
echo "Success!"
|
||||
@@ -35,6 +35,8 @@ for i in "$@"; do
|
||||
done
|
||||
|
||||
if [[ -z ${verify} ]]; then
|
||||
echo "Updating generated clientsets"
|
||||
|
||||
find ${ARK_ROOT}/pkg/generated/clientset \
|
||||
\( \
|
||||
-name '*.go' -and \
|
||||
@@ -54,3 +56,5 @@ ${BIN}/client-gen \
|
||||
--input ark/v1 \
|
||||
--clientset-name clientset \
|
||||
$@
|
||||
|
||||
echo "Success!"
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
ARK_ROOT=$(realpath $(dirname ${BASH_SOURCE})/..)
|
||||
BIN=${ARK_ROOT}/_output/bin
|
||||
mkdir -p ${BIN}
|
||||
|
||||
echo "Updating generated docs"
|
||||
|
||||
go build -o ${BIN}/docs-gen ./docs/generate/ark.go
|
||||
|
||||
if [[ $# -gt 1 ]]; then
|
||||
@@ -30,3 +33,5 @@ if [[ -z "${OUTPUT_DIR}" ]]; then
|
||||
fi
|
||||
|
||||
${BIN}/docs-gen ark ${OUTPUT_DIR}
|
||||
|
||||
echo "Success!"
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
ARK_ROOT=$(realpath $(dirname ${BASH_SOURCE})/..)
|
||||
BIN=${ARK_ROOT}/_output/bin
|
||||
mkdir -p ${BIN}
|
||||
|
||||
echo "Updating generated informers"
|
||||
|
||||
go build -o ${BIN}/informer-gen ./vendor/k8s.io/kubernetes/cmd/libs/go2idl/informer-gen
|
||||
|
||||
OUTPUT_BASE=""
|
||||
@@ -48,3 +51,5 @@ ${BIN}/informer-gen \
|
||||
--internal-clientset-package github.com/heptio/ark/pkg/generated/clientset \
|
||||
--versioned-clientset-package github.com/heptio/ark/pkg/generated/clientset \
|
||||
$@
|
||||
|
||||
echo "Success!"
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
ARK_ROOT=$(realpath $(dirname ${BASH_SOURCE})/..)
|
||||
BIN=${ARK_ROOT}/_output/bin
|
||||
mkdir -p ${BIN}
|
||||
|
||||
echo "Updating generated listers"
|
||||
|
||||
go build -o ${BIN}/lister-gen ./vendor/k8s.io/kubernetes/cmd/libs/go2idl/lister-gen
|
||||
|
||||
OUTPUT_BASE=""
|
||||
@@ -53,3 +56,5 @@ ${BIN}/lister-gen \
|
||||
--input-dirs github.com/heptio/ark/pkg/apis/ark/v1 \
|
||||
--output-package github.com/heptio/ark/pkg/generated/listers \
|
||||
$@
|
||||
|
||||
echo "Success!"
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash -e
|
||||
#
|
||||
# Copyright 2017 the Heptio Ark contributors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
HACK_DIR=$(dirname "${BASH_SOURCE}")
|
||||
|
||||
echo "Running all verification scripts"
|
||||
|
||||
for f in ${HACK_DIR}/verify-*.sh; do
|
||||
if [[ $f = "${HACK_DIR}/verify-all.sh" ]]; then
|
||||
continue
|
||||
fi
|
||||
$f
|
||||
done
|
||||
@@ -15,8 +15,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
HACK_DIR=$(dirname "${BASH_SOURCE}")
|
||||
|
||||
echo "Verifying generated clientsets"
|
||||
|
||||
if ! output=$(${HACK_DIR}/update-generated-clientsets.sh --verify-only 2>&1); then
|
||||
echo "FAILURE: verification of clientsets failed:"
|
||||
echo "${output}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Success!"
|
||||
|
||||
@@ -25,7 +25,9 @@ cleanup() {
|
||||
rm -rf ${TMP_DIR}
|
||||
}
|
||||
|
||||
${HACK_DIR}/update-generated-docs.sh ${TMP_DIR}
|
||||
echo "Verifying generated docs"
|
||||
|
||||
${HACK_DIR}/update-generated-docs.sh ${TMP_DIR} > /dev/null
|
||||
|
||||
exclude_file="README.md"
|
||||
output=$(echo "`diff -r ${DOCS_DIR} ${TMP_DIR}`" | sed "/${exclude_file}/d")
|
||||
@@ -35,3 +37,5 @@ if [[ -n "${output}" ]] ; then
|
||||
echo "${output}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Success!"
|
||||
|
||||
@@ -15,8 +15,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
HACK_DIR=$(dirname "${BASH_SOURCE}")
|
||||
|
||||
echo "Verifying generated informers"
|
||||
|
||||
if ! output=$(${HACK_DIR}/update-generated-informers.sh --verify-only 2>&1); then
|
||||
echo "FAILURE: verification of informers failed:"
|
||||
echo "${output}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Success!"
|
||||
|
||||
@@ -15,8 +15,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
HACK_DIR=$(dirname "${BASH_SOURCE}")
|
||||
|
||||
echo "Verifying generated listers"
|
||||
|
||||
if ! output=$(${HACK_DIR}/update-generated-listers.sh --verify-only 2>&1); then
|
||||
echo "FAILURE: verification of listers failed:"
|
||||
echo "${output}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Success!"
|
||||
|
||||
Reference in New Issue
Block a user