[resource/codegen] Make resource.Object compatible with kuberenetes
IfSentient opened this issue · comments
Currently, kubernete's go APIs expect runtime.Object
for most things, which, under the hood, are expected to be more complete interfaces (such as schema.ObjectKind
and metav1.Object
). The interface used by the app-sdk should be a superset of what is required by kubernetes, so that all objects used in the app-sdk can be used with the kubernetes go APIs unchanged. An example of how the resource.Object
interface should be modified:
type Object interface {
runtime.Object // Baseline k8s interface, requires DeepCopyObject and Destroy
schema.ObjectKind // Provides GVK information
metav1.Object // Provides all the Object metadata methods
// ...Other methods as required by the app-sdk...
}
Additionally, as part of this, unmarshal logic should be removed from the resource.Object
interface, and moved into a separate type which can handle an input of raw bytes and output a typed or untyped resource.Object
. This is analogous to an extended version of resource.Schema
, which also can marshal/unmarshal. A proposed solution for this looks like:
type Kind struct {
Schema
Codecs map[resource.KindEncoding]Codec
}
type Codec interface {
Read(in io.Reader, into Object) error
Write(out io.Writer, from Object) error
}