Closed kevdowney closed 2 years ago
kubebuilder version is too high,golang version v1.16+ (kubebuilder v3.1 < v3.3).
It works today w/ go1.17.7 darwin/amd64
kubebuilder init --domain my.domain --repo my.domain/guestbook
Writing kustomize manifests for you to edit...
Writing scaffold for you to edit...
Get controller runtime:
$ go get sigs.k8s.io/controller-runtime@v0.10.0
Update dependencies:
$ go mod tidy
Next: define a resource with:
$ kubebuilder create api
I did try this using go1.17 the other day it failed w/ the same error but I noticed today that it used sigs.k8s.io/controller-runtime@v0.10.0
and before it was using sigs.k8s.io/controller-runtime@v0.11.0
.
This specific error appears to be solely related to the sigs.k8s.io/controller-runtime@v0.11.0
Old Error:
$ go get sigs.k8s.io/controller-runtime@v0.11.0
# sigs.k8s.io/json/internal/golang/encoding/json
../../go/pkg/mod/sigs.k8s.io/json@v0.0.0-20211020170558-c049b76a60c6/internal/golang/encoding/json/encode.go:1249:12: sf.IsExported undefined (type reflect.StructField has no field or method IsExported)
../../go/pkg/mod/sigs.k8s.io/json@v0.0.0-20211020170558-c049b76a60c6/internal/golang/encoding/json/encode.go:1255:18: sf.IsExported undefined (type reflect.StructField has no field or method IsExported)
Error: failed to initialize project: unable to scaffold with "base.go.kubebuilder.io/v3": exit status 2
Usage:
Hi @kevdowney,
Each KB CLI version scaffolds the deps which are compatible with:
We cannot ensure all possible combinations since breaking changes on them can be faced and we recommend you use the versions scaffolds by default always. Another recommendation is to keep your project updated with the latest changes. You can follow the upgrade guide https://book.kubebuilder.io/migrations.html to check the major ones.
However, to update the project usually, means re-scaffold the files with the CLI tool and ensuring that your code is on top of the default scaffolds. See that you can also compare the diffs looking at the samples such as kubebuilder/testdata/project-v3/.
Also, note that the go version supported is defined in the pre-requisites as well and you can check it by looking at the Kubebuilder tags in this repo and checking what go version was adopted for each release, e.g : for v3.0.0 the supported go version was 1.15. See: https://github.com/kubernetes-sigs/kubebuilder/blob/v3.0.0/go.mod#L3
In this way, these ones shows sorted out. The problems faced here was because you or not using the go version which is supported by the CLI version adopted as you did not use its dops scaffolded by default.
I hope that you do not mind if we close this one, however, also please feel free to re-open or raise new issues if you see that you need.
What broke? What's expected?
Starting a project with kubebuilder v3.3.0 fails with scaffolding error.
Go 1.16
Reproducing this issue
KubeBuilder (CLI) Version
Version: main.version{KubeBuilderVersion:"3.3.0", KubernetesVendor:"1.23.1", GitCommit:"47859bf2ebf96a64db69a2f7074ffdec7f15c1ec", BuildDate:"2022-01-18T17:03:29Z", GoOs:"darwin", GoArch:"amd64"}
PROJECT version
No response
Plugin versions
No response
Other versions
go version go1.16.14 darwin/amd64
Extra Labels
/kind regression