11#! /usr/bin/env bash
2- echo " Installing dependencies..."
32source $( git rev-parse --show-toplevel) /ci3/source
4- echo " Source loaded"
3+
4+ log () { echo " [INFO] $( date -Is) - $* " ; }
5+ err () { echo " [ERROR] $( date -Is) - $* " >&2 ; }
6+ die () { err " $* " ; exit 1; }
7+ require_cmd () { command -v " $1 " > /dev/null 2>&1 || die " Required command not found: $1 " ; }
8+
9+ log " Installing dependencies..."
510
611# if kubectl is not installed, install it
712if ! command -v kubectl & > /dev/null; then
8- echo " Installing kubectl..."
9- curl -LO " https://dl.k8s.io/release/$( curl -L -s https://dl.k8s.io/release/stable.txt) /bin/$( os) /$( arch) /kubectl"
13+ log " Installing kubectl..."
14+ curl -sLO " https://dl.k8s.io/release/$( curl -L -s https://dl.k8s.io/release/stable.txt) /bin/$( os) /$( arch) /kubectl"
1015 chmod +x kubectl
1116 sudo mv kubectl /usr/local/bin/kubectl
1217fi
1318
1419# Install kind if it is not installed
1520if ! command -v kind & > /dev/null; then
16- echo " Installing kind..."
17- curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.23.0/kind-$( os) -$( arch)
21+ log " Installing kind..."
22+ curl -sLo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.23.0/kind-$( os) -$( arch)
1823 chmod +x ./kind
1924 sudo mv ./kind /usr/local/bin/kind
2025fi
@@ -28,7 +33,7 @@ function get_helm_from_cache {
2833 elif [ -f ./usr/local/bin/helm ]; then
2934 sudo mv ./usr/local/bin/helm /usr/local/bin/helm
3035 else
31- echo " Could not extract helm from cache"
36+ err " Could not extract helm from cache"
3237 return 1
3338 fi
3439 sudo chmod +x /usr/local/bin/helm
@@ -38,16 +43,16 @@ function get_helm_from_cache {
3843
3944# Install helm if it is not installed
4045if ! command -v helm & > /dev/null; then
41- echo " Installing helm..."
46+ log " Installing helm..."
4247
4348 # Determine the helm artifact name based on OS and architecture
4449 helm_artifact=" helm-$( os) -$( arch) .tar.gz"
4550 helm_release_url=" https://github.com/helm/helm/releases/tag/v3.19.0"
4651
4752 if get_helm_from_cache " $helm_artifact " > /dev/null; then
48- echo " Using cached Helm binary"
53+ log " Using cached Helm binary"
4954 else
50- echo " Downloading Helm from get.helm.sh..."
55+ log " Downloading Helm from get.helm.sh..."
5156 # Download and run the official Helm installer script
5257 curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
5358 chmod +x get_helm.sh
@@ -63,9 +68,9 @@ if ! command -v helm &> /dev/null; then
6368fi
6469
6570if ! command -v stern & > /dev/null; then
66- echo " Installing stern..."
71+ log " Installing stern..."
6772 # Download Stern
68- curl -Lo stern.tar.gz https://github.com/stern/stern/releases/download/v1.31.0/stern_1.31.0_$( os) _$( arch) .tar.gz
73+ curl -sLo stern.tar.gz https://github.com/stern/stern/releases/download/v1.31.0/stern_1.31.0_$( os) _$( arch) .tar.gz
6974
7075 # Extract the binary
7176 tar -xzf stern.tar.gz
@@ -82,8 +87,8 @@ if ! command -v stern &> /dev/null; then
8287fi
8388
8489if ! command -v gcloud & > /dev/null; then
85- echo " Installing gcloud..."
86- curl -Lo google-cloud-cli.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-$os -$( arch) .tar.gz
90+ log " Installing gcloud..."
91+ curl -sLo google-cloud-cli.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-$os -$( arch) .tar.gz
8792 tar -xzf google-cloud-cli.tar.gz
8893 rm google-cloud-cli.tar.gz
8994
@@ -105,20 +110,17 @@ if command -v gcloud &> /dev/null; then
105110 if dpkg -l google-cloud-cli-gke-gcloud-auth-plugin 2> /dev/null | grep -q " ^ii" ; then
106111 : # do nothing
107112 else
108- echo " Installing GKE auth plugin for kubectl via apt..."
113+ log " Installing GKE auth plugin for kubectl via apt..."
109114 sudo apt-get update
110115 sudo apt-get install -y google-cloud-cli-gke-gcloud-auth-plugin
111116 fi
112117 else
113- echo " Installing GKE auth plugin for kubectl via gcloud components..."
118+ log " Installing GKE auth plugin for kubectl via gcloud components..."
114119 gcloud components install gke-gcloud-auth-plugin
115120 fi
116121fi
117122
118123
119- # Sanity check commands
120- require_cmd () { command -v " $1 " > /dev/null 2>&1 || die " Required command not found: $1 " ; }
121-
122124require_cmd git
123125require_cmd kubectl
124126require_cmd terraform
0 commit comments