Skip to content

Commit

Permalink
Avoid downloading k9s plugins multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
mmontes11 committed May 13, 2024
1 parent 915a157 commit 28af49f
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions k9s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down

0 comments on commit 28af49f

Please sign in to comment.