cue.dev/x/k8s.io@v0.12.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 your
 6// external, versioned struct, and Object in your internal struct. You also
 7// 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 the serialized
43// data into your external MyAPIObject. That causes the raw JSON to be stored,
44// but not unpacked. The next step is to copy (using pkg/conversion) into the
45// internal struct. The runtime package's DefaultScheme has conversion
46// functions installed which will unpack the JSON stored in RawExtension,
47// turning it into the correct object type, and storing it in the Object.
48// (TODO: In the case where the object is of an unknown type, a runtime.Unknown
49// object will be created and stored.)
50#RawExtension: {}