Skip Go target normalization in integration tests

This commit is contained in:
Tim Hockin
2024-09-24 12:02:54 -07:00
parent 3582dce115
commit cf280dd6c2
5 changed files with 41 additions and 15 deletions

View File

@@ -383,7 +383,7 @@ kube::golang::best_guess_go_targets() {
continue
fi
if [[ "${target}" =~ ^([[:alnum:]]+".")+[[:alnum:]]+"/" ]]; then
if [[ "${target}" =~ ^([[:alnum:]]+".")+[[:alnum:]]+"/".+ ]]; then
# If the target starts with what looks like a domain name, assume it has a
# fully-qualified Go package name.
echo "${target}"
@@ -413,6 +413,19 @@ kube::golang::best_guess_go_targets() {
done
}
kube::golang::internal::lazy_normalize() {
target="$1"
if [[ "${target}" =~ ^([[:alnum:]]+".")+[[:alnum:]]+"/".+ ]]; then
# If the target starts with what looks like a domain name, assume it has a
# fully-qualified Go package name.
echo "${target}"
return
fi
go list -find -e "${target}"
}
# kube::golang::normalize_go_targets takes a list of build targets, which might
# be Go-style names (e.g. example.com/foo/bar or ./foo/bar) or just local paths
# (e.g. foo/bar) and produces a respective list (on stdout) of Go package
@@ -433,7 +446,7 @@ kube::golang::normalize_go_targets() {
local tst
tst="$(basename "${target}")"
local pkg
pkg="$(go list -find -e "${dir}")"
pkg="$(kube::golang::internal::lazy_normalize "${dir}")"
echo "${pkg}/${tst}"
continue
fi
@@ -441,11 +454,11 @@ kube::golang::normalize_go_targets() {
local dir
dir="$(dirname "${target}")"
local pkg
pkg="$(go list -find -e "${dir}")"
pkg="$(kube::golang::internal::lazy_normalize "${dir}")"
echo "${pkg}/..."
continue
fi
go list -find -e "${target}"
kube::golang::internal::lazy_normalize "${target}"
done
}