From 296fbdea85c5b9ce69ae1265199f912d272dc56f Mon Sep 17 00:00:00 2001 From: Charles Moulliard Date: Wed, 29 May 2019 10:34:56 +0200 Subject: [PATCH] Add script to fetch kubebuilder binaries Signed-off-by: Charles Moulliard --- scripts/fetch-test-binaries.sh | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/scripts/fetch-test-binaries.sh b/scripts/fetch-test-binaries.sh index f1f641a..810da56 100755 --- a/scripts/fetch-test-binaries.sh +++ b/scripts/fetch-test-binaries.sh @@ -1 +1,61 @@ #!/usr/bin/env bash + +set -e + +#hack_dir=$(dirname ${BASH_SOURCE}) +#source ${hack_dir}/common.sh + +k8s_version=1.14.1 +goarch=amd64 +goos="unknown" + +if [[ "$OSTYPE" == "linux-gnu" ]]; then + goos="linux" +elif [[ "$OSTYPE" == "darwin"* ]]; then + goos="darwin" +fi + +if [[ "$goos" == "unknown" ]]; then + echo "OS '$OSTYPE' not supported. Aborting." >&2 + exit 1 +fi + +tmp_root=./_out +kb_root_dir=$tmp_root/kubebuilder + +# Turn colors in this script off by setting the NO_COLOR variable in your +# environment to any value: +# +# $ NO_COLOR=1 test.sh +NO_COLOR=${NO_COLOR:-""} +if [ -z "$NO_COLOR" ]; then + header=$'\e[1;33m' + reset=$'\e[0m' +else + header='' + reset='' +fi + +function header_text { + echo "$header$*$reset" +} + +# fetch k8s API gen tools and make it available under kb_root_dir/bin. +function fetch_kb_tools { + header_text "fetching tools" + mkdir -p $tmp_root + kb_tools_archive_name="kubebuilder-tools-$k8s_version-$goos-$goarch.tar.gz" + kb_tools_download_url="https://storage.googleapis.com/kubebuilder-tools/$kb_tools_archive_name" + + kb_tools_archive_path="$tmp_root/$kb_tools_archive_name" + if [ ! -f $kb_tools_archive_path ]; then + curl -sL ${kb_tools_download_url} -o "$kb_tools_archive_path" + fi + tar -zvxf "$kb_tools_archive_path" -C "$tmp_root/" +} + +header_text "using tools" +fetch_kb_tools + +header_text "kubebuilder tools (etcd, kubectl, kube-apiserver)used to perform local tests installed under $tmp_root/kubebuilder/bin/" +exit 0