Skip to content

Commit e0a5d04

Browse files
authored
Merge pull request #115 from pmorie/skip_fetch_tools
Make it possible to skip fetch and untar of tools in test script
2 parents 838b1d1 + 7477d7e commit e0a5d04

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

test.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,33 @@ tmp_root=/tmp
6161
kb_root_dir=$tmp_root/kubebuilder
6262
kb_vendor_dir=$tmp_root/vendor
6363

64+
# Skip fetching and untaring the tools by setting the SKIP_FETCH_TOOLS variable
65+
# in your environment to any value:
66+
#
67+
# $ SKIP_FETCH_TOOLS=1 ./test.sh
68+
#
69+
# If you skip fetching tools, this script will use the tools already on your
70+
# machine, but rebuild the kubebuilder and kubebuilder-bin binaries.
71+
SKIP_FETCH_TOOLS=${SKIP_FETCH_TOOLS:""}
72+
6473
function prepare_staging_dir {
6574
header_text "preparing staging dir"
66-
rm -rf $kb_root_dir
75+
76+
if [ -z "$SKIP_FETCH_TOOLS" ]; then
77+
rm -rf $kb_root_dir
78+
else
79+
rm -f $kb_root_dir/kubebuilder/bin/kubebuilder
80+
rm -f $kb_root_dir/kubebuilder/bin/kubebuilder-gen
81+
rm -f $kb_root_dir/kubebuilder/bin/vendor.tar.gz
82+
fi
6783
}
6884

6985
# fetch k8s API gen tools and make it available under kb_root_dir/bin.
7086
function fetch_tools {
87+
if [ -n "$SKIP_FETCH_TOOLS" ]; then
88+
return 0
89+
fi
90+
7191
header_text "fetching tools"
7292
kb_tools_archive_name=kubebuilder-tools-$k8s_version-$goos-$goarch.tar.gz
7393
kb_tools_download_url="https://storage.googleapis.com/kubebuilder-tools/$kb_tools_archive_name"
@@ -76,7 +96,7 @@ function fetch_tools {
7696
if [ ! -f $kb_tools_archive_path ]; then
7797
curl -sL ${kb_tools_download_url} -o $kb_tools_archive_path
7898
fi
79-
tar -zxf $kb_tools_archive_path -C $tmp_root/
99+
tar -zvxf $kb_tools_archive_path -C $tmp_root/
80100
}
81101

82102
function build_kb {

0 commit comments

Comments
 (0)