forked from burdiyan/helm-update-config
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from bluebosh/env-tls
Support TLS environment variables
- Loading branch information
Showing
13 changed files
with
1,061 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Shamelessly copied from https://github.com/technosophos/helm-template | ||
|
||
PROJECT_NAME="helm-update-config" | ||
PROJECT_GH="bluebosh/${PROJECT_NAME}" | ||
|
||
: "${HELM_PLUGIN_DIR:=\"$(helm home --debug=false)/plugins/helm-update-config\"}" | ||
|
||
# Convert the HELM_PLUGIN_DIR to unix if cygpath is | ||
# available. This is the case when using MSYS2 or Cygwin | ||
# on Windows where helm returns a Windows path but we | ||
# need a Unix path | ||
|
||
if type cygpath > /dev/null 2>&1; then | ||
HELM_PLUGIN_DIR=$(cygpath -u "${HELM_PLUGIN_DIR}") | ||
fi | ||
|
||
if [[ $SKIP_BIN_INSTALL == "1" ]]; then | ||
echo "Skipping binary install" | ||
exit | ||
fi | ||
|
||
# initArch discovers the architecture for this system. | ||
initArch() { | ||
ARCH=$(uname -m) | ||
case $ARCH in | ||
armv5*) ARCH="armv5";; | ||
armv6*) ARCH="armv6";; | ||
armv7*) ARCH="armv7";; | ||
aarch64) ARCH="arm64";; | ||
x86) ARCH="386";; | ||
x86_64) ARCH="amd64";; | ||
i686) ARCH="386";; | ||
i386) ARCH="386";; | ||
esac | ||
} | ||
|
||
# initOS discovers the operating system for this system. | ||
initOS() { | ||
OS=$(uname | tr '[:upper:]' '[:lower:]') | ||
} | ||
|
||
# verifySupported checks that the os/arch combination is supported for | ||
# binary builds. | ||
verifySupported() { | ||
local supported="linux-amd64\nfreebsd-amd64\nmacos-amd64\nwindows-amd64\ndarwin-amd64" | ||
if ! echo "${supported}" | grep -q "${OS}-${ARCH}"; then | ||
echo "No prebuild binary for ${OS}-${ARCH}." | ||
exit 1 | ||
fi | ||
|
||
if ! type "curl" > /dev/null && ! type "wget" > /dev/null; then | ||
echo "Either curl or wget is required" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# getDownloadURL checks the latest available version. | ||
getDownloadURL() { | ||
local version | ||
version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null || true) | ||
if [ -n "$version" ]; then | ||
DOWNLOAD_URL="https://github.com/${PROJECT_GH}/releases/download/${version}/helm-update-config_${OS}" | ||
else | ||
# Use the GitHub API to find the download url for this project. | ||
local url="https://api.github.com/repos/$PROJECT_GH/releases/latest" | ||
if type "curl" > /dev/null; then | ||
DOWNLOAD_URL=$(curl -s $url | grep $OS | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}') | ||
elif type "wget" > /dev/null; then | ||
DOWNLOAD_URL=$(wget -q -O - $url | grep $OS | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}') | ||
fi | ||
fi | ||
} | ||
|
||
# downloadFile downloads the latest binary package and also the checksum | ||
# for that binary. | ||
downloadFile() { | ||
PLUGIN_TMP_FILE="/tmp/${PROJECT_NAME}" | ||
echo "Downloading $DOWNLOAD_URL" | ||
if type "curl" > /dev/null; then | ||
curl -L "$DOWNLOAD_URL" -o "$PLUGIN_TMP_FILE" | ||
elif type "wget" > /dev/null; then | ||
wget -q -O "$PLUGIN_TMP_FILE" "$DOWNLOAD_URL" | ||
fi | ||
} | ||
|
||
# installFile verifies the SHA256 for the file, then unpacks and | ||
# installs it. | ||
installFile() { | ||
HELM_TMP_BIN="/tmp/$PROJECT_NAME" | ||
chmod +x "${HELM_TMP_BIN}" | ||
echo "Preparing to install into ${HELM_PLUGIN_DIR}" | ||
mkdir -p "$HELM_PLUGIN_DIR/bin" | ||
mv "$HELM_TMP_BIN" "$HELM_PLUGIN_DIR/bin/" | ||
} | ||
|
||
# fail_trap is executed if an error occurs. | ||
fail_trap() { | ||
result=$? | ||
if [ "$result" != "0" ]; then | ||
echo "Failed to install ${PROJECT_NAME}" | ||
printf "\tFor support, go to https://github.com/bluebosh/helm-update-config" | ||
fi | ||
exit $result | ||
} | ||
|
||
# testVersion tests the installed client to make sure it is working. | ||
testVersion() { | ||
set +e | ||
echo "$PROJECT_NAME installed into $HELM_PLUGIN_DIR/$PROJECT_NAME" | ||
"${HELM_PLUGIN_DIR}/bin/helm-update-config" -h | ||
set -e | ||
} | ||
|
||
# Execution | ||
|
||
#Stop execution on any error | ||
trap "fail_trap" EXIT | ||
set -e | ||
initArch | ||
initOS | ||
verifySupported | ||
getDownloadURL | ||
downloadFile | ||
installFile | ||
testVersion |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
name: "update-config" | ||
version: "0.5.3" | ||
version: "0.6.0" | ||
usage: "update config of a running release" | ||
description: Update configuration values of a running release. | ||
ignoreFlags: false | ||
useTunnel: true | ||
command: "$HELM_PLUGIN_DIR/bin/helm-update-config" | ||
hooks: | ||
install: "$HELM_PLUGIN_DIR/install.sh" | ||
install: "$HELM_PLUGIN_DIR/install-binary.sh" | ||
update: "$HELM_PLUGIN_DIR/install-binary.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.