无法找到来自k8s.io/client-go的’fake’包。

huangapple go评论84阅读模式
英文:

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

问题

我在我的go.mod文件中有以下依赖项:

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

我删除了整个vendor文件夹,并尝试通过以下方式更新依赖项:

    go mod tidy 
    go mod vendor

但是从下面的图片中可以看出,fake仍然不存在:

无法找到来自k8s.io/client-go的’fake’包。

此外,从这里我可以看到'fake'包是存在的- https://github.com/kubernetes/client-go/tree/master/kubernetes

英文:

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:

无法找到来自k8s.io/client-go的’fake’包。

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

答案1

得分: 1

只需添加一个空白的导入语句,如下所示:

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

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

然后执行以下命令:

go mod vendor

你将看到期望的文件夹结构:

> ls vendor/k8s.io/client-go/kubernetes/
clientset.go doc.go       fake         import.go    scheme       typed
英文:

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


</details>



huangapple
  • 本文由 发表于 2022年1月5日 22:19:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/70594445.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定