From be57e1f6c278ebb99f62fb5182b5bde32445cfa2 Mon Sep 17 00:00:00 2001 From: Ma Xinjian Date: Thu, 21 Jan 2021 15:59:04 +0800 Subject: [PATCH 1/2] Add support to install kustomize to specified directory Signed-off-by: Ma Xinjian --- hack/install_kustomize.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hack/install_kustomize.sh b/hack/install_kustomize.sh index 02f07e0a6..df872d796 100755 --- a/hack/install_kustomize.sh +++ b/hack/install_kustomize.sh @@ -8,6 +8,10 @@ # kustomize binary to your current working directory. # (e.g. 'install_kustomize.sh 3.8.2') # +# If two arguments are given -> Downloads the specified version of the +# kustomize binary to the specified directory. +# (e.g. 'install_kustomize.sh 3.8.2 $(go env GOPATH)/bin') +# # Fails if the file already exists. curl_timeout=600 @@ -18,7 +22,12 @@ if [ -n "$1" ]; then release_url=${release_url}/tags/kustomize%2F$version fi -where=$PWD +if [ -z "$2" ]; then + where=$PWD + else + where=$2 +fi + if [ -f $where/kustomize ]; then echo "A file named kustomize already exists (remove it first)." exit 1 @@ -63,6 +72,6 @@ cp ./kustomize $where popd >& /dev/null -./kustomize version +$where/kustomize version -echo kustomize installed to current directory. +echo kustomize installed to specified directory. From 25e11e90201e55f6cdc2675b7f270fbe617e5275 Mon Sep 17 00:00:00 2001 From: Jeff Regan Date: Tue, 26 Jan 2021 12:15:20 -0800 Subject: [PATCH 2/2] Update install_kustomize.sh --- hack/install_kustomize.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hack/install_kustomize.sh b/hack/install_kustomize.sh index df872d796..fd057c444 100755 --- a/hack/install_kustomize.sh +++ b/hack/install_kustomize.sh @@ -15,21 +15,21 @@ # Fails if the file already exists. curl_timeout=600 -release_url=https://api.github.com/repos/kubernetes-sigs/kustomize/releases +version="" +release_url=https://api.github.com/repos/kubernetes-sigs/kustomize/releases if [ -n "$1" ]; then - version=v$1 - release_url=${release_url}/tags/kustomize%2F$version + version=v$1 + release_url=${release_url}/tags/kustomize%2F$version fi -if [ -z "$2" ]; then - where=$PWD - else - where=$2 +where=$PWD +if [ -n "$2" ]; then + where=$2 fi if [ -f $where/kustomize ]; then - echo "A file named kustomize already exists (remove it first)." + echo "A file named $where/kustomize already exists (remove it first)." exit 1 fi @@ -74,4 +74,4 @@ popd >& /dev/null $where/kustomize version -echo kustomize installed to specified directory. +echo kustomize installed to $where