Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #44 - Allow to configure kubectl version to use #45

Merged
merged 1 commit into from Jul 24, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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