Skip to content

Commit c893810

Browse files
committed
update install script to use tabs
1 parent 0d77135 commit c893810

1 file changed

Lines changed: 77 additions & 77 deletions

File tree

scripts/install_plugin.sh

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export GREP_COLOR="never"
1212
# need a Unix path
1313

1414
if command -v cygpath >/dev/null 2>&1; then
15-
HELM_BIN="$(cygpath -u "${HELM_BIN}")"
16-
HELM_PLUGIN_DIR="$(cygpath -u "${HELM_PLUGIN_DIR}")"
15+
HELM_BIN="$(cygpath -u "${HELM_BIN}")"
16+
HELM_PLUGIN_DIR="$(cygpath -u "${HELM_PLUGIN_DIR}")"
1717
fi
1818

1919
[ -z "$HELM_BIN" ] && HELM_BIN=$(command -v helm)
@@ -25,122 +25,122 @@ mkdir -p "$HELM_HOME"
2525
: "${HELM_PLUGIN_DIR:="$HELM_HOME/plugins/$PROJECT_NAME"}"
2626

2727
if [ "$SKIP_BIN_INSTALL" = "1" ]; then
28-
echo "Skipping binary install"
29-
exit
28+
echo "Skipping binary install"
29+
exit
3030
fi
3131

3232
# which mode is the common installer script running in
3333
SCRIPT_MODE="install"
3434
if [ "$1" = "-u" ]; then
35-
SCRIPT_MODE="update"
35+
SCRIPT_MODE="update"
3636
fi
3737

3838
# initArch discovers the architecture for this system.
3939
initArch() {
40-
ARCH=$(uname -m)
41-
case $ARCH in
42-
armv5*) ARCH="armv5" ;;
43-
armv6*) ARCH="armv6" ;;
44-
armv7*) ARCH="armv7" ;;
45-
aarch64) ARCH="arm64" ;;
46-
x86) ARCH="386" ;;
47-
x86_64) ARCH="amd64" ;;
48-
i686) ARCH="386" ;;
49-
i386) ARCH="386" ;;
50-
esac
40+
ARCH=$(uname -m)
41+
case $ARCH in
42+
armv5*) ARCH="armv5" ;;
43+
armv6*) ARCH="armv6" ;;
44+
armv7*) ARCH="armv7" ;;
45+
aarch64) ARCH="arm64" ;;
46+
x86) ARCH="386" ;;
47+
x86_64) ARCH="amd64" ;;
48+
i686) ARCH="386" ;;
49+
i386) ARCH="386" ;;
50+
esac
5151
}
5252

5353
# initOS discovers the operating system for this system.
5454
initOS() {
55-
OS=$(uname -s)
56-
57-
case "$OS" in
58-
Windows_NT) OS='windows' ;;
59-
# Msys support
60-
MSYS*) OS='windows' ;;
61-
# Minimalist GNU for Windows
62-
MINGW*) OS='windows' ;;
63-
CYGWIN*) OS='windows' ;;
64-
Darwin) OS='macos' ;;
65-
Linux) OS='linux' ;;
66-
esac
55+
OS=$(uname -s)
56+
57+
case "$OS" in
58+
Windows_NT) OS='windows' ;;
59+
# Msys support
60+
MSYS*) OS='windows' ;;
61+
# Minimalist GNU for Windows
62+
MINGW*) OS='windows' ;;
63+
CYGWIN*) OS='windows' ;;
64+
Darwin) OS='macos' ;;
65+
Linux) OS='linux' ;;
66+
esac
6767
}
6868

6969
# verifySupported checks that the os/arch combination is supported for
7070
# binary builds.
7171
verifySupported() {
72-
supported="linux-amd64\nlinux-arm64\nfreebsd-amd64\nmacos-amd64\nmacos-arm64\nwindows-amd64"
73-
if ! echo "${supported}" | grep -q "${OS}-${ARCH}"; then
74-
echo "No prebuild binary for ${OS}-${ARCH}."
75-
exit 1
76-
fi
77-
78-
if
79-
! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1
80-
then
81-
echo "Either curl or wget is required"
82-
exit 1
83-
fi
72+
supported="linux-amd64\nlinux-arm64\nfreebsd-amd64\nmacos-amd64\nmacos-arm64\nwindows-amd64"
73+
if ! echo "${supported}" | grep -q "${OS}-${ARCH}"; then
74+
echo "No prebuild binary for ${OS}-${ARCH}."
75+
exit 1
76+
fi
77+
78+
if
79+
! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1
80+
then
81+
echo "Either curl or wget is required"
82+
exit 1
83+
fi
8484
}
8585

