Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update golang version and kube-builder #2991

Closed
quentinalbertone opened this issue Oct 3, 2022 · 3 comments
Closed

Update golang version and kube-builder #2991

quentinalbertone opened this issue Oct 3, 2022 · 3 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@quentinalbertone
Copy link

What broke? What's expected?

Hi
I recently updated golang on my computer from 1.17 to 1.19,
during the process I also updated the version of kube-builder (I just reinstalled kubebuilder) from 3.3 to 3.7.
But now I cannot generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.

$> make generate
my_project_path/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:39:16: expected ']', found any
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:39:19: expected ';', found ']'
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:39:19: expected type, found ']'
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:45:34: expected declaration, found 'return'
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:39:16: expected ']', found any
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:39:19: expected ';', found ']'
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:39:19: expected type, found ']'
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:45:34: expected declaration, found 'return'
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:39:16: expected ']', found any
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:39:19: expected ';', found ']'
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:39:19: expected type, found ']'
/usr/local/Cellar/go/1.19.1/libexec/src/sync/atomic/type.go:45:34: expected declaration, found 'return'
Error: not all generators ran successfully
run `controller-gen object:headerFile=hack/boilerplate.go.txt paths=./... -w` to see all available markers, or `controller-gen object:headerFile=hack/boilerplate.go.txt paths=./... -h` for usage
make: *** [generate] Error 1

I suppose that it's link to this field in my struct

// +kubebuilder:validation:Optional
// +mapType:=atomic
// Specifies the node in which the capture must be deployed
// https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

I'm pretty sure everything was alright before the update but I might be wrong

Reproducing this issue

No response

KubeBuilder (CLI) Version

3.3.0

PROJECT version

v3

Plugin versions

layout:
- go.kubebuilder.io/v3

Other versions

$> go version
go version go1.19.1 darwin/amd64

Extra Labels

No response

@quentinalbertone quentinalbertone added the kind/bug Categorizes issue or PR as related to a bug. label Oct 3, 2022
@camilamacedo86
Copy link
Member

camilamacedo86 commented Oct 5, 2022

That is probably because of the controller-gen version used.
You are now using the latest version of the CLI but your project was scaffolded using old versions.
I would recommend you upgrade the controller-gen version used (see your Makefile file) as they go.mod deps as you can check in the samples for the tag used, see:

If the above does not sort out your problem we will need further info (all steps and versions) to reproduce your issue so that we can check and see how that can be solved.

@camilamacedo86 camilamacedo86 added the triage/needs-information Indicates an issue needs more information in order to work on it. label Oct 5, 2022
@quentinalbertone
Copy link
Author

Thanks I copy past the makefile as well as the go.mod a little go mod tidyand delete the bin directory and it works fine now.

I think it could be a good Idea to offer a way to scaffold again the project.

@camilamacedo86
Copy link
Member

Hi @quentinalbertone,

I think it could be a good Idea to offer a way to scaffold again the project.

Yes. That would be great and very desirable if we could have a solution via tooling that could update the projects. See #2068 (comment) and thought about how we could achieve that.

We also have the PR (WIP): https://github.com/kubernetes-sigs/kubebuilder/pull/2895/files but I am not sure if @rumstead has been able to work on it. Please, if you would like to help out please feel free to do so and also propose any other solution that you see for us to achieve this goal.

Regards this issue, I think we could address the need and I am closing this one. However, feel free to re-open if you see that would be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

2 participants