go1.14: set -mod=mod while rebuilding/linting vendor and building licenses, preserve explicit imports in modules.txt
This commit is contained in:
parent
101653e5e8
commit
660c290bbf
@ -27,8 +27,8 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
|
|||||||
|
|
||||||
# Explicitly opt into go modules, even though we're inside a GOPATH directory
|
# Explicitly opt into go modules, even though we're inside a GOPATH directory
|
||||||
export GO111MODULE=on
|
export GO111MODULE=on
|
||||||
# Explicitly clear GOFLAGS, since GOFLAGS=-mod=vendor breaks dependency resolution while rebuilding vendor
|
# Explicitly set GOFLAGS to ignore vendor, since GOFLAGS=-mod=vendor breaks dependency resolution while rebuilding vendor
|
||||||
export GOFLAGS=
|
export GOFLAGS=-mod=mod
|
||||||
# Detect problematic GOPROXY settings that prevent lookup of dependencies
|
# Detect problematic GOPROXY settings that prevent lookup of dependencies
|
||||||
if [[ "${GOPROXY:-}" == "off" ]]; then
|
if [[ "${GOPROXY:-}" == "off" ]]; then
|
||||||
kube::log::error "Cannot run with \$GOPROXY=off"
|
kube::log::error "Cannot run with \$GOPROXY=off"
|
||||||
|
@ -134,7 +134,9 @@ process_content () {
|
|||||||
# MAIN
|
# MAIN
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
|
# use modules, and use module info rather than the vendor dir for computing dependencies
|
||||||
export GO111MODULE=on
|
export GO111MODULE=on
|
||||||
|
export GOFLAGS=-mod=mod
|
||||||
|
|
||||||
# Check bash version
|
# Check bash version
|
||||||
if (( BASH_VERSINFO[0] < 4 )); then
|
if (( BASH_VERSINFO[0] < 4 )); then
|
||||||
|
@ -23,8 +23,8 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
|
|||||||
|
|
||||||
# Explicitly opt into go modules, even though we're inside a GOPATH directory
|
# Explicitly opt into go modules, even though we're inside a GOPATH directory
|
||||||
export GO111MODULE=on
|
export GO111MODULE=on
|
||||||
# Explicitly clear GOFLAGS, since GOFLAGS=-mod=vendor breaks dependency resolution while rebuilding vendor
|
# Explicitly set GOFLAGS to ignore vendor, since GOFLAGS=-mod=vendor breaks dependency resolution while rebuilding vendor
|
||||||
export GOFLAGS=
|
export GOFLAGS=-mod=mod
|
||||||
# Ensure sort order doesn't depend on locale
|
# Ensure sort order doesn't depend on locale
|
||||||
export LANG=C
|
export LANG=C
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
@ -327,8 +327,16 @@ go mod vendor >>"${LOG_FILE}" 2>&1
|
|||||||
|
|
||||||
# sort recorded packages for a given vendored dependency in modules.txt.
|
# sort recorded packages for a given vendored dependency in modules.txt.
|
||||||
# `go mod vendor` outputs in imported order, which means slight go changes (or different platforms) can result in a differently ordered modules.txt.
|
# `go mod vendor` outputs in imported order, which means slight go changes (or different platforms) can result in a differently ordered modules.txt.
|
||||||
# scan | prefix comment lines with the module name | sort field 1 | strip leading text on comment lines
|
# 1. prefix '#' lines with the module name and capture the module name
|
||||||
awk '{if($1=="#") print $2 " " $0; else print}' < vendor/modules.txt | sort -k1,1 -s | sed 's/.*#/#/' > "${TMP_DIR}/modules.txt.tmp"
|
# 2. prefix '##' with the most recently captured module name
|
||||||
|
# 3. output other lines as-is
|
||||||
|
# sort lines
|
||||||
|
# strip anything before '#'
|
||||||
|
awk '{
|
||||||
|
if($1=="#") { current_module=$2; print $2 " " $0; }
|
||||||
|
else if($1=="##") { print current_module " " $0; }
|
||||||
|
else { print }
|
||||||
|
}' < vendor/modules.txt | sort -k1,1 -s | sed 's/[^#]*#/#/' > "${TMP_DIR}/modules.txt.tmp"
|
||||||
mv "${TMP_DIR}/modules.txt.tmp" vendor/modules.txt
|
mv "${TMP_DIR}/modules.txt.tmp" vendor/modules.txt
|
||||||
|
|
||||||
# create a symlink in vendor directory pointing to the staging components.
|
# create a symlink in vendor directory pointing to the staging components.
|
||||||
|
Loading…
Reference in New Issue
Block a user