Go k8s client overriding v11.0.0+incompatible dependency?

11/17/2020

This is my Go project/module, I'm compiling with Go 1.15.4:

module xxx.com/xxx/xxx

go 1.13

replace (
	k8s.io/api => k8s.io/api v0.19.0
	k8s.io/apimachinery => k8s.io/apimachinery v0.19.0
	k8s.io/client-go => k8s.io/client-go v0.19.0
)

require (
	github.com/gorilla/websocket v1.4.2
	github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
	github.com/sirupsen/logrus v1.7.0
	github.com/spf13/cobra v1.1.1
	github.com/thediveo/klo v1.0.0
	github.com/x-cray/logrus-prefixed-formatter v0.5.2
	gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
	k8s.io/client-go v11.0.0+incompatible
)

I've placed replacement definition in order to use the (recent as of this writing) version 1.19.0 of the Kubernetes Go client packages.

When compiling, the Go tools always add a require for k8s.io/client-go v11.0.0+incompatible. Even if I manually change it to be k8s.io/client-go v0.19.0 it gets reverted on the next build.

  • can someone please explain why the v11.0.0+incompatible version keeps coming back (due to some dependency of a dependency)?
  • how to fix this?
-- TheDiveO
client
go
kubernetes

1 Answer

11/17/2020

You can use

go mod why <modulename>

For example in your case

go mod why k8s.io/client-go v11.0.0+incompatible

This will tell you who is using this module

-- Shubham Srivastava
Source: StackOverflow