-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add support for interface member #528
Comments
It should not error-out for |
@fiftoine Could you please help me out with your test case (like an example )here? Just wanted to make sure that I'm not missing out on any information. |
So happy this issue is already open - I just ran into this myself! Are there any workarounds? @fiftoine did you get this figured out? |
@tantona Could you please provide the test case that you're using here. It would help me in debugging this issue. |
@sohankunkerkar Just declare a new type, like this:
This will lead to an error like this:
|
Adding a type alias for
to this
|
I think something like Mitchell Hashimoto's |
@andersjanmyr Thanks for the detailed analysis. I understood what's the problem here. Let me go through it and will get back to you soon. |
@sohankunkerkar I looked at it some more and to be able to add this functionality the generator has to be altered. Here's an example that works (but is far from perfect). I need to add support to all interfaces and make sure that the |
After the above change is applied, the following patch needs to be applied to
|
@andersjanmyr That's awesome. I was planning to handle this condition in the controller-tools itself. |
@sohankunkerkar How does the generated copy code look? The |
Stumbled upon this today as well. Reading the thread of comments it seems two issues are actually entangled here:
My use-case is a bit similar to the one described above, although in my case, the structure member is a Here is the code that handles the copy (maybe helpful to other people): // +k8s:deepcopy-gen=false
type ExtraFields map[string]interface{}
func (in *ExtraFields) DeepCopyInto(out *ExtraFields) {
if in == nil {
*out = nil
} else {
*out = runtime.DeepCopyJSON(*in)
}
}
func (in *ExtraFields) DeepCopy() *ExtraFields {
if in == nil {
return nil
}
out := new(ExtraFields)
in.DeepCopyInto(out)
return out
} |
@j-vizcaino Could you provide your feedback over here? |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
this should have been fixed in the latest release of CT, IIRC |
I'm using version type DeploymentTargetSpec struct {
DeploymentPatchSet []interface{} `json:"deploymentPatchSet"`
} Seeing the error message:
Is there something I'm still doing wrong? It's also worth noting that this happens without the |
no fixed in master. @DirectXMan12 same problem: |
I've replied on the equivalent controller-tools issue. Please direct all comments there. |
I've locked this in the hopes that we can keep discussion in one place, not to discourage filing of issues. In general, generation issues should be discussed in the controller-tools repo. |
Hi,
I have a resource type that has a interface{} type.
When running
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd
I get an error :Actually, This field could contain string or int or bool but I don't want to create a IntOrStringOrBool type. Is there a workaround or is it a bug?
Thanks
The text was updated successfully, but these errors were encountered: