Proposal for solving api plugability

Note that this is just a sketch and lacks test and not all details are implemented. That said, this proposal:

* In the conversion package, expose Src/Dest struct tags to conversionFuncs via the Scope.
* In runtime, add "RawExtension" which just stores raw JSON (or yaml?) for deferred unpacking.
* In runtime, add global named Schemes.
* In runtime, add to the DefaultScheme conversionFuncs which convert between RawExtension and EmbeddedObject. They use a struct tag on the *internal* structure to determine which scheme to use. They use a struct tag on the external versioned structure to determine what object version to emit.
* As an example of how this would look in practice, the VolumeSource field is updated to use this mechanism.

I think this is easy, readable, extensible, and will emit the JSON that we want.
Why can't we simply rely on run-time code to do dynamic lookup?

E.g. When we ValidateVolumes(), call ValidateVolumePlugin(blob),
ValidateVolumePlugin() has the responsibility of looking up blob.Kind in a
map and calling allVolumeTypes[name].Validate(blob).

I'm arguing for magic in the marshalling, but manual labor in the
management of plugins.

This PR has a lot of stuff that I do not know in it - I will have to look
again tomorrow.


On Tue, Sep 9, 2014 at 11:25 PM, Daniel Smith <notifications@github.com>
wrote:

> In pkg/api/register.go:
>
> > @@ -38,4 +38,9 @@ func init() {
> >  		&EndpointsList{},
> >  		&Binding{},
> >  	)
> > +	// Register allowed thingies for volume sources
> > +	runtime.GetScheme("volumeSources").AddKnownTypes("",
>
> You may just have to deal with it. I could list the allowed types in the
> struct tag, but that wouldn't be extendable. This is.
>
> I'm working on improved documentation.
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/1239/files#r17344769>
> .
>