Skip to content

Commit

Permalink
allow to omit cluster creation (#50)
Browse files Browse the repository at this point in the history
Signed-off-by: Cezary Tarnowski <cezary.tarnowski@tomtom.com>
  • Loading branch information
CezaryTarnowski-TomTom committed Apr 21, 2022
1 parent 4c79091 commit deab45f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/test.yaml
Expand Up @@ -38,6 +38,21 @@ jobs:
kubectl cluster-info
kubectl get storageclass standard
test-with-install-only:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Only install kind without starting a cluster
uses: ./
with:
install_only: true

- name: Test kind works and there is no cluster started
run: |
[[ $(kind get clusters | wc -l) -eq 0 ]]
test-with-custom-k8s-version:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -22,6 +22,7 @@ For more information on inputs, see the [API Documentation](https://developer.gi
- `wait`: The duration to wait for the control plane to become ready (default: `60s`)
- `log_level`: The log level for kind
- `kubectl_version`: The kubectl version to use (default: v1.21.10)
- `install_only`: Skips cluster creation, only install kind (default: false)

### Example Workflow

Expand Down
2 changes: 2 additions & 0 deletions action.yml
Expand Up @@ -30,6 +30,8 @@ inputs:
description: "The kubectl version to use (default: v1.21.10)"
required: false
default: "v1.21.10"
install_only:
description: "Skips cluster creation, only install kind (default: false)"
runs:
using: "node12"
main: "main.js"
Expand Down
26 changes: 19 additions & 7 deletions kind.sh
Expand Up @@ -27,13 +27,14 @@ cat << EOF
Usage: $(basename "$0") <options>
-h, --help Display help
-v, --version The kind version to use (default: $DEFAULT_KIND_VERSION)"
-c, --config The path to the kind config file"
-i, --node-image The Docker image for the cluster nodes"
-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)"
-v, --version The kind version to use (default: $DEFAULT_KIND_VERSION)
-c, --config The path to the kind config file
-i, --node-image The Docker image for the cluster nodes
-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)"
-k, --kubectl-version The kubectl version to use (default: $DEFAULT_KUBECTL_VERSION)
-o, --install-only Skips cluster creation, only install kind (default: false)
EOF
}
Expand All @@ -46,6 +47,7 @@ main() {
local wait=60s
local log_level=
local kubectl_version="$DEFAULT_KUBECTL_VERSION"
local install_only=false

parse_command_line "$@"

Expand Down Expand Up @@ -77,7 +79,9 @@ main() {
"$kind_dir/kind" version
"$kubectl_dir/kubectl" version --client=true

create_kind_cluster
if [[ "$install_only" == false ]]; then
create_kind_cluster
fi
}

parse_command_line() {
Expand Down Expand Up @@ -157,6 +161,14 @@ parse_command_line() {
exit 1
fi
;;
-o|--install-only)
if [[ -n "${2:-}" ]]; then
install_only="$2"
shift
else
install_only=true
fi
;;
*)
break
;;
Expand Down
5 changes: 4 additions & 1 deletion main.sh
Expand Up @@ -51,8 +51,11 @@ main() {
args+=(--kubectl-version "${INPUT_KUBECTL_VERSION}")
fi

if [[ -n "${INPUT_INSTALL_ONLY:-}" ]]; then
args+=(--install-only)
fi

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

main

0 comments on commit deab45f

Please sign in to comment.