Cannot find 'fake' package from k8s.io/client-go

1/5/2022

I have the dependency in my go.mod file like below:

    require ( 
       ...
       k8s.io/client-go v0.23.1
    )

I deleted the entire vendor folder and tried updating the dependencies like this:

    go mod tidy 
    go mod vendor

But still fake is not present as can be seen from the pic below:

Vendor content of k8s.io

Also from here i can see that the 'fake' pkg is present - https://github.com/kubernetes/client-go/tree/master/kubernetes

-- Калоян Ников
client-go
dependency-management
go
kubernetes

1 Answer

1/5/2022

just add a blank import statement like:

import (
	_ "k8s.io/client-go/kubernetes/fake"

	"k8s.io/client-go/discovery"
)

and execute the command

go mod vendor

and you will see the expected folder

>ls vendor/k8s.io/client-go/kubernetes/
clientset.go doc.go       fake         import.go    scheme       typed
-- Matteo
Source: StackOverflow