8686
# getDownloadURL checks the latest available version.
8787
getDownloadURL() {
88-
version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null || :)
89-
if [ "$SCRIPT_MODE" = "install" ] && [ -n "$version" ]; then
90-
DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$version/$PROJECT_NAME-$OS-$ARCH.tgz"
91-
else
92-
DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/latest/download/$PROJECT_NAME-$OS-$ARCH.tgz"
93-
fi
88+
version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null || :)
89+
if [ "$SCRIPT_MODE" = "install" ] && [ -n "$version" ]; then
90+
DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$version/$PROJECT_NAME-$OS-$ARCH.tgz"
91+
else
92+
DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/latest/download/$PROJECT_NAME-$OS-$ARCH.tgz"
93+
fi
9494
}
9595

9696
# Temporary dir
9797
mkTempDir() {
98-
HELM_TMP="$(mktemp -d -t "${PROJECT_NAME}-XXXXXX")"
98+
HELM_TMP="$(mktemp -d -t "${PROJECT_NAME}-XXXXXX")"
9999
}
100100
rmTempDir() {
101-
if [ -d "${HELM_TMP:-/tmp/helm-set-status-tmp}" ]; then
102-
rm -rf "${HELM_TMP:-/tmp/helm-set-status-tmp}"
103-
fi
101+
if [ -d "${HELM_TMP:-/tmp/helm-set-status-tmp}" ]; then
102+
rm -rf "${HELM_TMP:-/tmp/helm-set-status-tmp}"
103+
fi
104104
}
105105

106106
# downloadFile downloads the latest binary package and also the checksum
107107
# for that binary.
108108
downloadFile() {
109-
PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz"
110-
echo "Downloading $DOWNLOAD_URL"
111-
if
112-
command -v curl >/dev/null 2>&1
113-
then
114-
curl -sSf -L "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE"
115-
elif
116-
command -v wget >/dev/null 2>&1
117-
then
118-
wget -q -O - "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE"
119-
fi
109+
PLUGIN_TMP_FILE="${HELM_TMP}/${PROJECT_NAME}.tgz"
110+
echo "Downloading $DOWNLOAD_URL"
111+
if
112+
command -v curl >/dev/null 2>&1
113+
then
114+
curl -sSf -L "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE"
115+
elif
116+
command -v wget >/dev/null 2>&1
117+
then
118+
wget -q -O - "$DOWNLOAD_URL" >"$PLUGIN_TMP_FILE"
119+
fi
120120
}
121121

122122
# installFile verifies the SHA256 for the file, then unpacks and
123123
# installs it.
124124
installFile() {
125-
tar xzf "$PLUGIN_TMP_FILE" -C "$HELM_TMP"
126-
HELM_TMP_BIN="$HELM_TMP/$PROJECT_NAME/bin/$PROJECT_NAME"
127-
if [ "${OS}" = "windows" ]; then
128-
HELM_TMP_BIN="$HELM_TMP_BIN.exe"
129-
fi
130-
echo "Preparing to install into ${HELM_PLUGIN_DIR}"
131-
mkdir -p "$HELM_PLUGIN_DIR/bin"
132-
cp "$HELM_TMP_BIN" "$HELM_PLUGIN_DIR/bin"
125+
tar xzf "$PLUGIN_TMP_FILE" -C "$HELM_TMP"
126+
HELM_TMP_BIN="$HELM_TMP/$PROJECT_NAME/bin/$PROJECT_NAME"
127+
if [ "${OS}" = "windows" ]; then
128+
HELM_TMP_BIN="$HELM_TMP_BIN.exe"
129+
fi
130+
echo "Preparing to install into ${HELM_PLUGIN_DIR}"
131+
mkdir -p "$HELM_PLUGIN_DIR/bin"
132+
cp "$HELM_TMP_BIN" "$HELM_PLUGIN_DIR/bin"
133133
}
134134

135135
# exit_trap is executed if on exit (error or not).
136136
exit_trap() {
137-
result=$?
138-
rmTempDir
139-
if [ "$result" != "0" ]; then
140-
echo "Failed to install $PROJECT_NAME"
141-
printf "\tFor support, go to https://github.com/${PROJECT_GH}.\n"
142-
fi
143-
exit $result
137+
result=$?
138+
rmTempDir
139+
if [ "$result" != "0" ]; then
140+
echo "Failed to install $PROJECT_NAME"
141+
printf "\tFor support, go to https://github.com/${PROJECT_GH}.\n"
142+
fi
143+
exit $result
144144
}
145145

146146
# Execution
@@ -154,4 +154,4 @@ verifySupported
154154
getDownloadURL
155155
mkTempDir
156156
downloadFile
157-
installFile
157+
installFile

0 commit comments

Comments
 (0)