Skip to content

Commit

Permalink
fix: helm#44 - Allow to configure kubectl version to use
Browse files Browse the repository at this point in the history
Fixes helm#44

Signed-off-by: grzesuav <grzesuav@gmail.com>
  • Loading branch information
grzesuav committed Jul 2, 2021
1 parent 9472952 commit 3422508
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -21,6 +21,7 @@ For more information on inputs, see the [API Documentation](https://developer.gi
- `cluster_name`: The name of the cluster to create (default: `chart-testing`)
- `wait`: The duration to wait for the control plane to become ready (default: `60s`)
- `log_level`: The log level for kind
- `kubetl_version`: The kubectl version to use (default: v1.20.8)

### Example Workflow

Expand Down
2 changes: 2 additions & 0 deletions action.yml
Expand Up @@ -17,6 +17,8 @@ inputs:
description: "The duration to wait for the control plane to become ready (default: 60s)"
log_level:
description: "The log level for kind"
kubectl+version:
description: "The kubectl version to use (default: v1.20.8)"
runs:
using: "node12"
main: "main.js"
Expand Down
16 changes: 14 additions & 2 deletions kind.sh
Expand Up @@ -20,7 +20,7 @@ set -o pipefail

DEFAULT_KIND_VERSION=v0.11.1
DEFAULT_CLUSTER_NAME=chart-testing
KUBECTL_VERSION=v1.20.8
DEFAULT_KUBECTL_VERSION=v1.20.8

show_help() {
cat << EOF
Expand All @@ -33,6 +33,7 @@ Usage: $(basename "$0") <options>
-n, --cluster-name The name of the cluster to create (default: chart-testing)"
-w, --wait The duration to wait for the control plane to become ready (default: 60s)"
-l, --log-level The log level for kind [panic, fatal, error, warning, info, debug, trace] (default: warning)
-k, --kubectl-version The kubectl version to use (default: $DEFAULT_KUBECTL_VERSION)"
EOF
}
Expand All @@ -44,6 +45,7 @@ main() {
local cluster_name="$DEFAULT_CLUSTER_NAME"
local wait=60s
local log_level=
local kubectl_version="$DEFAULT_KUBECTL_VERSION"

parse_command_line "$@"

Expand Down Expand Up @@ -145,6 +147,16 @@ parse_command_line() {
exit 1
fi
;;
-k|--kubectl-version)
if [[ -n "${2:-}" ]]; then
kubectl_version="$2"
shift
else
echo "ERROR: '-k|--kubectl-version' cannot be empty." >&2
show_help
exit 1
fi
;;
*)
break
;;
Expand All @@ -168,7 +180,7 @@ install_kubectl() {

mkdir -p "$kubectl_dir"

curl -sSLo "$kubectl_dir/kubectl" "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
curl -sSLo "$kubectl_dir/kubectl" "https://storage.googleapis.com/kubernetes-release/release/$kubectl_version/bin/linux/amd64/kubectl"
chmod +x "$kubectl_dir/kubectl"
}

Expand Down
4 changes: 4 additions & 0 deletions main.sh
Expand Up @@ -47,6 +47,10 @@ main() {
args+=(--log-level "${INPUT_LOG_LEVEL}")
fi

if [[ -n "${INPUT_KUBECTL_VERSION:-}" ]]; then
args+=(--kubectl-version "${INPUT_KUBECTL_VERSION}")
fi

"$SCRIPT_DIR/kind.sh" "${args[@]}"
}

Expand Down

0 comments on commit 3422508

Please sign in to comment.