When working with v1alpha3.OpaqueDeviceConfiguration, parameters are handled via RawExtension. This allows the API to store raw JSON/YAML that is later unpacked into specific plugin types during conversion.
To implement this pattern in your own Go-based API extensions:
- In your external versioned struct, use
runtime.RawExtension for the field. - In your internal struct, use
runtime.Object for the same field. - Register your plugin types in the
DefaultScheme so the conversion process can unpack the RawExtension into the correct object type.
// Internal package:
type MyAPIObject struct {
runtime.TypeMeta `json:",inline"`
MyPlugin runtime.Object `json:"myPlugin"`
}
type PluginA struct {
AOption string `json:"aOption"`
}
// External package:
type MyAPIObject struct {
runtime.TypeMeta `json:",inline"`
MyPlugin runtime.RawExtension `json:"myPlugin"`
}
type PluginA struct {
AOption string `json:"aOption"`
}
// On the wire, the JSON will look something like this:
{
"kind":"MyAPIObject",
"apiVersion":"v1",
"myPlugin": {
"kind":"PluginA",
"aOption":"foo",
},
}