@@ -40,18 +40,35 @@ if [[ "$goos" == "unknown" ]]; then
40
40
exit 1
41
41
fi
42
42
43
+ # Turn colors in this script off by setting the NO_COLOR variable in your
44
+ # environment to any value:
45
+ #
46
+ # $ NO_COLOR=1 test.sh
47
+ NO_COLOR=${NO_COLOR: " " }
48
+ header=$' \e [1;33m'
49
+ reset=$' \e [0m'
50
+ function header_text {
51
+ if [ -z " $NO_COLOR " ]; then
52
+ echo " $header ${@ } $reset "
53
+ else
54
+ echo ${@ }
55
+ fi
56
+ }
57
+
43
58
rc=0
44
59
tmp_root=/tmp
45
60
46
61
kb_root_dir=$tmp_root /kubebuilder
47
62
kb_vendor_dir=$tmp_root /vendor
48
63
49
64
function prepare_staging_dir {
65
+ header_text " preparing staging dir"
50
66
rm -rf $kb_root_dir
51
67
}
52
68
53
69
# fetch k8s API gen tools and make it available under kb_root_dir/bin.
54
70
function fetch_tools {
71
+ header_text " fetching tools"
55
72
kb_tools_archive_name=kubebuilder-tools-$k8s_version -$goos -$goarch .tar.gz
56
73
kb_tools_download_url=" https://storage.googleapis.com/kubebuilder-tools/$kb_tools_archive_name "
57
74
@@ -63,11 +80,13 @@ function fetch_tools {
63
80
}
64
81
65
82
function build_kb {
83
+ header_text " building kubebuilder"
66
84
go build -o $tmp_root /kubebuilder/bin/kubebuilder ./cmd/kubebuilder
67
85
go build -o $tmp_root /kubebuilder/bin/kubebuilder-gen ./cmd/kubebuilder-gen
68
86
}
69
87
70
88
function prepare_vendor_deps {
89
+ header_text " preparing vendor dependencies"
71
90
# TODO(droot): clean up this function
72
91
rm -rf $kb_vendor_dir && rm -f $tmp_root /Gopkg.toml && rm -f $tmp_root /Gopkg.lock
73
92
mkdir -p $kb_vendor_dir /github.com/kubernetes-sigs/kubebuilder/pkg/ || echo " "
@@ -82,11 +101,15 @@ function prepare_vendor_deps {
82
101
83
102
function prepare_testdir_under_gopath {
84
103
kb_test_dir=$GOPATH /src/github.com/kubernetes-sigs/kubebuilder-test
104
+ header_text " preparing test directory $kb_test_dir "
85
105
rm -rf $kb_test_dir && mkdir -p $kb_test_dir && cd $kb_test_dir
106
+ header_text " running kubebuilder commands in test directory $kb_test_dir "
86
107
}
87
108
88
109
function generate_crd_resources {
89
- # Setup env vars
110
+ header_text " generating CRD resources and code"
111
+
112
+ # Setup env vars
90
113
export PATH=/tmp/kubebuilder/bin/:$PATH
91
114
export TEST_ASSET_KUBECTL=/tmp/kubebuilder/bin/kubectl
92
115
export TEST_ASSET_KUBE_APISERVER=/tmp/kubebuilder/bin/kube-apiserver
@@ -99,9 +122,12 @@ function generate_crd_resources {
99
122
}
100
123
101
124
function test_generated_controller {
102
- # Verify the controller-manager builds and the tests pass
125
+ header_text " building generated code"
126
+ # Verify the controller-manager builds and the tests pass
103
127
go build ./cmd/...
104
128
go build ./pkg/...
129
+
130
+ header_text " testing generated code"
105
131
go test -v ./cmd/...
106
132
go test -v ./pkg/...
107
133
}
0 commit comments