Skip to content

Commit d49c192

Browse files
committed
hack/setup-envtest.sh: add header_text function
1 parent e831354 commit d49c192

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

hack/check-everything.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
set -e
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
1820

1921
hack_dir=$(dirname ${BASH_SOURCE})
2022
source ${hack_dir}/common.sh
@@ -35,12 +37,10 @@ SKIP_FETCH_TOOLS=${SKIP_FETCH_TOOLS:-""}
3537
ENVTEST_K8S_VERSION=${ENVTEST_K8S_VERSION:-"1.16.4"}
3638

3739
if [ -z "$SKIP_FETCH_TOOLS" ]; then
38-
header_text "fetching envtest tools@${ENVTEST_K8S_VERSION}"
3940
fetch_envtest_tools "$kb_root_dir"
4041
fetch_envtest_tools "${hack_dir}/../pkg/internal/testing/integration/assets"
4142
fi
4243

43-
header_text "setting up envtest@${ENVTEST_K8S_VERSION}"
4444
setup_envtest_env "$kb_root_dir"
4545

4646
${hack_dir}/verify.sh

hack/setup-envtest.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,28 @@
1515
# limitations under the License.
1616

1717
set -o errexit
18-
set -o nounset
1918
set -o pipefail
2019

20+
# Turn colors in this script off by setting the NO_COLOR variable in your
21+
# environment to any value:
22+
#
23+
# $ NO_COLOR=1 test.sh
24+
NO_COLOR=${NO_COLOR:-""}
25+
if [ -z "$NO_COLOR" ]; then
26+
header=$'\e[1;33m'
27+
reset=$'\e[0m'
28+
else
29+
header=''
30+
reset=''
31+
fi
32+
33+
function header_text {
34+
echo "$header$*$reset"
35+
}
36+
2137
function setup_envtest_env {
38+
header_text "setting up env vars"
39+
2240
# Setup env vars
2341
KUBEBUILDER_ASSETS=${KUBEBUILDER_ASSETS:-""}
2442
if [[ -z "${KUBEBUILDER_ASSETS}" ]]; then
@@ -59,10 +77,12 @@ function fetch_envtest_tools {
5977
if [[ -x "${dest_dir}/bin/kube-apiserver" ]]; then
6078
version=$("${dest_dir}"/bin/kube-apiserver --version)
6179
if [[ $version == *"${k8s_version}"* ]]; then
80+
header_text "Using cached envtest tools from ${dest_dir}"
6281
return 0
6382
fi
6483
fi
6584

85+
header_text "fetching envtest tools@${k8s_version} (into '${dest_dir}')"
6686
envtest_tools_archive_name="kubebuilder-tools-$k8s_version-$goos-$goarch.tar.gz"
6787
envtest_tools_download_url="https://storage.googleapis.com/kubebuilder-tools/$envtest_tools_archive_name"
6888

0 commit comments

Comments
 (0)