Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
tthvo committed Oct 3, 2024
2 parents b6ffb88 + 5d66646 commit dee14ca
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
36 changes: 27 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Create kind cluster
uses: ./
Expand All @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Create kind cluster with custom wait
uses: ./
Expand All @@ -43,7 +43,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Create kind cluster with custom verbosity
uses: ./
Expand All @@ -59,7 +59,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Create kind cluster with custom name
uses: ./
Expand All @@ -75,7 +75,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Only install kind without starting a cluster
uses: ./
Expand All @@ -90,7 +90,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Create kind cluster with custom name
uses: ./
Expand All @@ -103,12 +103,30 @@ jobs:
kubectl cluster-info
kubectl get nodes
test-with-custom-kubectl-version:
test-with-custom-kubeconfig:
runs-on: ubuntu-latest
env:
KUBECONFIG: "./kubeconfig"
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Create kind cluster with custom kubeconfig
uses: ./
with:
kubeconfig: "${{ env.KUBECONFIG }}"
cluster_name: "kube-config-test"

- name: Test
run: |
grep "kube-config-test" ${KUBECONFIG}
test-with-custom-kubectl-version:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Create kind cluster with custom name
uses: ./
with:
Expand All @@ -123,7 +141,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Create kind cluster with custom name
uses: ./
Expand All @@ -139,7 +157,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Create kind cluster with custom name
uses: ./
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ inputs:
config:
description: "The path to the kind config file"
required: false
kubeconfig:
description: "The path to the kubeconfig config file"
required: false
node_image:
description: "The Docker image for the cluster nodes"
required: false
Expand Down
16 changes: 16 additions & 0 deletions kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Usage: $(basename "$0") <options>
--help Display help
-v, --version The kind version to use (default: $DEFAULT_KIND_VERSION)
-c, --config The path to the kind config file
-K, --kubeconfig The path to the kubeconfig 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)
Expand All @@ -44,6 +45,7 @@ EOF
main() {
local version="${DEFAULT_KIND_VERSION}"
local config=
local kubeconfig=
local node_image=
local cluster_name="${DEFAULT_CLUSTER_NAME}"
local wait=60s
Expand Down Expand Up @@ -121,6 +123,16 @@ parse_command_line() {
exit 1
fi
;;
-K|--kubeconfig)
if [[ -n "${2:-}" ]]; then
kubeconfig="$2"
shift
else
echo "ERROR: '--kubeconfig' cannot be empty." >&2
show_help
exit 1
fi
;;
-i|--node-image)
if [[ -n "${2:-}" ]]; then
node_image="$2"
Expand Down Expand Up @@ -246,6 +258,10 @@ create_kind_cluster() {
args+=("--config=${config}")
fi

if [[ -n "${kubeconfig}" ]]; then
args+=("--kubeconfig=${kubeconfig}")
fi

if [[ -n "${verbosity}" ]]; then
args+=("--verbosity=${verbosity}")
fi
Expand Down
4 changes: 4 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ main() {
args+=(--config "${INPUT_CONFIG}")
fi

if [[ -n "${INPUT_KUBECONFIG:-}" ]]; then
args+=(--kubeconfig "${INPUT_KUBECONFIG}")
fi

if [[ -n "${INPUT_NODE_IMAGE:-}" ]]; then
args+=(--node-image "${INPUT_NODE_IMAGE}")
fi
Expand Down

0 comments on commit dee14ca

Please sign in to comment.