Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add build support script to print out the submodule versions required in other submodules #21635

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions build-support/functions/10-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,21 @@ 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 \
| if [ "$module_dir" != "." ]; then grep -v "consul/$module_dir"; else cat; fi)
echo "--------------"
echo ""
done
return 0
}
54 changes: 54 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,54 @@
#!/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 reports the consul module versions in each of the go.mod files in the Consul repository.
Options:
-h | --help Print this help text.
jmurret marked this conversation as resolved.
Show resolved Hide resolved
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 $?

Loading