fix verify-vendor if go.mod does not contain replace rules
Before this patch, if the go.mod did not contain a replace rule, jq would fail (Cannot iterate over null), and Bash would produce an error when trying to add an empty `$key` to `map_requires`: make verify-vendor + verify-vendor jq: error (at <stdin>:581): Cannot iterate over null (null) /go/src/github.com/containerd/containerd//script/verify-go-modules.sh: line 44: map_replaces_1[$key]: bad array subscript make: *** [Makefile:435: verify-vendor] Error 1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c4e29027d4
commit
a3a2d14ecc
@ -41,8 +41,8 @@ do
|
|||||||
done<<<$(go mod edit -json | jq -r '.Require[] | .Path + " # " + .Version')
|
done<<<$(go mod edit -json | jq -r '.Require[] | .Path + " # " + .Version')
|
||||||
while IFS='#' read -r key value
|
while IFS='#' read -r key value
|
||||||
do
|
do
|
||||||
map_replaces_1[$key]="$value"
|
[ "$key" = "" ] || map_replaces_1[$key]="$value"
|
||||||
done<<<$(go mod edit -json | jq -r '.Replace[] | .Old.Path + " # " + .New.Path + " : " + .New.Version')
|
done<<<$(go mod edit -json | jq -r 'try .Replace[] | .Old.Path + " # " + .New.Path + " : " + .New.Version')
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
# Load the requires and replaces section in the other go.mod file
|
# Load the requires and replaces section in the other go.mod file
|
||||||
@ -51,12 +51,12 @@ declare -A map_replaces_2
|
|||||||
pushd "${ROOT}/$1" > /dev/null
|
pushd "${ROOT}/$1" > /dev/null
|
||||||
while IFS='#' read -r key value
|
while IFS='#' read -r key value
|
||||||
do
|
do
|
||||||
map_requires_2[$key]="$value"
|
[ "$key" = "" ] || map_requires_2[$key]="$value"
|
||||||
done<<<$(go mod edit -json | jq -r '.Require[] | .Path + " # " + .Version')
|
done<<<$(go mod edit -json | jq -r '.Require[] | .Path + " # " + .Version')
|
||||||
while IFS='#' read -r key value
|
while IFS='#' read -r key value
|
||||||
do
|
do
|
||||||
map_replaces_2[$key]="$value"
|
map_replaces_2[$key]="$value"
|
||||||
done<<<$(go mod edit -json | jq -r '.Replace[] | .Old.Path + " # " + .New.Path + " : " + .New.Version')
|
done<<<$(go mod edit -json | jq -r 'try .Replace[] | .Old.Path + " # " + .New.Path + " : " + .New.Version')
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
# signal for errors later
|
# signal for errors later
|
||||||
|
Loading…
Reference in New Issue
Block a user