cue.dev/x/k8s.io@v0.7.0

apimachinery/pkg/runtime/schema.cue raw

 1package runtime
 2
 3// RawExtension is used to hold extensions in external versions.
 4//
 5// To use this, make a field which has RawExtension as its type in
 6// your external, versioned struct, and Object in your internal
 7// struct. You also need to register your various plugin types.
 8//
 9// // Internal package:
10//
11// type MyAPIObject struct {
12// runtime.TypeMeta `json:",inline"`
13// MyPlugin runtime.Object `json:"myPlugin"`
14// }
15//
16// type PluginA struct {
17// AOption string `json:"aOption"`
18// }
19//
20// // External package:
21//
22// type MyAPIObject struct {
23// runtime.TypeMeta `json:",inline"`
24// MyPlugin runtime.RawExtension `json:"myPlugin"`
25// }
26//
27// type PluginA struct {
28// AOption string `json:"aOption"`
29// }
30//
31// // On the wire, the JSON will look something like this:
32//
33// {
34// "kind":"MyAPIObject",
35// "apiVersion":"v1",
36// "myPlugin": {
37// "kind":"PluginA",
38// "aOption":"foo",
39// },
40// }
41//
42// So what happens? Decode first uses json or yaml to unmarshal
43// the serialized data into your external MyAPIObject. That
44// causes the raw JSON to be stored, but not unpacked. The next
45// step is to copy (using pkg/conversion) into the internal
46// struct. The runtime package's DefaultScheme has conversion
47// functions installed which will unpack the JSON stored in
48// RawExtension, turning it into the correct object type, and
49// storing it in the Object. (TODO: In the case where the object
50// is of an unknown type, a runtime.Unknown object will be
51// created and stored.)
52#RawExtension: {}