From fe8ecb18b066f736b58bf6476539f4593f2b3bfc Mon Sep 17 00:00:00 2001 From: Qing Ju Date: Sun, 31 May 2020 21:55:48 -0700 Subject: [PATCH] Added link to vendor.md in go.mod --- go.mod | 2 ++ hack/update-vendor.sh | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 22aacd83881..9aedd33e64c 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,6 @@ // This is a generated file. Do not edit directly. +// Ensure you've carefully read +// https://git.k8s.io/community/contributors/devel/sig-architecture/vendor.md // Run hack/pin-dependency.sh to change pinned dependency versions. // Run hack/update-vendor.sh to update go.mod files and the vendor directory. diff --git a/hack/update-vendor.sh b/hack/update-vendor.sh index b3e620d4ff6..ae04558109c 100755 --- a/hack/update-vendor.sh +++ b/hack/update-vendor.sh @@ -99,10 +99,10 @@ function group_replace_directives() { /^replace [(]/ { inreplace=1; next } inreplace && /^[)]/ { inreplace=0; next } inreplace { print > \"${go_mod_replace}\"; next } - + # print ungrouped replace directives with the replace directive trimmed /^replace [^(]/ { sub(/^replace /,\"\"); print > \"${go_mod_replace}\"; next } - + # otherwise print to the noreplace file { print > \"${go_mod_noreplace}\" } " < go.mod @@ -136,7 +136,7 @@ function add_generated_comments() { echo "" cat "${go_mod_nocomments}" } > go.mod - + # Format go mod edit -fmt } @@ -232,7 +232,7 @@ while IFS= read -r repo; do go list -tags=tools all } >> "${LOG_FILE}" 2>&1 - # capture module dependencies + # capture module dependencies go list -m -f '{{if not .Main}}{{.Path}}{{end}}' all > "${tmp_go_deps}" # restore the original go.mod file @@ -255,13 +255,13 @@ for repo in $(tsort "${TMP_DIR}/tidy_deps.txt"); do # prune replace directives that pin to the naturally selected version. # do this before tidying, since tidy removes unused modules that - # don't provide any relevant packages, which forgets which version of the + # don't provide any relevant packages, which forgets which version of the # unused transitive dependency we had a require directive for, # and prevents pruning the matching replace directive after tidying. go list -m -json all | - jq -r 'select(.Replace != null) | - select(.Path == .Replace.Path) | - select(.Version == .Replace.Version) | + jq -r 'select(.Replace != null) | + select(.Path == .Replace.Path) | + select(.Version == .Replace.Version) | "-dropreplace \(.Replace.Path)"' | xargs -L 100 go mod edit -fmt @@ -285,9 +285,9 @@ $(go mod why "${loopback_deps[@]}")" # prune replace directives that pin to the naturally selected version go list -m -json all | - jq -r 'select(.Replace != null) | - select(.Path == .Replace.Path) | - select(.Version == .Replace.Version) | + jq -r 'select(.Replace != null) | + select(.Path == .Replace.Path) | + select(.Version == .Replace.Version) | "-dropreplace \(.Replace.Path)"' | xargs -L 100 go mod edit -fmt @@ -309,6 +309,8 @@ fi kube::log::status "go.mod: adding generated comments" add_generated_comments " // This is a generated file. Do not edit directly. +// Ensure you've carefully read +// https://git.k8s.io/community/contributors/devel/sig-architecture/vendor.md // Run hack/pin-dependency.sh to change pinned dependency versions. // Run hack/update-vendor.sh to update go.mod files and the vendor directory. "