Skip to content

Instantly share code, notes, and snippets.

@dims
Last active May 20, 2025 14:38
Show Gist options
  • Save dims/c0857b86441442b15852a4c2355db130 to your computer and use it in GitHub Desktop.
Save dims/c0857b86441442b15852a4c2355db130 to your computer and use it in GitHub Desktop.
[DEPRECATED] Python script to compute updates to the Kubernetes go.mod to see how far we are behind latest in vendored repos

Generated on May 16, 2025

Package Current Latest URL
cel.dev/expr v0.23.1 v0.24.0 https://cel.dev/expr/compare/v0.23.1...v0.24.0
github.com/Azure/go-ansiterm 306776ec8161 faa5f7b0171c https://github.com/Azure/go-ansiterm/compare/306776ec8161...faa5f7b0171c
github.com/antlr4-go/antlr/v4 v4.13.0 v4.13.1 https://github.com/antlr4-go/antlr/v4/compare/v4.13.0...v4.13.1
github.com/chai2010/gettext-go v1.0.2 v1.0.3 https://github.com/chai2010/gettext-go/compare/v1.0.2...v1.0.3
github.com/container-storage-interface/spec v1.9.0 v1.11.0 https://github.com/container-storage-interface/spec/compare/v1.9.0...v1.11.0
github.com/containerd/containerd/api v1.8.0 v1.9.0 https://github.com/containerd/containerd/api/compare/v1.8.0...v1.9.0
github.com/containerd/ttrpc v1.2.6 v1.2.7 https://github.com/containerd/ttrpc/compare/v1.2.6...v1.2.7
github.com/containerd/typeurl/v2 v2.2.2 v2.2.3 https://github.com/containerd/typeurl/v2/compare/v2.2.2...v2.2.3
github.com/cpuguy83/go-md2man/v2 v2.0.4 v2.0.7 https://github.com/cpuguy83/go-md2man/v2/compare/v2.0.4...v2.0.7
github.com/emicklei/go-restful/v3 v3.11.0 v3.12.2 https://github.com/emicklei/go-restful/v3/compare/v3.11.0...v3.12.2
github.com/go-errors/errors v1.4.2 v1.5.1 https://github.com/go-errors/errors/compare/v1.4.2...v1.5.1
github.com/go-openapi/jsonpointer v0.21.0 v0.21.1 https://github.com/go-openapi/jsonpointer/compare/v0.21.0...v0.21.1
github.com/go-openapi/jsonreference v0.20.2 v0.21.0 https://github.com/go-openapi/jsonreference/compare/v0.20.2...v0.21.0
github.com/go-openapi/swag v0.23.0 v0.23.1 https://github.com/go-openapi/swag/compare/v0.23.0...v0.23.1
github.com/google/pprof d1b30febd7db c0086092b71a https://github.com/google/pprof/compare/d1b30febd7db...c0086092b71a
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.0 v2.3.2 https://github.com/grpc-ecosystem/go-grpc-middleware/v2/compare/v2.3.0...v2.3.2
github.com/ishidawataru/sctp 7ff4192f6ff2 53eab83c1cf6 https://github.com/ishidawataru/sctp/compare/7ff4192f6ff2...53eab83c1cf6
github.com/libopenstorage/openstorage v1.0.0 v9.4.47 https://github.com/libopenstorage/openstorage/compare/v1.0.0...v9.4.47
github.com/mailru/easyjson v0.7.7 v0.9.0 https://github.com/mailru/easyjson/compare/v0.7.7...v0.9.0
github.com/moby/term v0.5.0 v0.5.2 https://github.com/moby/term/compare/v0.5.0...v0.5.2
github.com/onsi/ginkgo/v2 v2.21.0 v2.23.4 https://github.com/onsi/ginkgo/v2/compare/v2.21.0...v2.23.4
github.com/onsi/gomega v1.35.1 v1.37.0 https://github.com/onsi/gomega/compare/v1.35.1...v1.37.0
github.com/opencontainers/cgroups v0.0.1 v0.0.2 https://github.com/opencontainers/cgroups/compare/v0.0.1...v0.0.2
github.com/opencontainers/runtime-spec v1.2.0 v1.2.1 https://github.com/opencontainers/runtime-spec/compare/v1.2.0...v1.2.1
github.com/opencontainers/selinux v1.11.1 v1.12.0 https://github.com/opencontainers/selinux/compare/v1.11.1...v1.12.0
github.com/pquerna/cachecontrol v0.1.0 v0.2.0 https://github.com/pquerna/cachecontrol/compare/v0.1.0...v0.2.0
github.com/prometheus/client_model v0.6.1 v0.6.2 https://github.com/prometheus/client_model/compare/v0.6.1...v0.6.2
github.com/prometheus/common v0.62.0 v0.64.0 https://github.com/prometheus/common/compare/v0.62.0...v0.64.0
github.com/prometheus/procfs v0.15.1 v0.16.1 https://github.com/prometheus/procfs/compare/v0.15.1...v0.16.1
github.com/spf13/cobra v1.8.1 v1.9.1 https://github.com/spf13/cobra/compare/v1.8.1...v1.9.1
github.com/vishvananda/netlink 62fb240731fa v1.3.1 https://github.com/vishvananda/netlink/compare/62fb240731fa...v1.3.1
github.com/vishvananda/netns v0.0.4 v0.0.5 https://github.com/vishvananda/netns/compare/v0.0.4...v0.0.5
go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful v0.44.0 v0.60.0 https://github.com/open-telemetry/opentelemetry-go-contrib/compare/instrumentation/github.com/emicklei/go-restful/otelrestful/v0.44.0...instrumentation/github.com/emicklei/go-restful/otelrestful/v0.60.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 v0.60.0 https://github.com/open-telemetry/opentelemetry-go-contrib/compare/instrumentation/google.golang.org/grpc/otelgrpc/v0.59.0...instrumentation/google.golang.org/grpc/otelgrpc/v0.60.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 v0.60.0 https://github.com/open-telemetry/opentelemetry-go-contrib/compare/instrumentation/net/http/otelhttp/v0.58.0...instrumentation/net/http/otelhttp/v0.60.0
go.opentelemetry.io/otel v1.34.0 v1.35.0 https://github.com/open-telemetry/opentelemetry-go/compare/v1.34.0...v1.35.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 v1.35.0 https://github.com/open-telemetry/opentelemetry-go/compare/exporters/otlp/otlptrace/v1.34.0...exporters/otlp/otlptrace/v1.35.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0 v1.35.0 https://github.com/open-telemetry/opentelemetry-go/compare/exporters/otlp/otlptrace/otlptracegrpc/v1.34.0...exporters/otlp/otlptrace/otlptracegrpc/v1.35.0
go.opentelemetry.io/otel/metric v1.34.0 v1.35.0 https://github.com/open-telemetry/opentelemetry-go/compare/metric/v1.34.0...metric/v1.35.0
go.opentelemetry.io/otel/sdk v1.34.0 v1.35.0 https://github.com/open-telemetry/opentelemetry-go/compare/sdk/v1.34.0...sdk/v1.35.0
go.opentelemetry.io/otel/trace v1.34.0 v1.35.0 https://github.com/open-telemetry/opentelemetry-go/compare/trace/v1.34.0...trace/v1.35.0
go.opentelemetry.io/proto/otlp v1.5.0 v1.6.0 https://github.com/open-telemetry/opentelemetry-proto-go/compare/otlp/v1.5.0...otlp/v1.6.0
golang.org/x/crypto v0.36.0 v0.38.0 https://github.com/golang/crypto/compare/v0.36.0...v0.38.0
golang.org/x/exp 8a7402abbf56 ce4c2cf36ca6 https://github.com/golang/exp/compare/8a7402abbf56...ce4c2cf36ca6
golang.org/x/mod v0.21.0 v0.24.0 https://github.com/golang/mod/compare/v0.21.0...v0.24.0
golang.org/x/net v0.38.0 v0.40.0 https://github.com/golang/net/compare/v0.38.0...v0.40.0
golang.org/x/oauth2 v0.27.0 v0.30.0 https://github.com/golang/oauth2/compare/v0.27.0...v0.30.0
golang.org/x/sync v0.12.0 v0.14.0 https://github.com/golang/sync/compare/v0.12.0...v0.14.0
golang.org/x/sys v0.31.0 v0.33.0 https://github.com/golang/sys/compare/v0.31.0...v0.33.0
golang.org/x/term v0.30.0 v0.32.0 https://github.com/golang/term/compare/v0.30.0...v0.32.0
golang.org/x/text v0.23.0 v0.25.0 https://github.com/golang/text/compare/v0.23.0...v0.25.0
golang.org/x/time v0.9.0 v0.11.0 https://github.com/golang/time/compare/v0.9.0...v0.11.0
golang.org/x/tools v0.26.0 v0.33.0 https://github.com/golang/tools/compare/v0.26.0...v0.33.0
google.golang.org/genproto/googleapis/api a0af3efb3deb 5a2f75b736a9 https://github.com/googleapis/go-genproto/compare/a0af3efb3deb...5a2f75b736a9
google.golang.org/genproto/googleapis/rpc a0af3efb3deb 5a2f75b736a9 https://github.com/googleapis/go-genproto/compare/a0af3efb3deb...5a2f75b736a9
google.golang.org/grpc v1.71.1 v1.72.1 https://github.com/protocolbuffers/protobuf-go/compare/v1.71.1...v1.72.1
google.golang.org/protobuf v1.36.5 v1.36.6 https://github.com/protocolbuffers/protobuf-go/compare/v1.36.5...v1.36.6
sigs.k8s.io/json 9aa6b5e7a4b3 cfa47c3a1cc8 https://sigs.k8s.io/json/compare/9aa6b5e7a4b3...cfa47c3a1cc8
#!/usr/bin/python
import json
import subprocess
import logging
import os
def get_dependencies():
dependencies = {}
f = subprocess.Popen('go mod edit -json', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
(stdout, stderr) = f.communicate()
if stderr:
logging.fatal(stderr)
data = json.loads(stdout)
for dep in data["Require"]:
if dep['Path'].startswith("k8s.io/") != -1:
dependencies[dep['Path']] = dep['Version']
return dependencies
def sanitize(param):
# v0.0.0-20190331200053-3d26580ed485
if param.count('-') == 2:
return param.split('-')[-1]
# v11.1.2+incompatible
if param.count('+') == 1:
return param.split('+')[0]
return param
def source(pkg, old, new):
if pkg.startswith("cloud.google.com/go"):
return "github.com/googleapis/google-cloud-go", old, new
elif pkg.startswith("golang.org/x/"):
return "github.com/golang" + pkg[len("golang.org/x"):], old, new
elif pkg.startswith("go.uber.org/"):
return "github.com/uber-go" + pkg[len("go.uber.org"):], old, new
elif pkg.startswith("go.starlark.net"):
return "github.com/google/starlark-go", old, new
elif pkg.startswith("gopkg.in"):
repo = pkg.split('/', 1)[1] # get the last part of `gopkg.in/gcfg.v1` which is `gcfg.v1`
repo = repo.split('.', 1)[0] # get the part before the `.` which is `gcfg`
# we could end up with `gcfg` or `square/go-jose` here, deal with them separately
if '/' not in repo:
repo = "github.com/go-" + repo + "/" + repo
else:
repo = "github.com/" + repo
return repo, old, new
elif pkg.startswith("google.golang.org"):
array = pkg.split('/', 2)
if array[1] == "api":
repo = "github.com/googleapis/google-api-go-client"
elif array[1] == "genproto":
repo = "github.com/googleapis/go-genproto"
else: # repo = "protobuf"
repo = "github.com/protocolbuffers/protobuf-go"
return repo, old, new
elif pkg.startswith("go.opentelemetry.io/"):
array = pkg.split('/', 2)
if array[1] == "contrib":
repo = "github.com/open-telemetry/opentelemetry-go-contrib"
elif array[1] == "proto":
repo = "github.com/open-telemetry/opentelemetry-proto-go"
else: # repo = "otel"
repo = "github.com/open-telemetry/opentelemetry-go"
if len(array) > 2:
path = array[2] + "/"
else:
path = ""
return repo, path + old, path + new
return pkg, old, new
def main():
cleanup_command = """git reset --hard HEAD"""
print(">>>> Running command %r" % cleanup_command)
os.system(cleanup_command)
print(">>>> parsing go.mod before updates")
before = get_dependencies()
print("Found %d packages before updating dependencies" % len(before.values()))
update_command = """\
go mod edit -json | jq -r ".Require[] | .Path | select(contains(\\"k8s.io/\\") | not)" | xargs -L1 go get -d\
"""
print(">>>> Running command %r" % update_command)
os.system(update_command)
print(">>>> parsing go.mod after updates")
after = get_dependencies()
print("Found %d packages after updating dependencies" % len(before.values()))
print(">>>> Packages that got dropped %r" % (list(set(before.keys()) - set(after.keys()))))
print(">>>> Packages that were added %r" % (list(set(after.keys()) - set(before.keys()))))
print(">>>>> Mark down of differences <<<<")
print("Package | Current | Latest | URL")
print("------------ | ------------- | ------------- |------------- ")
for pkg in sorted(before.keys()):
if pkg.startswith("k8s.io"):
continue
old = sanitize(before[pkg])
if pkg not in after:
print("~%s~ | %s | Dropped | NONE" % (pkg, old))
continue
new = sanitize(after[pkg])
repo, oldtag, newtag = source(pkg, old, new)
if old != new:
print("%s | %s | %s | https://%s/compare/%s...%s " % (pkg, old, new, repo, oldtag, newtag))
else:
print("~%s~ | %s | %s | No changes" % (pkg, old, new))
if __name__ == "__main__":
main()
@dims
Copy link
Author

dims commented May 20, 2025

This gist is deprecated! please see comment here - kubernetes/kubernetes#131839 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment