Merge pull request #41094 from MHBauer/client-gen-gv-parse

Automatic merge from submit-queue (batch tested with PRs 40665, 41094, 41351, 41721, 41843)

parse single string as group rather than version

**What this PR does / why we need it**:
Prevent bad code generation by adjusting parsing of input.

When client-gen is run with `--input` as an unversioned type, it blows up if the group does not end with a trailing slash.

examples
1. `--input servicecatalog/v1alpha` is group servicecatalog, with version v1alpha1
1. `--input servicecatalog/` is group servicecatalog, with version empty string
1. `--input servicecatalog` is group empty string, with version servicecatalog

I disagree that the second and third cases are different. This adjusts them so they are both case 2.


**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: 

This change would address the concerns in PR https://github.com/kubernetes/community/pull/343

**Special notes for your reviewer**:
@caesarxuchao @pmorie this does not result in any change in any current code generation, and improves the user experience of client-gen. I ran `hack/update-codegen.sh` and saw no changes in git, nor did anything fail.

**Release note**:
```release-note
NONE
```
pull/6/head
Kubernetes Submit Queue 2017-02-25 03:56:53 -08:00 committed by GitHub
commit 43d8110225
1 changed files with 1 additions and 1 deletions

View File

@ -36,7 +36,7 @@ func ToGroupVersion(gv string) (GroupVersion, error) {
switch strings.Count(gv, "/") {
case 0:
return GroupVersion{"", Version(gv)}, nil
return GroupVersion{Group(gv), ""}, nil
case 1:
i := strings.Index(gv, "/")
return GroupVersion{Group(gv[:i]), Version(gv[i+1:])}, nil