Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions scripts/build-controller-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ if ! k8s_controller_gen_version_equals "$CONTROLLER_TOOLS_VERSION"; then
exit 1
fi

if ! helm_version_equals_or_greater "$HELM_VERSION"; then
echo "FATAL: Existing version of helm "`helm version --template='Version: {{.Version}}'`", required version is $HELM_VERSION."
echo "FATAL: Please update helm, or uninstall helm and install the required version with scripts/install-helm.sh."
exit 1
fi

ACK_GENERATE_CACHE_DIR=${ACK_GENERATE_CACHE_DIR:-"$HOME/.cache/aws-controllers-k8s"}
# The ack-generate code generator is in a separate source code repository,
# typically at $GOPATH/src/github.com/aws-controllers-k8s/code-generator
Expand Down
21 changes: 21 additions & 0 deletions scripts/install-helm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# ./scripts/install-helm.sh
#
# Installs the latest version helm if not installed.
#
# NOTE: helm will be installed to /usr/local/bin/helm

set -eo pipefail

SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR="$SCRIPTS_DIR/.."

source "$SCRIPTS_DIR/lib/common.sh"

if ! is_installed helm ; then
__helm_url="https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3"
echo -n "installing helm from $__helm_url ... "
curl --silent "$__helm_url" | bash 1>/dev/null
echo "ok."
fi
25 changes: 21 additions & 4 deletions scripts/lib/common.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

CONTROLLER_TOOLS_VERSION="v0.7.0"
HELM_VERSION="v3.7"

# setting the -x option if debugging is true
if [[ "${DEBUG:-"false"}" = "true" ]]; then
Expand Down Expand Up @@ -91,25 +92,41 @@ debug_msg() {
echo "$__debug_prefix$__indent$__msg"
}

# controller_gen_version_equals accepts a string version and returns 0 if the
# k8s_controller_gen_version_equals accepts a string version and returns 0 if the
# installed version of controller-gen matches the supplied version, otherwise
# returns 1
#
# Usage:
#
# if controller_gen_version_equals "v0.4.0"; then
# if k8s_controller_gen_version_equals "v0.4.0"; then
# echo "controller-gen is at version 0.4.0"
# fi
k8s_controller_gen_version_equals() {
currentver="$(controller-gen --version | cut -d' ' -f2 | tr -d '\n')";
requiredver="$1";
local currentver="$(controller-gen --version | cut -d' ' -f2 | tr -d '\n')";
local requiredver="$1";
if [ "$currentver" = "$requiredver" ]; then
return 0
else
return 1
fi;
}

# helm_version_equals_or_greater accepts a string version and returns 0 if the
# installed version of helm matches or greater than the supplied version,
# otherwise returns 1
#
# Usage:
#
# if helm_version_equals_or_greater "v3.9.0"; then
# echo "Installed helm version is greater than or equal to version v3.9.0"
# fi
helm_version_equals_or_greater() {
local currentver="$(helm version --template='Version: {{.Version}}'| cut -d' ' -f2 | tr -d '\n')"
local requiredver="$1"
printf '%s\n%s\n' $requiredver $currentver | sort -C -V
return $?
}

# is_public_ecr_logged_in returns 0 if the Docker client is authenticated
# with ECR public and therefore can pull and push to ECR public, otherwise
# returns 1
Expand Down