mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
use relative paths and modules that are not visible to golagn workspaces
This commit is contained in:
parent
e6fccc36d8
commit
52386915a8
@ -82,24 +82,17 @@ shift $((OPTIND - 1))
|
|||||||
# Check specific directory or everything.
|
# Check specific directory or everything.
|
||||||
targets=("$@")
|
targets=("$@")
|
||||||
if [ ${#targets[@]} -eq 0 ]; then
|
if [ ${#targets[@]} -eq 0 ]; then
|
||||||
# This lists all entries in the go.work file as absolute directory paths.
|
shopt -s globstar
|
||||||
kube::util::read-array targets < <(go list -f '{{.Dir}}' -m)
|
# Modules are discovered by looking for go.mod rather than asking go
|
||||||
|
# to ensure that modules that aren't part of the workspace and/or are
|
||||||
|
# not dependencies are checked too.
|
||||||
|
# . and staging are listed explicitly here to avoid _output
|
||||||
|
for module in ./go.mod ./staging/**/go.mod; do
|
||||||
|
module="${module%/go.mod}"
|
||||||
|
targets+=("$module")
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sanitize paths:
|
|
||||||
# - We need relative paths because we will invoke apidiff in
|
|
||||||
# different work trees.
|
|
||||||
# - Must start with a dot.
|
|
||||||
for (( i=0; i<${#targets[@]}; i++ )); do
|
|
||||||
d="${targets[i]}"
|
|
||||||
d=$(realpath -s --relative-to="$(pwd)" "${d}")
|
|
||||||
if [ "${d}" != "." ]; then
|
|
||||||
# sub-directories have to have a leading dot.
|
|
||||||
d="./${d}"
|
|
||||||
fi
|
|
||||||
targets[i]="${d}"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Must be a something that git can resolve to a commit.
|
# Must be a something that git can resolve to a commit.
|
||||||
# "git rev-parse --verify" checks that and prints a detailed
|
# "git rev-parse --verify" checks that and prints a detailed
|
||||||
# error.
|
# error.
|
||||||
|
Loading…
Reference in New Issue
Block a user