Skip to content

Commit

Permalink
add build support script to print out the submodule versions required…
Browse files Browse the repository at this point in the history
… in other submodules
  • Loading branch information
jmurret committed Aug 22, 2024
1 parent 0e47b38 commit 7a0d3ca
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
17 changes: 17 additions & 0 deletions build-support/functions/10-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,20 @@ function go_mod_assert {
fi
return 0
}

function get_consul_module_versions {
local module_directories
module_directories=( "." "api" "envoyextensions" "proto-public" "sdk" "troubleshoot")
for module_dir in "${module_directories[@]}"; do
echo "Module versions for directory: '$module_dir':"
echo "--------------"
(cd "$module_dir" && go list -m all | grep -e github.com/hashicorp/consul/api \
-e github.com/hashicorp/consul/envoyextensions \
-e github.com/hashicorp/consul/proto-public \
-e github.com/hashicorp/consul/sdk \
-e github.com/hashicorp/consul/troubleshoot)
echo "--------------"
echo ""
done
return 0
}
62 changes: 62 additions & 0 deletions build-support/scripts/consul-module-versions-in-consul.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1


readonly SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})"
readonly SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
readonly SOURCE_DIR="$(dirname "$(dirname "${SCRIPT_DIR}")")"
readonly FN_DIR="$(dirname "${SCRIPT_DIR}")/functions"

source "${SCRIPT_DIR}/functions.sh"

function usage {
cat <<-EOF
Usage: ${SCRIPT_NAME} [<options ...>]
Description:
This script is just a convenience around discover what the Consul
version would be if you were to build it.
Options:
-s | --source DIR Path to source to build.
Defaults to "${SOURCE_DIR}"
-r | --release Include the release in the version
-g | --git Take git variables into account
-h | --help Print this help text.
EOF
}

function err_usage {
err "$1"
err ""
err "$(usage)"
}

function main {
while test $# -gt 0
do
case "$1" in
-h | --help )
usage
return 0
;;
*)
err_usage "ERROR: Unknown argument: '$1'"
return 1
;;
esac
done

get_consul_module_versions || return 1

return 0
}

main "$@"
exit $?

0 comments on commit 7a0d3ca

Please sign in to comment.