1
0
mirror of https://github.com/etcd-io/etcd.git synced 2026-02-05 06:46:49 +01:00

Use workspace modules to generate the bom

Signed-off-by: Ivan Valdes <ivan@vald.es>
This commit is contained in:
Ivan Valdes
2025-10-20 21:23:11 -07:00
parent be2e2306c3
commit 5bf8e5ae50
2 changed files with 9 additions and 20 deletions

View File

@@ -114,11 +114,6 @@ function modules() {
echo "${modules[@]}"
}
function modules_for_bom() {
for m in $(modules); do
echo -n "${m}/... "
done
# Receives a reference to an array variable, and returns the workspace relative modules.
function load_workspace_relative_modules() {
local -n _relative_modules=$1

View File

@@ -17,25 +17,26 @@ set -euo pipefail
source ./scripts/test_lib.sh
function bom_fixlet {
function bom_fix {
log_callout "generating bill-of-materials.json"
cp go.mod go.mod.tmp
cp go.sum go.sum.tmp
local modules
# shellcheck disable=SC2207
modules=($(modules_for_bom))
local _bom_modules=()
load_workspace_relative_modules_for_bom _bom_modules
GOOS=linux run_go_tool "github.com/appscodelabs/license-bill-of-materials" \
--override-file ./bill-of-materials.override.json "${modules[@]}" &> /dev/null
# Intentionally run the command once first, so it fetches dependencies. The exit code on the first
# run in a just cloned repository is always dirty.
GOOS=linux run_go_tool github.com/appscodelabs/license-bill-of-materials \
--override-file ./bill-of-materials.override.json "${_bom_modules[@]}" &>/dev/null
# BOM file should be generated for linux. Otherwise running this command on other operating systems such as OSX
# results in certain dependencies being excluded from the BOM file, such as procfs.
# results in certain dependencies being excluded from the BOM file, such as procfs.
# For more info, https://github.com/etcd-io/etcd/issues/19665
if GOOS=linux run_go_tool "github.com/appscodelabs/license-bill-of-materials" \
--override-file ./bill-of-materials.override.json \
"${modules[@]}" > ./bill-of-materials.json.tmp; then
"${_bom_modules[@]}" > ./bill-of-materials.json.tmp; then
cp ./bill-of-materials.json.tmp ./bill-of-materials.json
log_success "bom refreshed"
else
@@ -48,13 +49,6 @@ function bom_fixlet {
mv go.sum.tmp go.sum
}
function bom_fix {
# We regenerate bom from the tests directory, as it's a module
# that depends on all other modules, so we can generate comprehensive content.
# TODO: Migrate to root module, when root module depends on everything (including server & tests).
run_for_module "." bom_fixlet
}
# only build when called directly, not sourced
if [[ "$0" =~ updatebom.sh$ ]]; then
bom_fix