forked from app-registry/quay-helmv3-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cnr.sh
executable file
·63 lines (54 loc) · 1.32 KB
/
cnr.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#set -e
function list_plugin_versions {
if [ -x "$(command -v curl)" ]; then
local GET="curl -s"
else
local GET="wget -q -O -"
fi
$GET https://api.github.com/repos/app-registry/appr/tags |grep name | cut -d'"' -f 4
};
function latest {
list_plugin_versions | head -n 1
}
function download_appr {
local version=$(latest)
if [ $# -eq 1 ]; then
version=$1
fi
local PLATFORM="linux"
if [ -e /etc/alpine-release ]; then
PLATFORM="alpine"
fi
if [ "$(uname)" = "Darwin" ]; then
PLATFORM="osx"
fi
local URL="https://github.com/app-registry/appr/releases/download/$version/appr-$PLATFORM-x64"
echo "downloading $URL ..."
if [ -x "$(command -v curl)" ]; then
curl -s -L $URL -o $HELM_PLUGIN_DIR/appr
else
wget -q -O $HELM_PLUGIN_DIR/appr $URL
fi
chmod +x "$HELM_PLUGIN_DIR/appr"
}
function download_or_noop {
if [ ! -e "$HELM_PLUGIN_DIR/appr" ]; then
echo "Quay plugin assets do not exist, download them now !"
download_appr $1
fi
}
[ -z "$HELM_PLUGIN_DIR" ] && HELM_PLUGIN_DIR="$HELM_PLUGINS/quay-helmv3-plugin"
LATEST=$(latest)
download_or_noop $LATEST
case "$1" in
upgrade-plugin)
download_appr "${@:2}"
;;
list-plugin-versions)
list_plugin_versions
;;
*)
$HELM_PLUGIN_DIR/appr helm $@
;;
esac