summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgenerate-pkgbuild.sh21
1 files changed, 18 insertions, 3 deletions
diff --git a/generate-pkgbuild.sh b/generate-pkgbuild.sh
index 400d48382ad9..778179b04f2b 100755
--- a/generate-pkgbuild.sh
+++ b/generate-pkgbuild.sh
@@ -3,7 +3,11 @@
set -e
usage() {
- echo "Usage: $0 {stable|regular|rapid}" >&2
+ echo "Usage: $0 [{stable|regular|rapid}]" >&2
+}
+
+get_channel() {
+ echo ${PWD##*/} | grep -Eo '\-(stable|regular|rapid)-' | tr -d '\-'
}
get_major_version() {
@@ -13,6 +17,19 @@ get_major_version() {
| rg -o 'v?(\d\.\d+)\.\d+-gke\.\d+' -r '$1'
}
+if [ -z "$1" ];
+then
+ readonly channel=$(get_channel)
+ echo "Channel is not specified, automatically detected: $channel"
+ read -p "Is it correct? y/n " yn
+ case $yn in
+ [Yy]* ) set -- "$channel" ;;
+ * ) usage; exit 0;;
+ esac
+else
+ readonly channel=$1
+fi
+
case $1 in
-h)
usage
@@ -30,8 +47,6 @@ esac
readonly pkgname=kubectl
-readonly channel=$1
-
readonly version=$(curl -sSL "https://gcsweb.k8s.io/gcs/kubernetes-release/release/stable-$major_version.txt")
readonly arches=$( \