From 614f6b868396db56683e1e809c54b11f15fb2619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=8C=AF=E5=AE=87?= <> Date: Tue, 14 Jan 2025 17:25:18 +0800 Subject: [PATCH] feat(k8s): add reset-auth sub-command to freeleaps-cluster-authenticator for resetting kubectl authentication state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙振宇 <> --- bin/freeleaps-cluster-authenticator | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bin/freeleaps-cluster-authenticator b/bin/freeleaps-cluster-authenticator index 92b2d873..1476238d 100755 --- a/bin/freeleaps-cluster-authenticator +++ b/bin/freeleaps-cluster-authenticator @@ -24,6 +24,7 @@ help() { echo "" echo "Sub Commands:" echo " auth,-a,--auth Setup kubectl for freeleaps cluster with Mathmast account." + echo " reset-auth,-r,--reset-auth Reset kubectl authentication state for freeleaps cluster." echo " clear,-c,--clear Clear authentication for freeleaps cluster." echo " doctor,-d,--doctor Check if all the required tools are installed." echo " help,-h,--help Show this help message." @@ -267,6 +268,12 @@ clear_auth() { echo "[CLEAR] kubectl authentication cleared successfully." } +reset_auth() { + echo "[RESET] Reset kubectl authentication state..." + rm -rf "${HOME}/.kube/oidc-login" + echo "[RESET] kubectl authentication state reset successfully." +} + main() { if [ $# -lt 1 ]; then echo "[ERROR] No sub-command provided." @@ -281,6 +288,9 @@ main() { auth|-a|--auth) auth ;; + reset-auth|-r|--reset-auth) + reset_auth + ;; clear|-c|--clear) clear_auth ;;