Kubebuilder: zap.LoggerTo in generated suite_test.go doesn't exist in controller-runtime

Created on 11 Nov 2020  路  1Comment  路  Source: kubernetes-sigs/kubebuilder

What broke (please include exact error messages if you can)
When I ran kubebuilder create api and generated resources and controller code, it created a file controllers/suite_test.go. Inside this file, there are the following lines of generated code.

var _ = BeforeSuite(func(done Done) {
    logf.SetLogger(zap.LoggerTo(GinkgoWriter, true))
...

In the latest version of controller-runtime (v0.7.0-alpha.6), there is no LoggerTo in the zap pkg: https://github.com/kubernetes-sigs/controller-runtime/blob/v0.7.0-alpha.6/pkg/log/zap/zap.go

What did you expect to happen? What do you think went wrong?
Expected generated code to compile correctly with correct logger references.

What versions of software are you using? Specifically, the following are often useful:

  • go version
    > go version go1.13.14 darwin/amd64
  • kubebuilder version (kubebuilder version) and scaffolding version (check your PROJECT file)
    > kubebuilder version: Version: version.Version{KubeBuilderVersion:"2.3.1", KubernetesVendor:"1.16.4", GitCommit:"8b53abeb4280186e494b726edf8f54ca7aa64a49", BuildDate:"2020-03-26T16:42:00Z", GoOs:"unknown", GoArch:"unknown"}
    Scaffolding version in PROJECT file: version: "2"
  • controller-runtime version (check your go.mod file)
    > v0.7.0-alpha.6
  • controller-tools version
    > N/A
  • Kubernetes & kubectl versions (just run kubectl version against your API server)
    >
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.2", GitCommit:"f5743093fd1c663cb0cbc89748f730662345d44d", GitTreeState:"clean", BuildDate:"2020-09-16T21:51:49Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.1", GitCommit:"206bcadf021e76c27513500ca24182692aabd17e", GitTreeState:"clean", BuildDate:"2020-09-14T07:30:52Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}

/kind bug

kinbug

Most helpful comment

Hi @wfernandes,

The version which is scaffolded by KubeBuilderVersion:"2.3.1" is not using the v0.7.0-alpha.6. The only v3-alpha plugin uses that. See the doc: https://book.kubebuilder.io/quick-start.html#versions-and-supportability

Screen Shot 2020-11-11 at 21 00 22

And then, you can check here that the scaffolded changed for 0.7.0 already, See: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v3/controllers/suite_test.go#L53. To try out the v3-alpha plugin you need to:

  • Use kubebuilder from master branch (it is not released yet)
  • Create projects with the go/v3-alpha plugin via kubebuilder init --plugins=go/v3-alpha

In this way, I am closing this as sorted out. However, feel free to ping us if you need or think that it should be re-opened.

>All comments

Hi @wfernandes,

The version which is scaffolded by KubeBuilderVersion:"2.3.1" is not using the v0.7.0-alpha.6. The only v3-alpha plugin uses that. See the doc: https://book.kubebuilder.io/quick-start.html#versions-and-supportability

Screen Shot 2020-11-11 at 21 00 22

And then, you can check here that the scaffolded changed for 0.7.0 already, See: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v3/controllers/suite_test.go#L53. To try out the v3-alpha plugin you need to:

  • Use kubebuilder from master branch (it is not released yet)
  • Create projects with the go/v3-alpha plugin via kubebuilder init --plugins=go/v3-alpha

In this way, I am closing this as sorted out. However, feel free to ping us if you need or think that it should be re-opened.

Was this page helpful?
0 / 5 - 0 ratings