Skip to content

Commit

Permalink
resolve --log-level deprecation and replace to --verbosity (#64)
Browse files Browse the repository at this point in the history
* resolve --log-level deprecation and use --verbosity

Signed-off-by: cpanato <[email protected]>

* upgrade kind to v0.14.0

Signed-off-by: cpanato <[email protected]>

* update action checkout

Signed-off-by: cpanato <[email protected]>

* update readme

Signed-off-by: cpanato <[email protected]>

* add extra test

Signed-off-by: cpanato <[email protected]>

* update to use node16

Signed-off-by: cpanato <[email protected]>
  • Loading branch information
cpanato authored Jun 14, 2022
1 parent deab45f commit d08cf6f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 26 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ jobs:
kubectl cluster-info
kubectl get storageclass standard
test-with-custom-verbosity:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Create kind cluster with custom verbosity
uses: ./
with:
verbosity: 10

- name: Test
run: |
kubectl cluster-info
kubectl get storageclass standard
test-with-custom-name:
runs-on: ubuntu-latest
steps:
Expand All @@ -42,7 +58,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Only install kind without starting a cluster
uses: ./
Expand All @@ -53,7 +69,7 @@ jobs:
run: |
[[ $(kind get clusters | wc -l) -eq 0 ]]
test-with-custom-k8s-version:
test-with-custom-kubectl-version:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -68,3 +84,19 @@ jobs:
run: |
kubectl cluster-info
kubectl get nodes
test-with-custom-node-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Create kind cluster with custom name
uses: ./
with:
node_image: "kindest/node:v1.24.0"

- name: Test
run: |
kubectl cluster-info
kubectl get nodes
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ For more information, reference the GitHub Help Documentation for [Creating a wo

For more information on inputs, see the [API Documentation](https://developer.github.com/v3/repos/releases/#input)

- `version`: The kind version to use (default: `v0.12.0`)
- `version`: The kind version to use (default: `v0.14.0`)
- `config`: The path to the kind config file
- `node_image`: The Docker image for the cluster nodes
- `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
- `kubectl_version`: The kubectl version to use (default: v1.21.10)
- `verbosity`: info log verbosity, higher value produces more output
- `kubectl_version`: The kubectl version to use (default: v1.22.10)
- `install_only`: Skips cluster creation, only install kind (default: false)

### Example Workflow
Expand All @@ -38,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.2.0
uses: helm/kind-action@v1.3.0
```
This uses [@helm/kind-action](https://www.github.com/helm/kind-action) GitHub Action to spin up a [kind](https://kind.sigs.k8s.io/) Kubernetes cluster on every Pull Request.
Expand Down
16 changes: 9 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ branding:
icon: box
inputs:
version:
description: "The kind version to use (default: v0.12.0)"
description: "The kind version to use (default: v0.14.0)"
required: false
default: "v0.12.0"
default: "v0.14.0"
config:
description: "The path to the kind config file"
required: false
Expand All @@ -23,16 +23,18 @@ inputs:
description: "The duration to wait for the control plane to become ready (default: 60s)"
required: false
default: "60s"
log_level:
description: "The log level for kind"
verbosity:
description: "The verbosity level for kind (default: 0)"
default: "0"
required: false
kubectl_version:
description: "The kubectl version to use (default: v1.21.10)"
description: "The kubectl version to use (default: v1.22.10)"
required: false
default: "v1.21.10"
default: "v1.22.10"
install_only:
description: "Skips cluster creation, only install kind (default: false)"
required: false
runs:
using: "node12"
using: "node16"
main: "main.js"
post: "cleanup.js"
22 changes: 11 additions & 11 deletions kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ set -o errexit
set -o nounset
set -o pipefail

DEFAULT_KIND_VERSION=v0.12.0
DEFAULT_KIND_VERSION=v0.14.0
DEFAULT_CLUSTER_NAME=chart-testing
DEFAULT_KUBECTL_VERSION=v1.21.10
DEFAULT_KUBECTL_VERSION=v1.22.10

show_help() {
cat << EOF
Usage: $(basename "$0") <options>
-h, --help Display help
--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)
-l, --log-level The log level for kind [panic, fatal, error, warning, info, debug, trace] (default: warning)
-l, --verbosity info log verbosity, higher value produces more output
-k, --kubectl-version The kubectl version to use (default: $DEFAULT_KUBECTL_VERSION)
-o, --install-only Skips cluster creation, only install kind (default: false)
Expand All @@ -45,7 +45,7 @@ main() {
local node_image=
local cluster_name="$DEFAULT_CLUSTER_NAME"
local wait=60s
local log_level=
local verbosity=
local kubectl_version="$DEFAULT_KUBECTL_VERSION"
local install_only=false

Expand Down Expand Up @@ -91,7 +91,7 @@ parse_command_line() {
show_help
exit
;;
-v|--version)
--version)
if [[ -n "${2:-}" ]]; then
version="$2"
shift
Expand Down Expand Up @@ -141,12 +141,12 @@ parse_command_line() {
exit 1
fi
;;
-l|--log-level)
-v|--verbosity)
if [[ -n "${2:-}" ]]; then
log_level="$2"
verbosity="$2"
shift
else
echo "ERROR: '--log-level' cannot be empty." >&2
echo "ERROR: '--verbosity' cannot be empty." >&2
show_help
exit 1
fi
Expand Down Expand Up @@ -208,8 +208,8 @@ create_kind_cluster() {
args+=("--config=$config")
fi

if [[ -n "$log_level" ]]; then
args+=("--loglevel=$log_level")
if [[ -n "$verbosity" ]]; then
args+=("--verbosity=$verbosity")
fi

"$kind_dir/kind" "${args[@]}"
Expand Down
4 changes: 2 additions & 2 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ main() {
args+=(--wait "${INPUT_WAIT}")
fi

if [[ -n "${INPUT_LOG_LEVEL:-}" ]]; then
args+=(--log-level "${INPUT_LOG_LEVEL}")
if [[ -n "${INPUT_VERBOSITY:-}" ]]; then
args+=(--verbosity "${INPUT_VERBOSITY}")
fi

if [[ -n "${INPUT_KUBECTL_VERSION:-}" ]]; then
Expand Down

0 comments on commit d08cf6f

Please sign in to comment.