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

cmd "kubebuilder create api" failed when hits "core" keyword #342

Closed
interma opened this issue Aug 1, 2018 · 6 comments
Closed

cmd "kubebuilder create api" failed when hits "core" keyword #342

interma opened this issue Aug 1, 2018 · 6 comments
Milestone

Comments

@interma
Copy link
Contributor

interma commented Aug 1, 2018

Executed the following cmd:

$ ~/go/bin/kubebuilder_dir/kubebuilder init --domain hawq.org --license apache2 --owner "The HAWQ team Authors"
# successfully

$ ~/go/bin/kubebuilder_dir/kubebuilder create api --group core --version v1alpha1 --kind MyResource
Create Resource under pkg/apis [y/n]?
y
Create Controller under pkg/controller [y/n]?
y
Writing scaffold for you to edit...
pkg/apis/core/v1alpha1/myresource_types.go
pkg/apis/core/v1alpha1/myresource_types_test.go
pkg/controller/myresource/myresource_controller.go
pkg/controller/myresource/myresource_controller_test.go
Running make...
go generate ./pkg/... ./cmd/...
go fmt ./pkg/... ./cmd/...
go vet ./pkg/... ./cmd/...
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
CRD manifests generated under '/Users/hma/go/src/github.com/hawq-cn/apicrd-example/config/crds'
RBAC manifests generated under '/Users/hma/go/src/github.com/hawq-cn/apicrd-example/config/rbac'
go test ./pkg/... ./cmd/... -coverprofile cover.out
pkg/controller/myresource/myresource_controller.go:26:2: cannot find package "k8s.io/api/core/v1alpha1" in any of:
     /Users/hma/go/src/github.com/hawq-cn/apicrd-example/vendor/k8s.io/api/core/v1alpha1 (vendor tree)
     /usr/local/Cellar/go/1.9.2/libexec/src/k8s.io/api/core/v1alpha1 (from $GOROOT)
     /Users/hma/go/src/k8s.io/api/core/v1alpha1 (from $GOPATH)
make: *** [test] Error 1
2018/08/01 11:22:30 exit status 2

refer myresource_controller.go, there is an error import:

package myresource

import (
    "context"
    "log"
    "reflect"

    appsv1 "k8s.io/api/apps/v1"
    corev1 "k8s.io/api/core/v1"
    corev1alpha1 "k8s.io/api/core/v1alpha1" # <-- this line
#...
)

This error import cause the following go test failed.

@interma
Copy link
Contributor Author

interma commented Aug 1, 2018

I refered controller-tools code:
https://github.com/kubernetes-sigs/controller-tools/blob/master/pkg/scaffold/controller/controller.go#L57
Looks like this line caused this error? When choosing these keywords as api group, this error happens.

I think give user a warning when they chose the "keyword" group is better, or fix this .

@interma
Copy link
Contributor Author

interma commented Aug 1, 2018

and looks duplicate with #335

@droot
Copy link
Contributor

droot commented Aug 1, 2018

Thanks for adding more details (especially pointing the code where bug exists :))
Yes, this is a duplicate of #335
We can improve the detection of the core types using full GVK instead of just the group. @fanzhangio if you haven't started on the fix for #335 , I can work on it.

@droot droot added this to the v1.0.1 milestone Aug 1, 2018
@fanzhangio
Copy link

fanzhangio commented Aug 1, 2018

There should be a mechanism for coordinating core group domain and user-defined domain in scaffold controller. I identified the root cause in scaffold.

@interma
Copy link
Contributor Author

interma commented Aug 2, 2018

Thanks @droot @fanzhangio
Kubebuilder is a cool tool, glad to improve it.

@droot
Copy link
Contributor

droot commented Aug 6, 2018

This should be fixed with #343

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants