From 37d62f970bcbb3e7342acee2ba0aced511fc7af1 Mon Sep 17 00:00:00 2001 From: sharnoff Date: Fri, 24 Feb 2023 10:38:10 -0800 Subject: [PATCH] Get NeonVM version from go.mod in scripts (#62) https://github.com/neondatabase/autoscaling/pull/52#discussion_r1113253155 --- scripts-common.sh | 7 +++++++ scripts/download-deployments.sh | 4 +++- vm_image/build.sh | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts-common.sh b/scripts-common.sh index 0fef07fb3..f61ba14f6 100644 --- a/scripts-common.sh +++ b/scripts-common.sh @@ -41,6 +41,13 @@ git_info () { sed -e "s:':\":g" } +# Usage: NEONVM_VERSION="$(neonvm_version)" +# +# Fetches the version of NeonVM we're using as a dependency, directly from go.mod. +neonvm_version () { + go list -m -f '{{ .Version }}' github.com/neondatabase/neonvm +} + # Usage: VAR_NAME="$(get_var VAR_NAME DEFAULT_VALUE)" # # Helper function that diff --git a/scripts/download-deployments.sh b/scripts/download-deployments.sh index 1e8e0e468..ed18d6df3 100755 --- a/scripts/download-deployments.sh +++ b/scripts/download-deployments.sh @@ -8,6 +8,8 @@ set -eu -o pipefail cd -P -- "$(dirname -- "$0")" cd .. # but all of the references are to things in the upper directory +source './scripts-common.sh' + echo "downloading 'deploy/flannel.yaml'..." curl -sS https://raw.githubusercontent.com/flannel-io/flannel/v0.19.2/Documentation/kube-flannel.yml \ -o deploy/flannel.yaml @@ -18,5 +20,5 @@ echo "downloading 'multus-daemonset.yaml'..." curl -sS https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/master/deployments/multus-daemonset.yml \ -o deploy/multus-daemonset.yaml echo "downloading 'neonvm.yaml'..." -curl -sSL https://github.com/neondatabase/neonvm/releases/download/v0.4.6/neonvm.yaml \ +curl -sSL https://github.com/neondatabase/neonvm/releases/download/$(neonvm_version)/neonvm.yaml \ -o deploy/neonvm.yaml diff --git a/vm_image/build.sh b/vm_image/build.sh index 7e1614df5..d64656dd3 100755 --- a/vm_image/build.sh +++ b/vm_image/build.sh @@ -17,7 +17,7 @@ source '../scripts-common.sh' NEONVM_BUILDER_PATH='neonvm-builder' NEONVM_REPO='https://github.com/neondatabase/neonvm' -NEONVM_VERSION='v0.4.6' +NEONVM_VERSION="$(neonvm_version)" if [ -e "$NEONVM_BUILDER_PATH" ]; then echo "Skipping downloading NeonVM vm-builder because '$NEONVM_BUILDER_PATH' already exists"