This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
field "TypeMeta" not allowed in closed struct #439
Unanswered
errordeveloper
asked this question in
General
Replies: 1 comment
-
This discussion has been migrated to cue-lang/cue#439. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have am using CUE in a Kubernetes operator, I am trying to pass my API type to CUE, and seeing this error:
My template looks like this:
The generated CUE types look like this:
I tried changing the type definition by removing
metav1.TypeMeta
, and the error I got was this:I figured I'd try adding default values in my CUE tempate:
That worked. I then added
metav1.TypeMeta
back and all works now.I don't really understand why is this happening, could someone explain? What can I do to avoid having default values in the template?
I am pretty sure that
TypeMeta
error is a misleading actually, it only seems happens when an optional value has no default.Here is a more elegant work-around:
I have a separate
Fill
call that setsdefaults
, it still usesv1alpha1.MyType
, but somehow not having the type declared in the template makes it work. Albeit, as soon as one of the fields is not set indefaults
, I get myTypeMeta
error back again.Beta Was this translation helpful? Give feedback.
All reactions