-
Notifications
You must be signed in to change notification settings - Fork 311
Change to use sh instead of bash #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,23 +1,27 @@ | ||
| #!/usr/bin/env bash | ||
| #!/usr/bin/env sh | ||
|
|
||
| # Shamelessly copied from https://github.com/technosophos/helm-template | ||
|
|
||
| PROJECT_NAME="helm-diff" | ||
| PROJECT_GH="databus23/$PROJECT_NAME" | ||
| GREP_COLOR="never" | ||
| export GREP_COLOR="never" | ||
|
|
||
| : ${HELM_PLUGIN_DIR:="$(helm home --debug=false)/plugins/helm-diff"} | ||
| HELM_MAJOR_VERSION=$(helm version --client --short | awk -F '.' '{print $1}') | ||
|
|
||
| if [ "$HELM_MAJOR_VERSION" = "Client: v2" ]; then | ||
| : ${HELM_PLUGIN_DIR:="$(helm home --debug=false)/plugins/helm-diff"} | ||
| fi | ||
|
|
||
| # 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 | ||
| if type cygpath >/dev/null 2>&1; then | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a cosmetic change, or actually required for POSIX compliance?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cosmetic change |
||
| HELM_PLUGIN_DIR=$(cygpath -u $HELM_PLUGIN_DIR) | ||
| fi | ||
|
|
||
| if [[ $SKIP_BIN_INSTALL == "1" ]]; then | ||
| if [ "$SKIP_BIN_INSTALL" = "1" ]; then | ||
| echo "Skipping binary install" | ||
| exit | ||
| fi | ||
|
|
@@ -26,56 +30,56 @@ fi | |
| 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";; | ||
| 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=$(echo `uname`|tr '[:upper:]' '[:lower:]') | ||
| OS=$(uname | tr '[:upper:]' '[:lower:]') | ||
|
|
||
| case "$OS" in | ||
| # Msys support | ||
| msys*) OS='windows';; | ||
| # Minimalist GNU for Windows | ||
| mingw*) OS='windows';; | ||
| darwin) OS='macos';; | ||
| # Msys support | ||
| msys*) OS='windows' ;; | ||
| # Minimalist GNU for Windows | ||
| mingw*) OS='windows' ;; | ||
| darwin) OS='macos' ;; | ||
| esac | ||
| } | ||
|
|
||
| # verifySupported checks that the os/arch combination is supported for | ||
| # binary builds. | ||
| verifySupported() { | ||
| local supported="linux-amd64\nfreebsd-amd64\nmacos-amd64\nwindows-amd64" | ||
| supported="linux-amd64\nfreebsd-amd64\nmacos-amd64\nwindows-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 | ||
| 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=$(git -C $HELM_PLUGIN_DIR describe --tags --exact-match 2>/dev/null) | ||
| version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null) | ||
| if [ -n "$version" ]; then | ||
| DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/$version/helm-diff-$OS.tgz" | ||
| 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 | ||
| 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 | ||
| elif type "wget" >/dev/null; then | ||
| DOWNLOAD_URL=$(wget -q -O - $url | grep $OS | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}') | ||
| fi | ||
| fi | ||
|
|
@@ -86,9 +90,9 @@ getDownloadURL() { | |
| downloadFile() { | ||
| PLUGIN_TMP_FILE="/tmp/${PROJECT_NAME}.tgz" | ||
| echo "Downloading $DOWNLOAD_URL" | ||
| if type "curl" > /dev/null; then | ||
| if type "curl" >/dev/null; then | ||
| curl -L "$DOWNLOAD_URL" -o "$PLUGIN_TMP_FILE" | ||
| elif type "wget" > /dev/null; then | ||
| elif type "wget" >/dev/null; then | ||
| wget -q -O "$PLUGIN_TMP_FILE" "$DOWNLOAD_URL" | ||
| fi | ||
| } | ||
|
|
@@ -110,7 +114,7 @@ fail_trap() { | |
| result=$? | ||
| if [ "$result" != "0" ]; then | ||
| echo "Failed to install $PROJECT_NAME" | ||
| echo "\tFor support, go to https://github.com/databus23/helm-diff." | ||
| printf '\tFor support, go to https://github.com/databus23/helm-diff.\n' | ||
| fi | ||
| exit $result | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do use HELM_PLUGIN_DIR in
installFile. Should we just revert this or just make it POSIX-compliant?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mumoshu AFAIK the
:denotes the line as pretty much a comment and thus would not run. Ashelm homeis not supported in helm3There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deiga Thanks. I thought so at first, but my tiny experiment revealed that this seems to have actual side-effect of assigning the value.
Good catch! Then it can be said that this can safely be removed for helm 3. Not yet sure that's alright for helm 2 though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Should I add a conditional for helm2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deiga That would be awesome! It will allow us to move forward without deciding if it's necessary or not right now.