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

conflicting types in allOf branches in schema: string vs object #533

Closed
mjaow opened this issue Dec 7, 2020 · 9 comments · Fixed by knative/pkg#2104
Closed

conflicting types in allOf branches in schema: string vs object #533

mjaow opened this issue Dec 7, 2020 · 9 comments · Fixed by knative/pkg#2104
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@mjaow
Copy link

mjaow commented Dec 7, 2020

When I'm trying to use the Conditions type from knative


import	"knative.dev/pkg/apis"

type MyStruct struct{
     Conditions apis.Conditions `json:"conditions,omitempty"
}

apis.Conditions has a field with type VolatileTime

type Condition struct{
      LastTransitionTime VolatileTime `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"`
}

type VolatileTime struct {
	Inner metav1.Time `json:",inline"`
}

then I run controller-gen crd:trivialVersions=true crd:crdVersions="v1beta1" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases,

it will faied with conflicting types in allOf branches in schema: string vs object.

From error message, I guess it's type error for VolatileTime, so I'm trying to figure a way to overrides the type for this field LastTransitionTime . But I can't do it as it's a field in knative

Does anyone know how to deal with it?

@nitishkrishna
Copy link

I am getting the same exact error, my types.go has:

// Template wraps a json.RawMessage
// +kubebuilder:validation:Type=object
type TemplateSpec struct {
	json.RawMessage `json:",inline"`
}

@nitishkrishna
Copy link

nitishkrishna commented Dec 8, 2020

I fixed my issue by moving to this release of controller-tools: v0.4.1-0.20200821122629-1dc8cc4f84c8

-       _ "sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1"
+       _ "sigs.k8s.io/controller-tools/cmd/controller-gen@1dc8cc4f84c85b8f90aa58a87cbb768000f3518c"

@mjaow
Copy link
Author

mjaow commented Dec 9, 2020

look similar, but seems a different one. I think you fixed it due to v0.4.1-0.20200821122629-1dc8cc4f84c8 will generate an any type instead of object, any type has no conflict with string. So it will work in v0.4.0 also at your scenerio @nitishkrishna

I can also generate an any type with v0.4.0, but will fail when apply to k8s, as k8s doesn't support any type

ref #505

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 9, 2021
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Apr 8, 2021
@markusthoemmes
Copy link
Contributor

@mjaow this should now be fixed via the PR referenced above.

@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-contributor-experience at kubernetes/community.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-contributor-experience at kubernetes/community.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@aybansal-sudo
Copy link

i am facing a similar issue
conflicting types in allOf branches in schema: string vs object
Error: not all generators ran successfully
my types.go file has
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Type=object
RequestPayload json.RawMessage json:"requestPayload"

after running controller-gen "crd:crdVersions={v1},trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
it failed with: conflicting types in allOf branches in schema: string vs object
Error: not all generators ran successfully.
Any ideas on how to proceed with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants