WIP - Allow kubectl to handle arbitrary objects

Kubectl will need to handle extension for known (part of api.Scheme) and unknown (defined via config or future ComponentPlugin extension mechanisms on the api server) object types.  This pull request:

* updates the create/update/delete flows for kubectl to separate the versioning abstractions from the core code path via interfaces
* decouple kubectl commands from knowing about specific details of objects (via RESTMapper and the Factory abstraction for commands)
* factors `pkg/kubectl` to ensure it uses our existing abstractions for versioning and object types
* adds more test cases to core paths
* ensures that output from `kubectl get` goes through external versions
 * defaults to `latest.Version`
 * can be changed via `--output-version`
* add more test cases to `hack/test-cmd.sh` for the command output flows

A key goal of the pull is to continue to refine the runtime / meta abstractions to assist in client logic, and to allow other consumers of kubectl to support more than just types in api.Scheme (openshift).

A follow on pull will address the limited unit testability of the `pkg/kubectl/cmd` package.

Note: first commit is in #2059
Yeah, ResourceOrType*

Can do with some further improvement, but each message is subtly different and I wanted them all together in one spot.

> On Nov 3, 2014, at 7:16 PM, bgrant0607 <notifications@github.com> wrote:
> 
> In pkg/kubectl/cmd/resource.go:
> 
> > +
> > +// ResourceFromArgs expects two arguments with a given type, and extracts the fields necessary
> > +// to uniquely locate a resource. Displays a usageError if that contract is not satisfied, or
> > +// a generic error if any other problems occur.
> > +func ResourceOrTypeFromArgs(cmd *cobra.Command, args []string, mapper meta.RESTMapper) (mapping *meta.RESTMapping, namespace, name string) {
> > +	if len(args) == 0 || len(args) > 2 {
> > +		usageError(cmd, "Must provide resource or a resource and name as command line params")
> > +	}
> > +
> > +	resource := args[0]
> > +	if len(resource) == 0 {
> > +		usageError(cmd, "Must provide resource or a resource and name as command line params")
> > +	}
> > +
> > +	namespace = getKubeNamespace(cmd)
> > +	if len(args) == 2 {
> It's ok for name to be omitted?
> 
> —
> Reply to this email directly or view it on GitHub.