Merge pull request #45910 from seh/correct-tpr-example-registration

Automatic merge from submit-queue (batch tested with PRs 46133, 46211, 46224, 46205, 45910)

Correct client-go TPR example type registration

**What this PR does / why we need it**:

Eliminate duplicate registration of third-party resource types in the _client-go_ example, precluding any number of readers from copying the mistake into their own applications as they adapt the example to their own needs.

**Special notes for your reviewer**:

See [the preceding discussion](a6c97715ed (commitcomment-22146536)) about a6c97715ed, committed as part of #45463 but only noticed after the merge.

It's possible that we could take a few of the changes proposed here and apply them more broadly throughout the rest of the code, such as not exporting the `AddToScheme` var in favor of an actual function declaration. Given the flux in #44784, I'd prefer that we don't hold up these small touch-ups on a broader unification.

People I expect will want to weigh in: @sttts, @caesarxuchao, and @nilebox.
This commit is contained in:
Kubernetes Submit Queue 2017-05-22 15:50:07 -07:00 committed by GitHub
commit 8e98f1dfec

View File

@ -27,25 +27,18 @@ var (
AddToScheme = SchemeBuilder.AddToScheme
)
// GroupName is the group name use in this package
// GroupName is the group name use in this package.
const GroupName = "tpr.client-go.k8s.io"
// SchemeGroupVersion is group version used to register these objects
// SchemeGroupVersion is the group version used to register these objects.
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
// Resource takes an unqualified resource and returns a Group-qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
SchemeBuilder.Register(addKnownTypes)
}
// Adds the list of known types to api.Scheme.
// addKnownTypes adds the set of types defined in this package to the supplied scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Example{},