Merge pull request #113424 from liggitt/simplify-go.mod

Simplify go.mod
This commit is contained in:
Kubernetes Prow Robot 2022-10-31 14:20:57 -07:00 committed by GitHub
commit f9bfa378ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1209 additions and 874 deletions

View File

@ -35,38 +35,14 @@ type Unwanted struct {
}
type UnwantedSpec struct {
// TODO implement checks for RootModules
// module names/patterns of root modules whose dependencies should be considered direct references
RootModules []string `json:"rootModules"`
// module names we don't want to depend on, mapped to an optional message about why
UnwantedModules map[string]string `json:"unwantedModules"`
}
type UnwantedStatus struct {
// TODO implement checks for Vendored
// unwanted modules we still vendor, based on vendor/modules.txt content.
// eliminating things from this list is good.
Vendored []string `json:"vendored"`
// TODO implement checks for distinguishing direct/indirect
// unwanted modules we still directly reference from spec.roots, based on `go mod graph` content.
// references to modules in the spec.unwantedModules list, based on `go mod graph` content.
// eliminating things from this list is good, and sometimes requires working with upstreams to do so.
References []string `json:"references"`
}
// Check all unwanted dependencies and update its status.
func (config *Unwanted) checkUpdateStatus(modeGraph map[string][]string) {
fmt.Println("Check all unwanted dependencies and update its status.")
for unwanted := range config.Spec.UnwantedModules {
if _, found := modeGraph[unwanted]; found {
if !stringInSlice(unwanted, config.Status.References) {
config.Status.References = append(config.Status.References, unwanted)
}
}
}
// sort deps
sort.Strings(config.Status.References)
UnwantedReferences map[string][]string `json:"unwantedReferences"`
}
// runCommand runs the cmd and returns the combined stdout and stderr, or an
@ -85,44 +61,51 @@ func readFile(path string) (string, error) {
return string(content), err
}
func stringInSlice(a string, list []string) bool {
func moduleInSlice(a module, list []module, matchVersion bool) bool {
for _, b := range list {
if b == a {
return true
}
if !matchVersion && b.name == a.name {
return true
}
}
return false
}
func convertToMap(modStr string) map[string][]string {
modMap := make(map[string][]string)
// converts `go mod graph` output modStr into a map of from->[]to references and the main module
func convertToMap(modStr string) ([]module, map[module][]module) {
var (
mainModulesList = []module{}
mainModules = map[module]bool{}
)
modMap := make(map[module][]module)
for _, line := range strings.Split(modStr, "\n") {
if len(line) == 0 {
continue
}
deps := strings.Split(line, " ")
if len(deps) == 2 {
first := strings.Split(deps[0], "@")[0]
second := strings.Split(deps[1], "@")[0]
original, ok := modMap[second]
if !ok {
modMap[second] = []string{first}
} else if stringInSlice(first, original) {
continue
} else {
modMap[second] = append(original, first)
first := parseModule(deps[0])
second := parseModule(deps[1])
if first.version == "" || first.version == "v0.0.0" {
if !mainModules[first] {
mainModules[first] = true
mainModulesList = append(mainModulesList, first)
}
}
modMap[first] = append(modMap[first], second)
} else {
// skip invalid line
log.Printf("!!!invalid line in mod.graph: %s", line)
continue
}
}
return modMap
return mainModulesList, modMap
}
// difference returns a-b and b-a as a simple map.
func difference(a, b []string) (map[string]bool, map[string]bool) {
// difference returns a-b and b-a as sorted lists
func difference(a, b []string) ([]string, []string) {
aMinusB := map[string]bool{}
bMinusA := map[string]bool{}
for _, dependency := range a {
@ -135,7 +118,37 @@ func difference(a, b []string) (map[string]bool, map[string]bool) {
bMinusA[dependency] = true
}
}
return aMinusB, bMinusA
aMinusBList := []string{}
bMinusAList := []string{}
for dependency := range aMinusB {
aMinusBList = append(aMinusBList, dependency)
}
for dependency := range bMinusA {
bMinusAList = append(bMinusAList, dependency)
}
sort.Strings(aMinusBList)
sort.Strings(bMinusAList)
return aMinusBList, bMinusAList
}
type module struct {
name string
version string
}
func (m module) String() string {
if len(m.version) == 0 {
return m.name
}
return m.name + "@" + m.version
}
func parseModule(s string) module {
if !strings.Contains(s, "@") {
return module{name: s}
}
parts := strings.SplitN(s, "@", 2)
return module{name: parts[0], version: parts[1]}
}
// option1: dependencyverifier dependencies.json
@ -176,32 +189,150 @@ func main() {
log.Fatalf("Error reading dependencies file %s: %s", dependenciesJSONPath, err)
}
// Check and update status of struct Unwanted
modeGraph := convertToMap(modeGraphStr)
// convert from `go mod graph` to main module and map of from->[]to references
mainModules, moduleGraph := convertToMap(modeGraphStr)
// gather the effective versions by looking at the versions required by the main modules
effectiveVersions := map[string]module{}
for _, mainModule := range mainModules {
for _, override := range moduleGraph[mainModule] {
if _, ok := effectiveVersions[override.name]; !ok {
effectiveVersions[override.name] = override
}
}
}
unwantedToReferencers := map[string][]module{}
for _, mainModule := range mainModules {
// visit to find unwanted modules still referenced from the main module
visit(func(m module, via []module) {
if _, unwanted := configFromFile.Spec.UnwantedModules[m.name]; unwanted {
// this is unwanted, store what is referencing it
referencer := via[len(via)-1]
if !moduleInSlice(referencer, unwantedToReferencers[m.name], false) {
// // uncomment to get a detailed tree of the path that referenced the unwanted dependency
//
// i := 0
// for _, v := range via {
// if v.version != "" && v.version != "v0.0.0" {
// fmt.Println(strings.Repeat(" ", i), v)
// i++
// }
// }
// if i > 0 {
// fmt.Println(strings.Repeat(" ", i+1), m)
// fmt.Println()
// }
unwantedToReferencers[m.name] = append(unwantedToReferencers[m.name], referencer)
}
}
}, mainModule, moduleGraph, effectiveVersions)
}
config := &Unwanted{}
config.Spec.UnwantedModules = configFromFile.Spec.UnwantedModules
config.checkUpdateStatus(modeGraph)
for unwanted := range unwantedToReferencers {
if config.Status.UnwantedReferences == nil {
config.Status.UnwantedReferences = map[string][]string{}
}
sort.Slice(unwantedToReferencers[unwanted], func(i, j int) bool {
ri := unwantedToReferencers[unwanted][i]
rj := unwantedToReferencers[unwanted][j]
if ri.name != rj.name {
return ri.name < rj.name
}
return ri.version < rj.version
})
for _, referencer := range unwantedToReferencers[unwanted] {
// make sure any reference at all shows up as a non-nil status
if config.Status.UnwantedReferences == nil {
config.Status.UnwantedReferences[unwanted] = []string{}
}
// record specific names of versioned referents
if referencer.version != "" && referencer.version != "v0.0.0" {
config.Status.UnwantedReferences[unwanted] = append(config.Status.UnwantedReferences[unwanted], referencer.name)
}
}
}
needUpdate := false
// Compare unwanted list from unwanted-dependencies.json with current status from `go mod graph`
removedReferences, unwantedReferences := difference(configFromFile.Status.References, config.Status.References)
expected, err := json.MarshalIndent(configFromFile.Status, "", " ")
if err != nil {
log.Fatal(err)
}
actual, err := json.MarshalIndent(config.Status, "", " ")
if err != nil {
log.Fatal(err)
}
if !bytes.Equal(expected, actual) {
log.Printf("Expected status of\n%s", string(expected))
log.Printf("Got status of\n%s", string(actual))
}
for expectedRef, expectedFrom := range configFromFile.Status.UnwantedReferences {
actualFrom, ok := config.Status.UnwantedReferences[expectedRef]
if !ok {
// disappeared entirely
log.Printf("Good news! Unwanted dependency %q is no longer referenced. Remove status.unwantedReferences[%q] in %s to ensure it doesn't get reintroduced.", expectedRef, expectedRef, dependenciesJSONPath)
needUpdate = true
continue
}
removedReferences, unwantedReferences := difference(expectedFrom, actualFrom)
if len(removedReferences) > 0 {
log.Println("Good news! The following unwanted dependencies are no longer referenced:")
for reference := range removedReferences {
log.Printf("Good news! Unwanted module %q dropped the following dependants:", expectedRef)
for _, reference := range removedReferences {
log.Printf(" %s", reference)
}
log.Printf("!!! Remove the unwanted dependencies from status in %s to ensure they don't get reintroduced", dependenciesJSONPath)
log.Printf("!!! Remove those from status.unwantedReferences[%q] in %s to ensure they don't get reintroduced.", expectedRef, dependenciesJSONPath)
needUpdate = true
}
if len(unwantedReferences) > 0 {
log.Printf("The following unwanted dependencies marked in %s are referenced:", dependenciesJSONPath)
for reference := range unwantedReferences {
log.Printf(" %s (referenced by %s)", reference, strings.Join(modeGraph[reference], ", "))
log.Printf("Unwanted module %q marked in %s is referenced by new dependants:", expectedRef, dependenciesJSONPath)
for _, reference := range unwantedReferences {
log.Printf(" %s", reference)
}
log.Printf("!!! Avoid updating referencing modules to versions that reintroduce use of unwanted dependencies\n")
needUpdate = true
}
}
for actualRef, actualFrom := range config.Status.UnwantedReferences {
if _, expected := configFromFile.Status.UnwantedReferences[actualRef]; expected {
// expected, already ensured referencers were equal in the first loop
continue
}
log.Printf("Unwanted module %q marked in %s is referenced", actualRef, dependenciesJSONPath)
for _, reference := range actualFrom {
log.Printf(" %s", reference)
}
log.Printf("!!! Avoid updating referencing modules to versions that reintroduce use of unwanted dependencies\n")
needUpdate = true
}
if needUpdate {
os.Exit(1)
}
}
func visit(visitor func(m module, via []module), main module, references map[module][]module, effectiveVersions map[string]module) {
doVisit(visitor, main, nil, map[module]bool{}, references, effectiveVersions)
}
func doVisit(visitor func(m module, via []module), from module, via []module, visited map[module]bool, references map[module][]module, effectiveVersions map[string]module) {
visitor(from, via)
via = append(via, from)
if visited[from] {
return
}
for _, to := range references[from] {
// switch to the effective version of this dependency
if override, ok := effectiveVersions[to.name]; ok {
to = override
}
// recurse unless we've already visited this module in this traversal
if !moduleInSlice(to, via, false) {
doVisit(visitor, to, via, visited, references, effectiveVersions)
}
}
visited[from] = true
}

287
go.mod
View File

@ -172,7 +172,7 @@ require (
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/cel-go v0.12.5 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
@ -247,278 +247,6 @@ require (
)
replace (
bazil.org/fuse => bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898
bitbucket.org/bertimus9/systemstat => bitbucket.org/bertimus9/systemstat v0.5.0
cloud.google.com/go => cloud.google.com/go v0.97.0
cloud.google.com/go/bigquery => cloud.google.com/go/bigquery v1.8.0
cloud.google.com/go/storage => cloud.google.com/go/storage v1.10.0
github.com/Azure/azure-sdk-for-go => github.com/Azure/azure-sdk-for-go v55.0.0+incompatible
github.com/Azure/go-ansiterm => github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1
github.com/Azure/go-autorest => github.com/Azure/go-autorest v14.2.0+incompatible
github.com/Azure/go-autorest/autorest => github.com/Azure/go-autorest/autorest v0.11.27
github.com/Azure/go-autorest/autorest/adal => github.com/Azure/go-autorest/autorest/adal v0.9.20
github.com/Azure/go-autorest/autorest/date => github.com/Azure/go-autorest/autorest/date v0.3.0
github.com/Azure/go-autorest/autorest/mocks => github.com/Azure/go-autorest/autorest/mocks v0.4.2
github.com/Azure/go-autorest/autorest/to => github.com/Azure/go-autorest/autorest/to v0.4.0
github.com/Azure/go-autorest/autorest/validation => github.com/Azure/go-autorest/autorest/validation v0.1.0
github.com/Azure/go-autorest/logger => github.com/Azure/go-autorest/logger v0.2.1
github.com/Azure/go-autorest/tracing => github.com/Azure/go-autorest/tracing v0.6.0
github.com/BurntSushi/toml => github.com/BurntSushi/toml v0.3.1
github.com/GoogleCloudPlatform/k8s-cloud-provider => github.com/GoogleCloudPlatform/k8s-cloud-provider v1.18.1-0.20220218231025-f11817397a1b
github.com/JeffAshton/win_pdh => github.com/JeffAshton/win_pdh v0.0.0-20161109143554-76bb4ee9f0ab
github.com/MakeNowJust/heredoc => github.com/MakeNowJust/heredoc v1.0.0
github.com/Microsoft/go-winio => github.com/Microsoft/go-winio v0.4.17
github.com/Microsoft/hcsshim => github.com/Microsoft/hcsshim v0.8.22
github.com/NYTimes/gziphandler => github.com/NYTimes/gziphandler v1.1.1
github.com/PuerkitoBio/purell => github.com/PuerkitoBio/purell v1.1.1
github.com/PuerkitoBio/urlesc => github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
github.com/antihax/optional => github.com/antihax/optional v1.0.0
github.com/antlr/antlr4/runtime/Go/antlr => github.com/antlr/antlr4/runtime/Go/antlr v1.4.10
github.com/armon/circbuf => github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e
github.com/armon/go-socks5 => github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/asaskevich/govalidator => github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a
github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.44.116
github.com/benbjohnson/clock => github.com/benbjohnson/clock v1.1.0
github.com/beorn7/perks => github.com/beorn7/perks v1.0.1
github.com/blang/semver => github.com/blang/semver v3.5.1+incompatible
github.com/blang/semver/v4 => github.com/blang/semver/v4 v4.0.0
github.com/cenkalti/backoff/v4 => github.com/cenkalti/backoff/v4 v4.1.3
github.com/census-instrumentation/opencensus-proto => github.com/census-instrumentation/opencensus-proto v0.2.1
github.com/certifi/gocertifi => github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054
github.com/cespare/xxhash/v2 => github.com/cespare/xxhash/v2 v2.1.2
github.com/chai2010/gettext-go => github.com/chai2010/gettext-go v1.0.2
github.com/checkpoint-restore/go-criu/v5 => github.com/checkpoint-restore/go-criu/v5 v5.3.0
github.com/chzyer/logex => github.com/chzyer/logex v1.1.10
github.com/chzyer/readline => github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
github.com/chzyer/test => github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1
github.com/cilium/ebpf => github.com/cilium/ebpf v0.7.0
github.com/cncf/udpa/go => github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4
github.com/cncf/xds/go => github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1
github.com/cockroachdb/datadriven => github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5
github.com/cockroachdb/errors => github.com/cockroachdb/errors v1.2.4
github.com/cockroachdb/logtags => github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f
github.com/container-storage-interface/spec => github.com/container-storage-interface/spec v1.6.0
github.com/containerd/cgroups => github.com/containerd/cgroups v1.0.1
github.com/containerd/console => github.com/containerd/console v1.0.3
github.com/containerd/containerd => github.com/containerd/containerd v1.4.9
github.com/containerd/continuity => github.com/containerd/continuity v0.1.0
github.com/containerd/fifo => github.com/containerd/fifo v1.0.0
github.com/containerd/go-runc => github.com/containerd/go-runc v1.0.0
github.com/containerd/ttrpc => github.com/containerd/ttrpc v1.0.2
github.com/containerd/typeurl => github.com/containerd/typeurl v1.0.2
github.com/coredns/caddy => github.com/coredns/caddy v1.1.0
github.com/coredns/corefile-migration => github.com/coredns/corefile-migration v1.0.17
github.com/coreos/go-oidc => github.com/coreos/go-oidc v2.1.0+incompatible
github.com/coreos/go-semver => github.com/coreos/go-semver v0.3.0
github.com/coreos/go-systemd/v22 => github.com/coreos/go-systemd/v22 v22.3.2
github.com/cpuguy83/go-md2man/v2 => github.com/cpuguy83/go-md2man/v2 v2.0.2
github.com/creack/pty => github.com/creack/pty v1.1.11
github.com/cyphar/filepath-securejoin => github.com/cyphar/filepath-securejoin v0.2.3
github.com/davecgh/go-spew => github.com/davecgh/go-spew v1.1.1
github.com/daviddengcn/go-colortext => github.com/daviddengcn/go-colortext v1.0.0
github.com/dnaeon/go-vcr => github.com/dnaeon/go-vcr v1.0.1
github.com/docker/distribution => github.com/docker/distribution v2.8.1+incompatible
github.com/docker/docker => github.com/docker/docker v20.10.17+incompatible
github.com/docker/go-connections => github.com/docker/go-connections v0.4.0
github.com/docker/go-units => github.com/docker/go-units v0.4.0
github.com/docopt/docopt-go => github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
github.com/dustin/go-humanize => github.com/dustin/go-humanize v1.0.0
github.com/elazarl/goproxy => github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 // 947c36da3153 is the SHA for git tag v1.11
github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.9.0
github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1
github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v0.1.0
github.com/euank/go-kmsg-parser => github.com/euank/go-kmsg-parser v2.0.0+incompatible
github.com/evanphx/json-patch => github.com/evanphx/json-patch v4.12.0+incompatible
github.com/exponent-io/jsonpath => github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d
github.com/fatih/camelcase => github.com/fatih/camelcase v1.0.0
github.com/felixge/httpsnoop => github.com/felixge/httpsnoop v1.0.3
github.com/flynn/go-shlex => github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568
github.com/form3tech-oss/jwt-go => github.com/form3tech-oss/jwt-go v3.2.3+incompatible
github.com/frankban/quicktest => github.com/frankban/quicktest v1.11.3
github.com/fsnotify/fsnotify => github.com/fsnotify/fsnotify v1.6.0
github.com/fvbommel/sortorder => github.com/fvbommel/sortorder v1.0.1
github.com/getsentry/raven-go => github.com/getsentry/raven-go v0.2.0
github.com/ghodss/yaml => github.com/ghodss/yaml v1.0.0
github.com/go-errors/errors => github.com/go-errors/errors v1.0.1
github.com/go-kit/kit => github.com/go-kit/kit v0.9.0
github.com/go-kit/log => github.com/go-kit/log v0.2.0
github.com/go-logfmt/logfmt => github.com/go-logfmt/logfmt v0.5.1
github.com/go-logr/logr => github.com/go-logr/logr v1.2.3
github.com/go-logr/stdr => github.com/go-logr/stdr v1.2.2
github.com/go-logr/zapr => github.com/go-logr/zapr v1.2.3
github.com/go-openapi/jsonpointer => github.com/go-openapi/jsonpointer v0.19.5
github.com/go-openapi/jsonreference => github.com/go-openapi/jsonreference v0.20.0
github.com/go-openapi/swag => github.com/go-openapi/swag v0.19.14
github.com/go-stack/stack => github.com/go-stack/stack v1.8.0
github.com/go-task/slim-sprig => github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0
github.com/godbus/dbus/v5 => github.com/godbus/dbus/v5 v5.0.6
github.com/gofrs/uuid => github.com/gofrs/uuid v4.0.0+incompatible
github.com/gogo/googleapis => github.com/gogo/googleapis v1.4.1
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
github.com/golang-jwt/jwt/v4 => github.com/golang-jwt/jwt/v4 v4.2.0
github.com/golang/glog => github.com/golang/glog v1.0.0
github.com/golang/groupcache => github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
github.com/golang/mock => github.com/golang/mock v1.6.0
github.com/golang/protobuf => github.com/golang/protobuf v1.5.2
github.com/golang/snappy => github.com/golang/snappy v0.0.3
github.com/golangplus/bytes => github.com/golangplus/bytes v1.0.0
github.com/golangplus/fmt => github.com/golangplus/fmt v1.0.0
github.com/golangplus/testing => github.com/golangplus/testing v1.0.0
github.com/google/btree => github.com/google/btree v1.0.1
github.com/google/cadvisor => github.com/google/cadvisor v0.45.0
github.com/google/cel-go => github.com/google/cel-go v0.12.5
github.com/google/gnostic => github.com/google/gnostic v0.5.7-v3refs
github.com/google/go-cmp => github.com/google/go-cmp v0.5.9
github.com/google/gofuzz => github.com/google/gofuzz v1.1.0
github.com/google/martian/v3 => github.com/google/martian/v3 v3.2.1
github.com/google/pprof => github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38
github.com/google/renameio => github.com/google/renameio v0.1.0
github.com/google/shlex => github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid => github.com/google/uuid v1.1.2
github.com/googleapis/gax-go/v2 => github.com/googleapis/gax-go/v2 v2.1.1
github.com/gorilla/websocket => github.com/gorilla/websocket v1.4.2
github.com/gregjones/httpcache => github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7
github.com/grpc-ecosystem/go-grpc-middleware => github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/go-grpc-prometheus => github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/grpc-ecosystem/grpc-gateway => github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0
github.com/ianlancetaylor/demangle => github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639
github.com/imdario/mergo => github.com/imdario/mergo v0.3.6
github.com/inconshreveable/mousetrap => github.com/inconshreveable/mousetrap v1.0.1
github.com/ishidawataru/sctp => github.com/ishidawataru/sctp v0.0.0-20190723014705-7c296d48a2b5
github.com/jmespath/go-jmespath => github.com/jmespath/go-jmespath v0.4.0
github.com/jmespath/go-jmespath/internal/testify => github.com/jmespath/go-jmespath/internal/testify v1.5.1
github.com/jonboulle/clockwork => github.com/jonboulle/clockwork v0.2.2
github.com/josharian/intern => github.com/josharian/intern v1.0.0
github.com/jpillora/backoff => github.com/jpillora/backoff v1.0.0
github.com/json-iterator/go => github.com/json-iterator/go v1.1.12
github.com/julienschmidt/httprouter => github.com/julienschmidt/httprouter v1.3.0
github.com/karrick/godirwalk => github.com/karrick/godirwalk v1.16.1
github.com/kisielk/errcheck => github.com/kisielk/errcheck v1.5.0
github.com/kisielk/gotool => github.com/kisielk/gotool v1.0.0
github.com/konsorten/go-windows-terminal-sequences => github.com/konsorten/go-windows-terminal-sequences v1.0.2
github.com/kr/pretty => github.com/kr/pretty v0.2.1
github.com/kr/text => github.com/kr/text v0.2.0
github.com/libopenstorage/openstorage => github.com/libopenstorage/openstorage v1.0.0
github.com/liggitt/tabwriter => github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
github.com/lithammer/dedent => github.com/lithammer/dedent v1.1.0
github.com/mailru/easyjson => github.com/mailru/easyjson v0.7.6
github.com/mattn/go-runewidth => github.com/mattn/go-runewidth v0.0.7
github.com/matttproud/golang_protobuf_extensions => github.com/matttproud/golang_protobuf_extensions v1.0.2
github.com/mindprince/gonvml => github.com/mindprince/gonvml v0.0.0-20190828220739-9ebdce4bb989
github.com/mistifyio/go-zfs => github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible
github.com/mitchellh/go-wordwrap => github.com/mitchellh/go-wordwrap v1.0.0
github.com/mitchellh/mapstructure => github.com/mitchellh/mapstructure v1.4.1
github.com/moby/ipvs => github.com/moby/ipvs v1.0.1
github.com/moby/spdystream => github.com/moby/spdystream v0.2.0
github.com/moby/sys/mountinfo => github.com/moby/sys/mountinfo v0.6.0
github.com/moby/term => github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
github.com/modern-go/concurrent => github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
github.com/modern-go/reflect2 => github.com/modern-go/reflect2 v1.0.2
github.com/mohae/deepcopy => github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb
github.com/monochromegane/go-gitignore => github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00
github.com/morikuni/aec => github.com/morikuni/aec v1.0.0
github.com/mrunalp/fileutils => github.com/mrunalp/fileutils v0.5.0
github.com/munnerz/goautoneg => github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
github.com/mwitkow/go-conntrack => github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
github.com/mxk/go-flowrate => github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f
github.com/niemeyer/pretty => github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e
github.com/olekukonko/tablewriter => github.com/olekukonko/tablewriter v0.0.4
github.com/onsi/ginkgo/v2 => github.com/onsi/ginkgo/v2 v2.4.0
github.com/onsi/gomega => github.com/onsi/gomega v1.23.0
github.com/opencontainers/go-digest => github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec => github.com/opencontainers/image-spec v1.0.2
github.com/opencontainers/runc => github.com/opencontainers/runc v1.1.3
github.com/opencontainers/runtime-spec => github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/opencontainers/selinux => github.com/opencontainers/selinux v1.10.0
github.com/opentracing/opentracing-go => github.com/opentracing/opentracing-go v1.1.0
github.com/peterbourgon/diskv => github.com/peterbourgon/diskv v2.0.1+incompatible
github.com/pkg/errors => github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib => github.com/pmezard/go-difflib v1.0.0
github.com/pquerna/cachecontrol => github.com/pquerna/cachecontrol v0.1.0
github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.13.0
github.com/prometheus/client_model => github.com/prometheus/client_model v0.2.0
github.com/prometheus/common => github.com/prometheus/common v0.37.0
github.com/prometheus/procfs => github.com/prometheus/procfs v0.8.0
github.com/robfig/cron/v3 => github.com/robfig/cron/v3 v3.0.1
github.com/rogpeppe/fastuuid => github.com/rogpeppe/fastuuid v1.2.0
github.com/rogpeppe/go-internal => github.com/rogpeppe/go-internal v1.3.0
github.com/rubiojr/go-vhd => github.com/rubiojr/go-vhd v0.0.0-20200706105327-02e210299021
github.com/russross/blackfriday/v2 => github.com/russross/blackfriday/v2 v2.1.0
github.com/seccomp/libseccomp-golang => github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646
github.com/sergi/go-diff => github.com/sergi/go-diff v1.1.0
github.com/sirupsen/logrus => github.com/sirupsen/logrus v1.8.1
github.com/soheilhy/cmux => github.com/soheilhy/cmux v0.1.5
github.com/spf13/cobra => github.com/spf13/cobra v1.6.0
github.com/spf13/pflag => github.com/spf13/pflag v1.0.5
github.com/stoewer/go-strcase => github.com/stoewer/go-strcase v1.2.0
github.com/stretchr/objx => github.com/stretchr/objx v0.4.0
github.com/stretchr/testify => github.com/stretchr/testify v1.8.0
github.com/syndtr/gocapability => github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/tmc/grpc-websocket-proxy => github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802
github.com/urfave/cli => github.com/urfave/cli v1.22.2
github.com/vishvananda/netlink => github.com/vishvananda/netlink v1.1.0
github.com/vishvananda/netns => github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae
github.com/vmware/govmomi => github.com/vmware/govmomi v0.20.3
github.com/xiang90/probing => github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2
github.com/xlab/treeprint => github.com/xlab/treeprint v1.1.0
github.com/yuin/goldmark => github.com/yuin/goldmark v1.4.13
go.etcd.io/bbolt => go.etcd.io/bbolt v1.3.6
go.etcd.io/etcd/api/v3 => go.etcd.io/etcd/api/v3 v3.5.5
go.etcd.io/etcd/client/pkg/v3 => go.etcd.io/etcd/client/pkg/v3 v3.5.5
go.etcd.io/etcd/client/v2 => go.etcd.io/etcd/client/v2 v2.305.5
go.etcd.io/etcd/client/v3 => go.etcd.io/etcd/client/v3 v3.5.5
go.etcd.io/etcd/pkg/v3 => go.etcd.io/etcd/pkg/v3 v3.5.5
go.etcd.io/etcd/raft/v3 => go.etcd.io/etcd/raft/v3 v3.5.5
go.etcd.io/etcd/server/v3 => go.etcd.io/etcd/server/v3 v3.5.5
go.opencensus.io => go.opencensus.io v0.23.0
go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful => go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful v0.35.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc => go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp => go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0
go.opentelemetry.io/contrib/propagators/b3 => go.opentelemetry.io/contrib/propagators/b3 v1.10.0
go.opentelemetry.io/otel => go.opentelemetry.io/otel v1.10.0
go.opentelemetry.io/otel/exporters/otlp/internal/retry => go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace => go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.10.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.10.0
go.opentelemetry.io/otel/metric => go.opentelemetry.io/otel/metric v0.31.0
go.opentelemetry.io/otel/sdk => go.opentelemetry.io/otel/sdk v1.10.0
go.opentelemetry.io/otel/trace => go.opentelemetry.io/otel/trace v1.10.0
go.opentelemetry.io/proto/otlp => go.opentelemetry.io/proto/otlp v0.19.0
go.starlark.net => go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5
go.uber.org/atomic => go.uber.org/atomic v1.7.0
go.uber.org/goleak => go.uber.org/goleak v1.2.0
go.uber.org/multierr => go.uber.org/multierr v1.6.0
go.uber.org/zap => go.uber.org/zap v1.19.0
golang.org/x/crypto => golang.org/x/crypto v0.1.0
golang.org/x/lint => golang.org/x/lint v0.0.0-20190930215403-16217165b5de
golang.org/x/mod => golang.org/x/mod v0.6.0
golang.org/x/net => golang.org/x/net v0.1.1-0.20221027164007-c63010009c80
golang.org/x/oauth2 => golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b
golang.org/x/sync => golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/sys => golang.org/x/sys v0.1.0
golang.org/x/term => golang.org/x/term v0.1.0
golang.org/x/text => golang.org/x/text v0.4.0
golang.org/x/time => golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
golang.org/x/tools => golang.org/x/tools v0.2.0
golang.org/x/xerrors => golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
google.golang.org/api => google.golang.org/api v0.60.0
google.golang.org/appengine => google.golang.org/appengine v1.6.7
google.golang.org/genproto => google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21
google.golang.org/grpc => google.golang.org/grpc v1.49.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc => google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0
google.golang.org/protobuf => google.golang.org/protobuf v1.28.1
gopkg.in/alecthomas/kingpin.v2 => gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/check.v1 => gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f
gopkg.in/errgo.v2 => gopkg.in/errgo.v2 v2.1.0
gopkg.in/gcfg.v1 => gopkg.in/gcfg.v1 v1.2.0
gopkg.in/inf.v0 => gopkg.in/inf.v0 v0.9.1
gopkg.in/natefinch/lumberjack.v2 => gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/square/go-jose.v2 => gopkg.in/square/go-jose.v2 v2.2.2
gopkg.in/warnings.v0 => gopkg.in/warnings.v0 v0.1.1
gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1
gotest.tools/v3 => gotest.tools/v3 v3.0.3
honnef.co/go/tools => honnef.co/go/tools v0.0.1-2020.1.4
k8s.io/api => ./staging/src/k8s.io/api
k8s.io/apiextensions-apiserver => ./staging/src/k8s.io/apiextensions-apiserver
k8s.io/apimachinery => ./staging/src/k8s.io/apimachinery
@ -533,12 +261,9 @@ replace (
k8s.io/controller-manager => ./staging/src/k8s.io/controller-manager
k8s.io/cri-api => ./staging/src/k8s.io/cri-api
k8s.io/csi-translation-lib => ./staging/src/k8s.io/csi-translation-lib
k8s.io/gengo => k8s.io/gengo v0.0.0-20220902162205-c0856e24416d
k8s.io/klog/v2 => k8s.io/klog/v2 v2.80.1
k8s.io/kms => ./staging/src/k8s.io/kms
k8s.io/kube-aggregator => ./staging/src/k8s.io/kube-aggregator
k8s.io/kube-controller-manager => ./staging/src/k8s.io/kube-controller-manager
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280
k8s.io/kube-proxy => ./staging/src/k8s.io/kube-proxy
k8s.io/kube-scheduler => ./staging/src/k8s.io/kube-scheduler
k8s.io/kubectl => ./staging/src/k8s.io/kubectl
@ -550,14 +275,4 @@ replace (
k8s.io/sample-apiserver => ./staging/src/k8s.io/sample-apiserver
k8s.io/sample-cli-plugin => ./staging/src/k8s.io/sample-cli-plugin
k8s.io/sample-controller => ./staging/src/k8s.io/sample-controller
k8s.io/system-validators => k8s.io/system-validators v1.8.0
k8s.io/utils => k8s.io/utils v0.0.0-20220922133306-665eaaec4324
sigs.k8s.io/apiserver-network-proxy/konnectivity-client => sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.33
sigs.k8s.io/json => sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2
sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.12.1
sigs.k8s.io/kustomize/cmd/config => sigs.k8s.io/kustomize/cmd/config v0.10.9
sigs.k8s.io/kustomize/kustomize/v4 => sigs.k8s.io/kustomize/kustomize/v4 v4.5.7
sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.13.9
sigs.k8s.io/structured-merge-diff/v4 => sigs.k8s.io/structured-merge-diff/v4 v4.2.3
sigs.k8s.io/yaml => sigs.k8s.io/yaml v1.3.0
)

794
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -94,16 +94,15 @@ echo "Running: go mod edit -require ${dep}@${rev}"
go mod edit -require "${dep}@${rev}"
# Add the replace directive
if [ "${replacement}" != "${dep}" ]; then
echo "Running: go mod edit -replace ${dep}=${replacement}@${rev}"
go mod edit -replace "${dep}=${replacement}@${rev}"
fi
# Propagate pinned version to staging repos that also have that dependency
# Propagate pinned version to staging repos
for repo in $(kube::util::list_staging_repos); do
pushd "staging/src/k8s.io/${repo}" >/dev/null 2>&1
if go mod edit -json | jq -e -r ".Require[] | select(.Path == \"${dep}\")" > /dev/null 2>&1; then
go mod edit -require "${dep}@${rev}"
go mod edit -replace "${dep}=${replacement}@${rev}"
fi
# When replacing with a fork, always add a replace statement in all go.mod
# files (not just the root of the staging repos!) because there might be

View File

@ -23,9 +23,17 @@
}
},
"status": {
"references": [
"github.com/go-kit/kit",
"github.com/json-iterator/go"
"unwantedReferences": {
"github.com/go-kit/kit": [
"github.com/grpc-ecosystem/go-grpc-middleware"
],
"github.com/json-iterator/go": [
"github.com/prometheus/client_golang",
"go.etcd.io/etcd/client/v2",
"go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful",
"k8s.io/kube-openapi",
"sigs.k8s.io/structured-merge-diff/v4"
]
}
}
}

View File

@ -82,36 +82,18 @@ function ensure_require_replace_directives_for_all_dependencies() {
| jq -r ".Replace // [] | sort | .[] | select(${replace_filter})" \
> "${replace_json}"
# 1a. Ensure replace directives have an explicit require directive
jq -r '"-require \(.Old.Path)@\(.New.Version)"' < "${replace_json}" \
| xargs -L 100 go mod edit -fmt
# 1b. Ensure require directives have a corresponding replace directive pinning a version
jq -r '"-replace \(.Path)=\(.Path)@\(.Version)"' < "${require_json}" \
| xargs -L 100 go mod edit -fmt
jq -r '"-replace \(.Old.Path)=\(.New.Path)@\(.New.Version)"' < "${replace_json}" \
| xargs -L 100 go mod edit -fmt
# 2. Propagate root replace/require directives into staging modules, in case we are downgrading, so they don't bump the root required version back up
# Propagate root replace/require directives into staging modules, in case we are downgrading, so they don't bump the root required version back up
for repo in $(kube::util::list_staging_repos); do
pushd "staging/src/k8s.io/${repo}" >/dev/null 2>&1
jq -r '"-require \(.Path)@\(.Version)"' < "${require_json}" \
| xargs -L 100 go mod edit -fmt
jq -r '"-replace \(.Path)=\(.Path)@\(.Version)"' < "${require_json}" \
| xargs -L 100 go mod edit -fmt
jq -r '"-replace \(.Old.Path)=\(.New.Path)@\(.New.Version)"' < "${replace_json}" \
| xargs -L 100 go mod edit -fmt
popd >/dev/null 2>&1
done
# 3. Add explicit require directives for indirect dependencies
go list -m -json all \
| jq -r 'select(.Main != true) | select(.Indirect == true) | "-require \(.Path)@\(.Version)"' \
| xargs -L 100 go mod edit -fmt
# 4. Add explicit replace directives pinning dependencies that aren't pinned yet
go list -m -json all \
| jq -r 'select(.Main != true) | select(.Replace == null) | "-replace \(.Path)=\(.Path)@\(.Version)"' \
| xargs -L 100 go mod edit -fmt
# tidy to ensure require directives are added for indirect dependencies
go mod tidy
}
function print_go_mod_section() {

View File

@ -43,7 +43,7 @@ require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dnaeon/go-vcr v1.0.1 // indirect
github.com/dnaeon/go-vcr v1.2.0 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-logr/logr v1.2.3 // indirect

View File

@ -106,8 +106,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dnaeon/go-vcr v1.0.1 h1:r8L/HqC0Hje5AXMu1ooW8oyQyOFv4GxqpL0nRP7SLLY=
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE=
github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
@ -283,6 +283,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=

697
vendor/modules.txt vendored

File diff suppressed because it is too large Load Diff