mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Extend the install_kustomize.sh to enable the installation of specific versions
This commit is contained in:
@@ -1,10 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Downloads the most recently released kustomize binary
|
||||
# to your current working directory.
|
||||
# If no argument is given -> Downloads the most recently released
|
||||
# kustomize binary to your current working directory.
|
||||
# (e.g. 'install_kustomize.sh')
|
||||
#
|
||||
# If an argument is given -> Downloads the specified version of the
|
||||
# kustomize binary to your current working directory.
|
||||
# (e.g. 'install_kustomize.sh 3.8.2')
|
||||
#
|
||||
# Fails if the file already exists.
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "No version specified. Downloading the most recently released kustomize binary."
|
||||
version=""
|
||||
else
|
||||
echo "Downloading the kustomize binary version $1."
|
||||
version=$1
|
||||
fi
|
||||
|
||||
where=$PWD
|
||||
if [ -f $where/kustomize ]; then
|
||||
echo "A file named kustomize already exists (remove it first)."
|
||||
@@ -17,7 +31,7 @@ if [[ ! "$tmpDir" || ! -d "$tmpDir" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function cleanup {
|
||||
function cleanup {
|
||||
rm -rf "$tmpDir"
|
||||
}
|
||||
|
||||
@@ -36,11 +50,17 @@ curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases |\
|
||||
grep browser_download |\
|
||||
grep $opsys |\
|
||||
cut -d '"' -f 4 |\
|
||||
grep /kustomize/v |\
|
||||
grep /kustomize/v$version |\
|
||||
sort | tail -n 1 |\
|
||||
xargs curl -s -O -L
|
||||
|
||||
tar xzf ./kustomize_v*_${opsys}_amd64.tar.gz
|
||||
if [ -e ./kustomize_v*_${opsys}_amd64.tar.gz ]
|
||||
then
|
||||
tar xzf ./kustomize_v*_${opsys}_amd64.tar.gz
|
||||
else
|
||||
echo "Error: kustomize binary with the version $version does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp ./kustomize $where
|
||||
|
||||
|
||||
Reference in New Issue
Block a user