Define a mapping between REST resource name and kind/apiVersion

Allows clients to abstractly map user input to generic resource
paths as per docs/api-conventions.md

Extracted from #2000 and supports #1958
The versions you pass to NewDefaultRESTMapper() are the versions you search when looking for an object that has no apiVersion (for instance, when the CLI consumer passes "nodes" and you need to check in order a list of versions to determine a matching object type), the ones you pass to Add are the versions on the scheme you want to load (so if you didn't want to load v1beta3 you don't pass it to Add).

----- Original Message -----
> > @@ -83,3 +88,19 @@ func InterfacesFor(version string) (*VersionInterfaces,
> > error) {
> >  		return nil, fmt.Errorf("unsupported storage version: %s (valid: %s)",
> >  		version, strings.Join(Versions, ", "))
> >  	}
> >  }
> > +
> > +func init() {
> > +	mapper := meta.NewDefaultRESTMapper(
> > +		Versions,
> > +		func(version string) (runtime.Codec, meta.MetadataAccessor, bool) {
> > +			interfaces, err := InterfacesFor(version)
> > +			if err != nil {
> > +				return nil, nil, false
> > +			}
> > +			return interfaces.Codec, interfaces.MetadataAccessor, true
> > +		},
> > +	)
> > +	mapper.Add(api.Scheme, true, Versions...)
> 
> Maybe it will become clear as I read more of this PR, but I find it strange
> that Versions is passed to both calls.
> 
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/GoogleCloudPlatform/kubernetes/pull/2059/files#r19765614