-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Shared API types: Hit an unsupported type invalid type for invalid type #2619
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
Comments
it is caused because of an error in your local env. You need to set the go env GOROOT. See: The GOROOT environment variable point to the directory where the go which should be used is installed. In this way, I understand that usually, you don’t need to set $GOROOT variable. However, you may face issues in some scenarios. For example; if you have more than one go version installed locally, or if you installed it in different locally from where was recommend or if you use homebrew to install. Just to illustrate the homebrew scenario see, for example, https://coderwall.com/p/c00m1g/set-goroot-variable-with-homebre Duplication of many:
Closing as sorted out. |
Could this have a different cause than those other issues?
I also tried running |
Are you able to create a new project from scratch as described in the docs?
if yes, then the problem is in the implementation of your _type.go which has an invalid type defined. Please, let us know if it worked for you.
If you still unable to check what is invalid could you please add here this spec definition? Also, see that SDK latest version is 0.15.2 and I'd like to recommend you upgrade your project and local env to use it. If not, then the problem is in your local env. Note that if you used the brew formula you will probably need to do some setups manually in your env. |
Following your instructions I was able to pinpoint the problem.
This makes it fail using latest operator-sdk So it seems that cyclic imports between versioned and non-versioned sibling packages is causing the problem. |
Hi @german-muzquiz, Thank you for you let us know that you find the issue in your code impl. Btw, the So, please, let us know if we can close this one or if you are still needing help with your impl. If yes, could you please let us know what is your scenario and what you are trying to achieve with? Why ar are you adding it in the _types? |
The goal is to be able to add new CRD versions in a maintainable way (v1beta1, v1beta2, etc.). In the current implementation, all the code is importing versioned packages:
Every time we increase the version, a lot of code would be impacted. To avoid this, I'm trying to create a set of version agnostic interfaces in a shared package, and make all the I tried to make a factory struct in the shared package to instantiate versioned types, but I can achieve a similar goal just making the types register themselves into the shared package, so I can workaround the error. I'd love to have better error messages though, or better documentation on what can or cannot be done regarding shared packages. So far I can workaround the issue. |
HI @german-muzquiz, I am not sure if I properly follow up your solution. Anyway, shows that we could identify that it is related to invalid type/definitions implemented in the code. Also, I'd like to recommend you check the k8s doc Versions in CustomResourceDefinitions as Migrating Existing Kubernetes APIs to understand how is recommend migrate the APIs. And then, in the case of you are using OLM the doc How do operator upgrades work in Operator Lifecycle Manager (OLM)?. I hope that it helps you with. Also, not that each API will have one version and would be one import and then you might need to allow your project to be able to work with more than one version. So, shows that all is sorted out and we can close this one. However, please feel free to ping and ask to re-open it if you see that something still required to be clarified over this matter. |
Bug Report
What did you do?
I have an existing project using operator-sdk that is working fine. Now I plan to add a new version of the API, and there are some custom types that need to be shared between all APIs. I'm following this guide: https://github.com/operator-framework/operator-sdk/blob/9a32696a3b68dc9f94acca29dd4878df0baddf9e/doc/user/migrating-existing-apis.md#copying-shared-type-definitions-and-functions-to-a-separate-package
When running
operator-sdk generate k8s
, I face the "Hit an unsupported type invalid type for invalid type" error.What did you expect to see?
Code generation completed successfully.
What did you see instead? Under which circumstances?
Environment
v0.12.0
go version go1.13.4 darwin/amd64
Kubernetes cluster kind:
Are you writing your operator in ansible, helm, or go?
go
Additional context
Add any other context about the problem here.
Basically I just moved a custom type from
_types.go
to a separate package:Returning that custom type to
v1alpha2
fixes the error.The text was updated successfully, but these errors were encountered: