Skip to content

Commit

Permalink
Remove dependency on gobin
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Wang <wachao@vmware.com>
  • Loading branch information
ahrtr committed Dec 19, 2022
1 parent 413ec16 commit 925c061
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
17 changes: 13 additions & 4 deletions scripts/test_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,25 @@ fi

# tool_get_bin [tool] - returns absolute path to a tool binary (or returns error)
function tool_get_bin {
tool_exists "gobin" "GO111MODULE=off go get github.com/myitcv/gobin" || return 2

local tool="$1"
local pkg_part="$1"
if [[ "$tool" == *"@"* ]]; then
pkg_part=$(echo "${tool}" | cut -d'@' -f1)
# shellcheck disable=SC2086
run gobin ${GOBINARGS:-} -p "${tool}" || return 2
run go install ${GOBINARGS:-} "${tool}" || return 2
else
# shellcheck disable=SC2086
run_for_module ./tools/mod run gobin ${GOBINARGS:-} -p -m --mod=readonly "${tool}" || return 2
run_for_module ./tools/mod run go install ${GOBINARGS:-} "${tool}" || return 2
fi

# remove the version suffix, such as removing "/v3" from "go.etcd.io/etcd/v3".
local cmd_base_name
cmd_base_name=$(basename "${pkg_part}")
if [[ ${cmd_base_name} =~ ^v[0-9]*$ ]]; then
pkg_part=$(dirname "${pkg_part}")
fi

run_for_module ./tools/mod go list -f '{{.Target}}' "${pkg_part}"
}

# tool_pkg_dir [pkg] - returns absolute path to a directory that stores given pkg.
Expand Down
14 changes: 14 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,20 @@ function bom_pass {
"${modules[@]}")
code="$?"

if [ "${code}" -ne 0 ] ; then
# license-bill-of-materials.go has a bug, it may get `go list ...` output
# included in the `names`. See,
# https://github.com/coreos/license-bill-of-materials/blob/13baff47494e3f89fe1b67818363c3bc2fb12b8a/license-bill-of-materials.go#L204-L222
# So we need to try one more time.
# ${HOME}/go/pkg/mod.
# TODO(ahrtr): get rid of https://github.com/coreos/license-bill-of-materials.

output=$(GOFLAGS=-mod=mod run_go_tool github.com/coreos/license-bill-of-materials \
--override-file ./bill-of-materials.override.json \
"${modules[@]}")
code="$?"
fi

run cp go.sum.tmp go.sum || return 2
run cp go.mod.tmp go.mod || return 2

Expand Down

0 comments on commit 925c061

Please sign in to comment.