14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
17
- set -e
17
+ set -o errexit
18
+ set -o pipefail
19
+
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
+ }
18
36
19
37
function setup_envtest_env {
38
+ header_text " setting up env vars"
39
+
20
40
# Setup env vars
41
+ KUBEBUILDER_ASSETS=${KUBEBUILDER_ASSETS:- " " }
21
42
if [[ -z " ${KUBEBUILDER_ASSETS} " ]]; then
22
43
export KUBEBUILDER_ASSETS=$1 /bin
23
44
fi
24
45
}
25
46
26
47
# fetch k8s API gen tools and make it available under envtest_root_dir/bin.
48
+ #
49
+ # Skip fetching and untaring the tools by setting the SKIP_FETCH_TOOLS variable
50
+ # in your environment to any value:
51
+ #
52
+ # $ SKIP_FETCH_TOOLS=1 ./check-everything.sh
53
+ #
54
+ # If you skip fetching tools, this script will use the tools already on your
55
+ # machine.
27
56
function fetch_envtest_tools {
57
+ SKIP_FETCH_TOOLS=${SKIP_FETCH_TOOLS:- " " }
58
+ if [ -n " $SKIP_FETCH_TOOLS " ]; then
59
+ return 0
60
+ fi
61
+
28
62
tmp_root=/tmp
29
63
envtest_root_dir=$tmp_root /envtest
30
64
31
- k8s_version=1.16.4
32
- goarch=amd64
33
- goos=" unknown"
34
-
35
- if [[ " $OSTYPE " == " linux-gnu" ]]; then
36
- goos=" linux"
37
- elif [[ " $OSTYPE " == " darwin" * ]]; then
38
- goos=" darwin"
39
- fi
65
+ k8s_version=" ${ENVTEST_K8S_VERSION:- 1.16.4} "
66
+ goarch=" $( go env GOARCH) "
67
+ goos=" $( go env GOOS) "
40
68
41
- if [[ " $goos " = = " unknown " ]]; then
42
- echo " OS '$OSTYPE ' not supported. Aborting." >&2
69
+ if [[ " $goos " != " linux " && " $goos " ! = " darwin " ]]; then
70
+ echo " OS '$goos ' not supported. Aborting." >&2
43
71
return 1
44
72
fi
45
73
@@ -49,10 +77,12 @@ function fetch_envtest_tools {
49
77
if [[ -x " ${dest_dir} /bin/kube-apiserver" ]]; then
50
78
version=$( " ${dest_dir} " /bin/kube-apiserver --version)
51
79
if [[ $version == * " ${k8s_version} " * ]]; then
80
+ header_text " Using cached envtest tools from ${dest_dir} "
52
81
return 0
53
82
fi
54
83
fi
55
84
85
+ header_text " fetching envtest tools@${k8s_version} (into '${dest_dir} ')"
56
86
envtest_tools_archive_name=" kubebuilder-tools-$k8s_version -$goos -$goarch .tar.gz"
57
87
envtest_tools_download_url=" https://storage.googleapis.com/kubebuilder-tools/$envtest_tools_archive_name "
58
88
0 commit comments