From 28af49f36b05b4df64eee9de19389cc556254489 Mon Sep 17 00:00:00 2001 From: Martin Montes Date: Mon, 13 May 2024 10:59:14 +0200 Subject: [PATCH] Avoid downloading k9s plugins multiple times --- k9s.sh | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/k9s.sh b/k9s.sh index ea4b939..73e78e7 100755 --- a/k9s.sh +++ b/k9s.sh @@ -43,7 +43,7 @@ function cleanup() { fi } -if [ "$1" == "--force" -o "$1" == "-f" -o "$1" == "-y" ]; then +if [ "$1" == "-f" -o "$1" == "-y" ]; then cleanup else read -p "Do you want to cleanup existing config at '$K9S_CONFIG' and contexts at '$K9S_CTX'? (y/n) " -n 1 @@ -65,32 +65,30 @@ mkdir -p "$K9S_CTX" mkdir -p "$K9S_CTX/clusters" git clone -q --no-progress https://github.com/derailed/k9s.git -cp k9s/skins/* "$K9S_CONFIG/skins" -rm -rf k9s - git clone -q --no-progress https://github.com/mmontes11/k8s-tooling.git + +cp k9s/skins/* "$K9S_CONFIG/skins" cp k8s-tooling/.k9s/config.yaml "$K9S_CONFIG/config.yaml" cp -r k8s-tooling/.k9s/skins/* "$K9S_CONFIG/skins" cp -r k8s-tooling/.k9s/clusters/* "$K9S_CTX/clusters" -rm -rf k8s-tooling K9S_PLUGINS=( # oficial - "https://raw.githubusercontent.com/derailed/k9s/master/plugins/debug-container.yaml" - "https://raw.githubusercontent.com/derailed/k9s/master/plugins/watch-events.yaml" + "k9s/plugins/debug-container.yaml" + "k9s/plugins/watch-events.yaml" # custom - "https://raw.githubusercontent.com/mmontes11/k8s-scripts/main/.k9s/plugins/flux.yaml" - "https://raw.githubusercontent.com/mmontes11/k8s-scripts/main/.k9s/plugins/cert-manager.yaml" - "https://raw.githubusercontent.com/mmontes11/k8s-scripts/main/.k9s/plugins/openssl.yaml" + "k8s-tooling/.k9s/plugins/flux.yaml" + "k8s-tooling/.k9s/plugins/cert-manager.yaml" + "k8s-tooling/.k9s/plugins/openssl.yaml" ) for i in "${!K9S_PLUGINS[@]}"; do - curl -sSLo plugin.yaml "${K9S_PLUGINS[$i]}" - yq eval-all '. as $item ireduce ({}; . *+ $item)' \ - --inplace "$K9S_CONFIG/plugins.yaml" plugin.yaml - rm plugin.yaml + --inplace "$K9S_CONFIG/plugins.yaml" "${K9S_PLUGINS[$i]}" done +rm -rf k9s +rm -rf k8s-tooling + chown -R "$USER:$USER" "$K9S_CONFIG" chown -R "$USER:$USER" "$K9S_CTX"