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

Failed making a parser #55

Closed
asdfsx opened this issue Sep 10, 2018 · 5 comments
Closed

Failed making a parser #55

asdfsx opened this issue Sep 10, 2018 · 5 comments

Comments

@asdfsx
Copy link

asdfsx commented Sep 10, 2018

I'm trying to create a brand new apiserver using code-generator. So I create an empty golang project, and add this project into vendor

mkdir ${GOPATH}/src/github.com/asdfsx/getkubeconfig
cd ${GOPATH}/src/github.com/asdfsx/getkubeconfig
glide init
glide get k8s.io/code-generator#kubernetes-1.11.3

then I try to generator the code as follow

vendor/k8s.io/code-generator/generate-groups.sh \
all \
github.com/asdfsx/getkubeconfig/pkg/client \
github.com/asdfsx/getkubeconfig/pkg/apis \
example:v1

but got the error

Generating deepcopy funcs
F0910 19:18:35.552948   12153 main.go:81] Error: Failed making a parser: unable to add directory "github.com/asdfsx/getkubeconfig/pkg/apis/example/v1": unable to import "github.com/asdfsx/getkubeconfig/pkg/apis/example/v1": cannot find package "github.com/asdfsx/getkubeconfig/pkg/apis/example/v1" in any of:
        /Users/sunxia/gocode/src/github.com/asdfsx/getkubeconfig/vendor/github.com/asdfsx/getkubeconfig/pkg/apis/example/v1 (vendor tree)
        /usr/local/opt/go/libexec/src/github.com/asdfsx/getkubeconfig/pkg/apis/example/v1 (from $GOROOT)
        /Users/sunxia/gocode/src/github.com/asdfsx/getkubeconfig/pkg/apis/example/v1 (from $GOPATH)

and if I create the direcotry /Users/sunxia/gocode/src/github.com/asdfsx/getkubeconfig/pkg/apis/example/v1 then the error change to

Generating deepcopy funcs
F0910 19:19:51.352507   12172 main.go:81] Error: Failed making a parser: unable to add directory "github.com/asdfsx/getkubeconfig/pkg/apis/example/v1": No files for pkg "github.com/asdfsx/getkubeconfig/pkg/apis/example/v1": map[parser.importPathString][]parser.parsedFile{}

Can someone tell me what's going wrong? thx a lot!

@asdfsx
Copy link
Author

asdfsx commented Sep 11, 2018

I solved the problem ,by following this article.
This is a silly question, I close it

@asdfsx asdfsx closed this as completed Sep 11, 2018
@yueyongyue
Copy link

yueyongyue commented Oct 14, 2019

@asdfsx What was done ? export GO111MODULE=off ?

@asdfsx
Copy link
Author

asdfsx commented Oct 31, 2019

@yueyongyue I don't think so~I've forget the detail.
But I think the problem is codegenerator can not generate codes from an empty project.
You should add type definitions , and use comments like // +genclient to config the generator.
Then you can use generator to generate codes

@BlackKD
Copy link

BlackKD commented Mar 22, 2020

I solved the problem ,by following this
#99

@satr
Copy link

satr commented Oct 18, 2022

Fixed similar issue with a symbolic link.

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

4 participants