...
1#!/usr/bin/env bash
2
3# Copyright 2019 The Kubernetes Authors.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17set -e
18
19hack_dir=$(dirname ${BASH_SOURCE})
20source ${hack_dir}/common.sh
21
22k8s_version=1.13.1
23goarch=amd64
24goos="unknown"
25
26if [[ "$OSTYPE" == "linux-gnu" ]]; then
27 goos="linux"
28elif [[ "$OSTYPE" == "darwin"* ]]; then
29 goos="darwin"
30fi
31
32if [[ "$goos" == "unknown" ]]; then
33 echo "OS '$OSTYPE' not supported. Aborting." >&2
34 exit 1
35fi
36
37tmp_root=/tmp
38kb_root_dir=$tmp_root/kubebuilder
39
40# Skip fetching and untaring the tools by setting the SKIP_FETCH_TOOLS variable
41# in your environment to any value:
42#
43# $ SKIP_FETCH_TOOLS=1 ./test.sh
44#
45# If you skip fetching tools, this script will use the tools already on your
46# machine, but rebuild the kubebuilder and kubebuilder-bin binaries.
47SKIP_FETCH_TOOLS=${SKIP_FETCH_TOOLS:-""}
48
49# fetch k8s API gen tools and make it available under kb_root_dir/bin.
50function fetch_kb_tools {
51 if [ -n "$SKIP_FETCH_TOOLS" ]; then
52 return 0
53 fi
54
55 header_text "fetching tools"
56 kb_tools_archive_name="kubebuilder-tools-$k8s_version-$goos-$goarch.tar.gz"
57 kb_tools_download_url="https://storage.googleapis.com/kubebuilder-tools/$kb_tools_archive_name"
58
59 kb_tools_archive_path="$tmp_root/$kb_tools_archive_name"
60 if [ ! -f $kb_tools_archive_path ]; then
61 curl -sL ${kb_tools_download_url} -o "$kb_tools_archive_path"
62 fi
63 tar -zvxf "$kb_tools_archive_path" -C "$tmp_root/"
64}
65
66# Install metalinter
67function install_metalinter {
68 which gometalinter.v2 || go install gopkg.in/alecthomas/gometalinter.v2
69}
70
71
72# # Install wire
73# function install_wire {
74# which wire|| go install github.com/google/wire/cmd/wire
75# }
76
77# header_text "using tools"
78
79# install_wire
80
81fetch_kb_tools
82setup_envs
83
84# ${hack_dir}/verify.sh
85# ${hack_dir}/test-all.sh
86
87echo "passed"
88exit 0
View as plain text