package kubecaml

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Raw_extension is used to hold extensions in external versions.

to use this, make a field which has Raw_extension as its type in your external, versioned struct, and Object in your internal struct. You also need to register your various plugin types.

// Internal package: type My_api_object struct { runtime.type_meta `json:",inline"` my_plugin runtime.object `json:"my_plugin"` } type Plugin_a struct { a_option string `json:"a_option"` }

// External package: type My_api_object struct { runtime.type_meta `json:",inline"` my_plugin runtime.raw_extension `json:"my_plugin"` } type Plugin_a struct { a_option string `json:"a_option"` }

// On the wire, the Json will look something like this: { "kind":"my_api_object", "api_version":"v1", "my_plugin": { "kind":"plugin_a", "a_option":"foo", }, }

so what happens? Decode first uses json or yaml to unmarshal the serialized data into your external My_api_object. That causes the raw Json to be stored, but not unpacked. The next step is to copy (using pkg/conversion) into the internal struct. The runtime package's Default_scheme has conversion functions installed which will unpack the Json stored in Raw_extension, turning it into the correct object type, and storing it in the Object. (todo: In the case where the object is of an unknown type, a runtime.unknown object will be created and stored.)

type t
val to_yojson : t -> Yojson.Safe.t
val make : raw:string -> unit -> t
val raw : t -> string

Raw is the underlying serialization of this object.

module Object : Object.S with type value := t
OCaml

Innovation. Community. Security.