sigs.k8s.io/cluster-api-provider-aws@v1.5.5/hack/ensure-kind.sh (about) 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 17 set -o errexit 18 set -o nounset 19 set -o pipefail 20 21 GOPATH_BIN="$(go env GOPATH)/bin/" 22 MINIMUM_KIND_VERSION=v0.14.0 23 GOARCH="$(go env GOARCH)" 24 GOOS="$(go env GOOS)" 25 26 # Ensure the kind tool exists and is a viable version, or installs it 27 verify_kind_version() { 28 29 # If kind is not available on the path, get it 30 if ! [ -x "$(command -v kind)" ]; then 31 if [ "$GOOS" == "linux" ] || [ "$GOOS" == "darwin" ]; then 32 echo 'kind not found, installing' 33 if ! [ -d "${GOPATH_BIN}" ]; then 34 mkdir -p "${GOPATH_BIN}" 35 fi 36 curl -sLo "${GOPATH_BIN}/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${MINIMUM_KIND_VERSION}/kind-${GOOS}-${GOARCH}" 37 chmod +x "${GOPATH_BIN}/kind" 38 else 39 echo "Missing required binary in path: kind" 40 return 2 41 fi 42 fi 43 44 local kind_version 45 kind_version="v$(kind version -q)" 46 if [[ "${MINIMUM_KIND_VERSION}" != $(echo -e "${MINIMUM_KIND_VERSION}\n${kind_version}" | sort -s -t. -k 1,1n -k 2,2n -k 3,3n | head -n1) ]]; then 47 cat <<EOF 48 Detected kind version: ${kind_version}. 49 Requires ${MINIMUM_KIND_VERSION} or greater. 50 Please install ${MINIMUM_KIND_VERSION} or later. 51 EOF 52 return 2 53 fi 54 } 55 56 verify_kind_version