kubectl delete command: adding  labelSelector

@lavalamp @smarterclayton basically I've rewritten the PR integrating your comments.

@smarterclayton: I didn't fix shortcut expansion since I have hard time to understand where the shortcut should come from. Maybe we may discuss about it. 



> On Dec 10, 2014, at 9:48 AM, salvatore dario minonne <notifications@github.com> wrote:
> 
> In pkg/kubectl/cmd/resource.go:
> 
> > +		namespace := GetKubeNamespace(cmd)
> > +		for _, arg := range extractedArgs {
> > +			resource := kubectl.ExpandResourceShortcut(arg)
> > +			if len(resource) == 0 {
> > +				usageError(cmd, "Unknown resource %s", resource)
> > +			}
> > +			version, kind, err := mapper.VersionAndKindForResource(resource)
> > +			checkErr(err)
> > +			mapping, err := mapper.RESTMapping(version, kind)
> > +			checkErr(err)
> > +			client, err := clientBuilder(cmd, mapping)
> > +			checkErr(err)
> > +			labelSelector, err := labels.ParseSelector(selector)
> > +			checkErr(err)
> > +			restHelper := kubectl.NewRESTHelper(client, mapping)
> > +			obj, err := restHelper.Get(namespace, "", labelSelector)
> @smarterclayton I tried to wrap my head around these but I have hard time. (Sorry for the maybe silly questions)
> 
> If I split RESTCallItem { ... } in ResourceInfo { ... } and ResourceSelector { ... } 
> the func ResourcesFromArgsOrFile should return 2 arrays []ResourceSelector and []ResourceInfo? My understanding is that info contained in both struct will be necessary to delete the resources.
> 
Return an array of interfaces - something like

    type Foo interface {
      Resource(func(runtime.Object) error)
    }

    []Foo

> What's the goal of having the 2 func Get(...) for ResourceInfo and ResourceSelector. These two funcs get as input a func(obj runtime.Object) error but what's the role of this func? To extract for example the names?
> 
It actually hides the details of iterating over each item.  So users can specify a single item, multiple items, a single selector that returns multiple items, or multiple selectors.
> Clearly I'm loosing part of a bigger scenario
> 
> About the cpu hit of calling the get for each resource: my understanding (probably wrong) if that the only way to detect if a resource is a kube resource is to get it. Is there other way to detect it?
> 
What cpu hit is this?  There will eventually be a mechanism whereby RESTMapper would have dynamic lists of resources fetched earlier - so the values returned by that interface could in the future change.  The interface would hide that detail though.
> —
> Reply to this email directly or view it on GitHub.
>