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

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

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

问题

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

  1. require (
  2. ...
  3. k8s.io/client-go v0.23.1
  4. )

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

  1. go mod tidy
  2. 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:

  1. require (
  2. ...
  3. k8s.io/client-go v0.23.1
  4. )

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

  1. go mod tidy
  2. 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

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

  1. import (
  2. _ "k8s.io/client-go/kubernetes/fake"
  3. "k8s.io/client-go/discovery"
  4. )

然后执行以下命令:

  1. go mod vendor

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

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

just add a blank import statement like:

  1. import (
  2. _ "k8s.io/client-go/kubernetes/fake"
  3. "k8s.io/client-go/discovery"
  4. )

and execute the command

  1. go mod vendor

and you will see the expected folder

  1. >ls vendor/k8s.io/client-go/kubernetes/
  2. clientset.go doc.go fake import.go scheme typed
  3. </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:

确定