From bb712e2c12e1e0f0f63d4ad655d87dc6766ce850 Mon Sep 17 00:00:00 2001 From: Steve Kuznetsov Date: Sun, 6 Nov 2022 07:05:42 -0700 Subject: [PATCH] code-generator: refer to the API package for GV{R,K} There should only be one source of truth for the API group's name and version. Signed-off-by: Steve Kuznetsov Kubernetes-commit: e13198ec6f52c4a6405388e90053954dc7656a31 --- .../fake/generator_fake_for_type.go | 71 +++++++------------ .../example/v1/fake/fake_clustertesttype.go | 61 ++++++++-------- .../typed/example/v1/fake/fake_testtype.go | 57 ++++++++------- .../example/v1/fake/fake_clustertesttype.go | 63 ++++++++-------- .../typed/example/v1/fake/fake_testtype.go | 57 ++++++++------- .../internalversion/fake/fake_testtype.go | 5 +- .../internalversion/fake/fake_testtype.go | 5 +- .../internalversion/fake/fake_testtype.go | 5 +- .../typed/example/v1/fake/fake_testtype.go | 57 ++++++++------- .../typed/example2/v1/fake/fake_testtype.go | 57 ++++++++------- .../example3.io/v1/fake/fake_testtype.go | 57 ++++++++------- .../example/v1/fake/fake_clustertesttype.go | 61 ++++++++-------- .../typed/example/v1/fake/fake_testtype.go | 57 ++++++++------- .../typed/example2/v1/fake/fake_testtype.go | 57 ++++++++------- 14 files changed, 319 insertions(+), 351 deletions(-) diff --git a/cmd/client-gen/generators/fake/generator_fake_for_type.go b/cmd/client-gen/generators/fake/generator_fake_for_type.go index ec40fb4e..dce920ad 100644 --- a/cmd/client-gen/generators/fake/generator_fake_for_type.go +++ b/cmd/client-gen/generators/fake/generator_fake_for_type.go @@ -27,7 +27,6 @@ import ( "k8s.io/gengo/types" "k8s.io/code-generator/cmd/client-gen/generators/util" - "k8s.io/code-generator/cmd/client-gen/path" ) // genFakeForType produces a file for each top-level type. @@ -93,51 +92,33 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io. if err != nil { return err } - canonicalGroup := g.group - if canonicalGroup == "core" { - canonicalGroup = "" - } - - groupName := g.group - if g.group == "core" { - groupName = "" - } - - // allow user to define a group name that's different from the one parsed from the directory. - p := c.Universe.Package(path.Vendorless(g.inputPackage)) - if override := types.ExtractCommentTags("+", p.Comments)["groupName"]; override != nil { - groupName = override[0] - } const pkgClientGoTesting = "k8s.io/client-go/testing" m := map[string]interface{}{ - "type": t, - "inputType": t, - "resultType": t, - "subresourcePath": "", - "package": pkg, - "Package": namer.IC(pkg), - "namespaced": !tags.NonNamespaced, - "Group": namer.IC(g.group), - "GroupGoName": g.groupGoName, - "Version": namer.IC(g.version), - "group": canonicalGroup, - "groupName": groupName, - "version": g.version, - "CreateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "CreateOptions"}), - "DeleteOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "DeleteOptions"}), - "GetOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "GetOptions"}), - "ListOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ListOptions"}), - "PatchOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "PatchOptions"}), - "ApplyOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ApplyOptions"}), - "UpdateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "UpdateOptions"}), - "Everything": c.Universe.Function(types.Name{Package: "k8s.io/apimachinery/pkg/labels", Name: "Everything"}), - "GroupVersionResource": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/runtime/schema", Name: "GroupVersionResource"}), - "GroupVersionKind": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/runtime/schema", Name: "GroupVersionKind"}), - "PatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "PatchType"}), - "ApplyPatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "ApplyPatchType"}), - "watchInterface": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/watch", Name: "Interface"}), - "jsonMarshal": c.Universe.Type(types.Name{Package: "encoding/json", Name: "Marshal"}), + "type": t, + "inputType": t, + "resultType": t, + "subresourcePath": "", + "package": pkg, + "Package": namer.IC(pkg), + "namespaced": !tags.NonNamespaced, + "Group": namer.IC(g.group), + "GroupGoName": g.groupGoName, + "Version": namer.IC(g.version), + "version": g.version, + "SchemeGroupVersion": c.Universe.Type(types.Name{Package: t.Name.Package, Name: "SchemeGroupVersion"}), + "CreateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "CreateOptions"}), + "DeleteOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "DeleteOptions"}), + "GetOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "GetOptions"}), + "ListOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ListOptions"}), + "PatchOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "PatchOptions"}), + "ApplyOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ApplyOptions"}), + "UpdateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "UpdateOptions"}), + "Everything": c.Universe.Function(types.Name{Package: "k8s.io/apimachinery/pkg/labels", Name: "Everything"}), + "PatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "PatchType"}), + "ApplyPatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "ApplyPatchType"}), + "watchInterface": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/watch", Name: "Interface"}), + "jsonMarshal": c.Universe.Type(types.Name{Package: "encoding/json", Name: "Marshal"}), "NewRootListAction": c.Universe.Function(types.Name{Package: pkgClientGoTesting, Name: "NewRootListAction"}), "NewListAction": c.Universe.Function(types.Name{Package: pkgClientGoTesting, Name: "NewListAction"}), @@ -340,11 +321,11 @@ type Fake$.type|publicPlural$ struct { ` var resource = ` -var $.type|allLowercasePlural$Resource = $.GroupVersionResource|raw${Group: "$.groupName$", Version: "$.version$", Resource: "$.type|resource$"} +var $.type|allLowercasePlural$Resource = $.SchemeGroupVersion|raw$.WithResource("$.type|resource$") ` var kind = ` -var $.type|allLowercasePlural$Kind = $.GroupVersionKind|raw${Group: "$.groupName$", Version: "$.version$", Kind: "$.type|singularKind$"} +var $.type|allLowercasePlural$Kind = $.SchemeGroupVersion|raw$.WithKind("$.type|singularKind$") ` var listTemplate = ` diff --git a/examples/HyphenGroup/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go b/examples/HyphenGroup/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go index bcad13d1..1ac3d042 100644 --- a/examples/HyphenGroup/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go +++ b/examples/HyphenGroup/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go @@ -22,13 +22,12 @@ import ( "context" autoscalingv1 "k8s.io/api/autoscaling/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - examplev1 "k8s.io/code-generator/examples/HyphenGroup/apis/example/v1" + v1 "k8s.io/code-generator/examples/HyphenGroup/apis/example/v1" ) // FakeClusterTestTypes implements ClusterTestTypeInterface @@ -36,24 +35,24 @@ type FakeClusterTestTypes struct { Fake *FakeExampleGroupV1 } -var clustertesttypesResource = schema.GroupVersionResource{Group: "example-group.hyphens.code-generator.k8s.io", Version: "v1", Resource: "clustertesttypes"} +var clustertesttypesResource = v1.SchemeGroupVersion.WithResource("clustertesttypes") -var clustertesttypesKind = schema.GroupVersionKind{Group: "example-group.hyphens.code-generator.k8s.io", Version: "v1", Kind: "ClusterTestType"} +var clustertesttypesKind = v1.SchemeGroupVersion.WithKind("ClusterTestType") // Get takes name of the clusterTestType, and returns the corresponding clusterTestType object, and an error if there is any. -func (c *FakeClusterTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootGetAction(clustertesttypesResource, name), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootGetAction(clustertesttypesResource, name), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // List takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors. -func (c *FakeClusterTestTypes) List(ctx context.Context, opts v1.ListOptions) (result *examplev1.ClusterTestTypeList, err error) { +func (c *FakeClusterTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) { obj, err := c.Fake. - Invokes(testing.NewRootListAction(clustertesttypesResource, clustertesttypesKind, opts), &examplev1.ClusterTestTypeList{}) + Invokes(testing.NewRootListAction(clustertesttypesResource, clustertesttypesKind, opts), &v1.ClusterTestTypeList{}) if obj == nil { return nil, err } @@ -62,8 +61,8 @@ func (c *FakeClusterTestTypes) List(ctx context.Context, opts v1.ListOptions) (r if label == nil { label = labels.Everything() } - list := &examplev1.ClusterTestTypeList{ListMeta: obj.(*examplev1.ClusterTestTypeList).ListMeta} - for _, item := range obj.(*examplev1.ClusterTestTypeList).Items { + list := &v1.ClusterTestTypeList{ListMeta: obj.(*v1.ClusterTestTypeList).ListMeta} + for _, item := range obj.(*v1.ClusterTestTypeList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -72,69 +71,69 @@ func (c *FakeClusterTestTypes) List(ctx context.Context, opts v1.ListOptions) (r } // Watch returns a watch.Interface that watches the requested clusterTestTypes. -func (c *FakeClusterTestTypes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeClusterTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewRootWatchAction(clustertesttypesResource, opts)) } // Create takes the representation of a clusterTestType and creates it. Returns the server's representation of the clusterTestType, and an error, if there is any. -func (c *FakeClusterTestTypes) Create(ctx context.Context, clusterTestType *examplev1.ClusterTestType, opts v1.CreateOptions) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Create(ctx context.Context, clusterTestType *v1.ClusterTestType, opts metav1.CreateOptions) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(clustertesttypesResource, clusterTestType), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootCreateAction(clustertesttypesResource, clusterTestType), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // Update takes the representation of a clusterTestType and updates it. Returns the server's representation of the clusterTestType, and an error, if there is any. -func (c *FakeClusterTestTypes) Update(ctx context.Context, clusterTestType *examplev1.ClusterTestType, opts v1.UpdateOptions) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Update(ctx context.Context, clusterTestType *v1.ClusterTestType, opts metav1.UpdateOptions) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(clustertesttypesResource, clusterTestType), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootUpdateAction(clustertesttypesResource, clusterTestType), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeClusterTestTypes) UpdateStatus(ctx context.Context, clusterTestType *examplev1.ClusterTestType, opts v1.UpdateOptions) (*examplev1.ClusterTestType, error) { +func (c *FakeClusterTestTypes) UpdateStatus(ctx context.Context, clusterTestType *v1.ClusterTestType, opts metav1.UpdateOptions) (*v1.ClusterTestType, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "status", clusterTestType), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "status", clusterTestType), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // Delete takes name of the clusterTestType and deletes it. Returns an error if one occurs. -func (c *FakeClusterTestTypes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeClusterTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(clustertesttypesResource, name, opts), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootDeleteActionWithOptions(clustertesttypesResource, name, opts), &v1.ClusterTestType{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeClusterTestTypes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeClusterTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewRootDeleteCollectionAction(clustertesttypesResource, listOpts) - _, err := c.Fake.Invokes(action, &examplev1.ClusterTestTypeList{}) + _, err := c.Fake.Invokes(action, &v1.ClusterTestTypeList{}) return err } // Patch applies the patch and returns the patched clusterTestType. -func (c *FakeClusterTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clustertesttypesResource, name, pt, data, subresources...), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootPatchSubresourceAction(clustertesttypesResource, name, pt, data, subresources...), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // GetScale takes name of the clusterTestType, and returns the corresponding scale object, and an error if there is any. -func (c *FakeClusterTestTypes) GetScale(ctx context.Context, clusterTestTypeName string, options v1.GetOptions) (result *autoscalingv1.Scale, err error) { +func (c *FakeClusterTestTypes) GetScale(ctx context.Context, clusterTestTypeName string, options metav1.GetOptions) (result *autoscalingv1.Scale, err error) { obj, err := c.Fake. Invokes(testing.NewRootGetSubresourceAction(clustertesttypesResource, "scale", clusterTestTypeName), &autoscalingv1.Scale{}) if obj == nil { @@ -144,7 +143,7 @@ func (c *FakeClusterTestTypes) GetScale(ctx context.Context, clusterTestTypeName } // UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any. -func (c *FakeClusterTestTypes) UpdateScale(ctx context.Context, clusterTestTypeName string, scale *autoscalingv1.Scale, opts v1.UpdateOptions) (result *autoscalingv1.Scale, err error) { +func (c *FakeClusterTestTypes) UpdateScale(ctx context.Context, clusterTestTypeName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (result *autoscalingv1.Scale, err error) { obj, err := c.Fake. Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "scale", scale), &autoscalingv1.Scale{}) if obj == nil { diff --git a/examples/HyphenGroup/clientset/versioned/typed/example/v1/fake/fake_testtype.go b/examples/HyphenGroup/clientset/versioned/typed/example/v1/fake/fake_testtype.go index e5bb608b..54e65a30 100644 --- a/examples/HyphenGroup/clientset/versioned/typed/example/v1/fake/fake_testtype.go +++ b/examples/HyphenGroup/clientset/versioned/typed/example/v1/fake/fake_testtype.go @@ -21,13 +21,12 @@ package fake import ( "context" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - examplev1 "k8s.io/code-generator/examples/HyphenGroup/apis/example/v1" + v1 "k8s.io/code-generator/examples/HyphenGroup/apis/example/v1" ) // FakeTestTypes implements TestTypeInterface @@ -36,25 +35,25 @@ type FakeTestTypes struct { ns string } -var testtypesResource = schema.GroupVersionResource{Group: "example-group.hyphens.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} +var testtypesResource = v1.SchemeGroupVersion.WithResource("testtypes") -var testtypesKind = schema.GroupVersionKind{Group: "example-group.hyphens.code-generator.k8s.io", Version: "v1", Kind: "TestType"} +var testtypesKind = v1.SchemeGroupVersion.WithKind("TestType") // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. -func (c *FakeTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &examplev1.TestType{}) + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result *examplev1.TestTypeList, err error) { +func (c *FakeTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &examplev1.TestTypeList{}) + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &v1.TestTypeList{}) if obj == nil { return nil, err @@ -64,8 +63,8 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * if label == nil { label = labels.Everything() } - list := &examplev1.TestTypeList{ListMeta: obj.(*examplev1.TestTypeList).ListMeta} - for _, item := range obj.(*examplev1.TestTypeList).Items { + list := &v1.TestTypeList{ListMeta: obj.(*v1.TestTypeList).ListMeta} + for _, item := range obj.(*v1.TestTypeList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -74,69 +73,69 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * } // Watch returns a watch.Interface that watches the requested testTypes. -func (c *FakeTestTypes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) } // Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Create(ctx context.Context, testType *examplev1.TestType, opts v1.CreateOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Create(ctx context.Context, testType *v1.TestType, opts metav1.CreateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Update(ctx context.Context, testType *examplev1.TestType, opts v1.UpdateOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Update(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *examplev1.TestType, opts v1.UpdateOptions) (*examplev1.TestType, error) { +func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (*v1.TestType, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // Delete takes name of the testType and deletes it. Returns an error if one occurs. -func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &examplev1.TestType{}) + Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &v1.TestType{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOpts) - _, err := c.Fake.Invokes(action, &examplev1.TestTypeList{}) + _, err := c.Fake.Invokes(action, &v1.TestTypeList{}) return err } // Patch applies the patch and returns the patched testType. -func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &examplev1.TestType{}) + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } diff --git a/examples/MixedCase/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go b/examples/MixedCase/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go index e0f13315..07fa1ec1 100644 --- a/examples/MixedCase/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go +++ b/examples/MixedCase/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go @@ -22,13 +22,12 @@ import ( "context" autoscalingv1 "k8s.io/api/autoscaling/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - examplev1 "k8s.io/code-generator/examples/MixedCase/apis/example/v1" + v1 "k8s.io/code-generator/examples/MixedCase/apis/example/v1" ) // FakeClusterTestTypes implements ClusterTestTypeInterface @@ -36,24 +35,24 @@ type FakeClusterTestTypes struct { Fake *FakeExampleV1 } -var clustertesttypesResource = schema.GroupVersionResource{Group: "example.crd.code-generator.k8s.io", Version: "v1", Resource: "clustertesttypes"} +var clustertesttypesResource = v1.SchemeGroupVersion.WithResource("clustertesttypes") -var clustertesttypesKind = schema.GroupVersionKind{Group: "example.crd.code-generator.k8s.io", Version: "v1", Kind: "ClusterTestType"} +var clustertesttypesKind = v1.SchemeGroupVersion.WithKind("ClusterTestType") // Get takes name of the clusterTestType, and returns the corresponding clusterTestType object, and an error if there is any. -func (c *FakeClusterTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootGetAction(clustertesttypesResource, name), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootGetAction(clustertesttypesResource, name), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // List takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors. -func (c *FakeClusterTestTypes) List(ctx context.Context, opts v1.ListOptions) (result *examplev1.ClusterTestTypeList, err error) { +func (c *FakeClusterTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) { obj, err := c.Fake. - Invokes(testing.NewRootListAction(clustertesttypesResource, clustertesttypesKind, opts), &examplev1.ClusterTestTypeList{}) + Invokes(testing.NewRootListAction(clustertesttypesResource, clustertesttypesKind, opts), &v1.ClusterTestTypeList{}) if obj == nil { return nil, err } @@ -62,8 +61,8 @@ func (c *FakeClusterTestTypes) List(ctx context.Context, opts v1.ListOptions) (r if label == nil { label = labels.Everything() } - list := &examplev1.ClusterTestTypeList{ListMeta: obj.(*examplev1.ClusterTestTypeList).ListMeta} - for _, item := range obj.(*examplev1.ClusterTestTypeList).Items { + list := &v1.ClusterTestTypeList{ListMeta: obj.(*v1.ClusterTestTypeList).ListMeta} + for _, item := range obj.(*v1.ClusterTestTypeList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -72,69 +71,69 @@ func (c *FakeClusterTestTypes) List(ctx context.Context, opts v1.ListOptions) (r } // Watch returns a watch.Interface that watches the requested clusterTestTypes. -func (c *FakeClusterTestTypes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeClusterTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewRootWatchAction(clustertesttypesResource, opts)) } // Create takes the representation of a clusterTestType and creates it. Returns the server's representation of the clusterTestType, and an error, if there is any. -func (c *FakeClusterTestTypes) Create(ctx context.Context, clusterTestType *examplev1.ClusterTestType, opts v1.CreateOptions) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Create(ctx context.Context, clusterTestType *v1.ClusterTestType, opts metav1.CreateOptions) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(clustertesttypesResource, clusterTestType), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootCreateAction(clustertesttypesResource, clusterTestType), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // Update takes the representation of a clusterTestType and updates it. Returns the server's representation of the clusterTestType, and an error, if there is any. -func (c *FakeClusterTestTypes) Update(ctx context.Context, clusterTestType *examplev1.ClusterTestType, opts v1.UpdateOptions) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Update(ctx context.Context, clusterTestType *v1.ClusterTestType, opts metav1.UpdateOptions) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(clustertesttypesResource, clusterTestType), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootUpdateAction(clustertesttypesResource, clusterTestType), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeClusterTestTypes) UpdateStatus(ctx context.Context, clusterTestType *examplev1.ClusterTestType, opts v1.UpdateOptions) (*examplev1.ClusterTestType, error) { +func (c *FakeClusterTestTypes) UpdateStatus(ctx context.Context, clusterTestType *v1.ClusterTestType, opts metav1.UpdateOptions) (*v1.ClusterTestType, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "status", clusterTestType), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "status", clusterTestType), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // Delete takes name of the clusterTestType and deletes it. Returns an error if one occurs. -func (c *FakeClusterTestTypes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeClusterTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(clustertesttypesResource, name, opts), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootDeleteActionWithOptions(clustertesttypesResource, name, opts), &v1.ClusterTestType{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeClusterTestTypes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeClusterTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewRootDeleteCollectionAction(clustertesttypesResource, listOpts) - _, err := c.Fake.Invokes(action, &examplev1.ClusterTestTypeList{}) + _, err := c.Fake.Invokes(action, &v1.ClusterTestTypeList{}) return err } // Patch applies the patch and returns the patched clusterTestType. -func (c *FakeClusterTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clustertesttypesResource, name, pt, data, subresources...), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootPatchSubresourceAction(clustertesttypesResource, name, pt, data, subresources...), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // GetScale takes name of the clusterTestType, and returns the corresponding scale object, and an error if there is any. -func (c *FakeClusterTestTypes) GetScale(ctx context.Context, clusterTestTypeName string, options v1.GetOptions) (result *autoscalingv1.Scale, err error) { +func (c *FakeClusterTestTypes) GetScale(ctx context.Context, clusterTestTypeName string, options metav1.GetOptions) (result *autoscalingv1.Scale, err error) { obj, err := c.Fake. Invokes(testing.NewRootGetSubresourceAction(clustertesttypesResource, "scale", clusterTestTypeName), &autoscalingv1.Scale{}) if obj == nil { @@ -144,7 +143,7 @@ func (c *FakeClusterTestTypes) GetScale(ctx context.Context, clusterTestTypeName } // UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any. -func (c *FakeClusterTestTypes) UpdateScale(ctx context.Context, clusterTestTypeName string, scale *autoscalingv1.Scale, opts v1.UpdateOptions) (result *autoscalingv1.Scale, err error) { +func (c *FakeClusterTestTypes) UpdateScale(ctx context.Context, clusterTestTypeName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (result *autoscalingv1.Scale, err error) { obj, err := c.Fake. Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "scale", scale), &autoscalingv1.Scale{}) if obj == nil { @@ -154,7 +153,7 @@ func (c *FakeClusterTestTypes) UpdateScale(ctx context.Context, clusterTestTypeN } // CreateScale takes the representation of a scale and creates it. Returns the server's representation of the scale, and an error, if there is any. -func (c *FakeClusterTestTypes) CreateScale(ctx context.Context, clusterTestTypeName string, scale *autoscalingv1.Scale, opts v1.CreateOptions) (result *autoscalingv1.Scale, err error) { +func (c *FakeClusterTestTypes) CreateScale(ctx context.Context, clusterTestTypeName string, scale *autoscalingv1.Scale, opts metav1.CreateOptions) (result *autoscalingv1.Scale, err error) { obj, err := c.Fake. Invokes(testing.NewRootCreateSubresourceAction(clustertesttypesResource, clusterTestTypeName, "scale", scale), &autoscalingv1.Scale{}) if obj == nil { diff --git a/examples/MixedCase/clientset/versioned/typed/example/v1/fake/fake_testtype.go b/examples/MixedCase/clientset/versioned/typed/example/v1/fake/fake_testtype.go index fd18b460..6e74ed18 100644 --- a/examples/MixedCase/clientset/versioned/typed/example/v1/fake/fake_testtype.go +++ b/examples/MixedCase/clientset/versioned/typed/example/v1/fake/fake_testtype.go @@ -21,13 +21,12 @@ package fake import ( "context" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - examplev1 "k8s.io/code-generator/examples/MixedCase/apis/example/v1" + v1 "k8s.io/code-generator/examples/MixedCase/apis/example/v1" ) // FakeTestTypes implements TestTypeInterface @@ -36,25 +35,25 @@ type FakeTestTypes struct { ns string } -var testtypesResource = schema.GroupVersionResource{Group: "example.crd.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} +var testtypesResource = v1.SchemeGroupVersion.WithResource("testtypes") -var testtypesKind = schema.GroupVersionKind{Group: "example.crd.code-generator.k8s.io", Version: "v1", Kind: "TestType"} +var testtypesKind = v1.SchemeGroupVersion.WithKind("TestType") // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. -func (c *FakeTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &examplev1.TestType{}) + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result *examplev1.TestTypeList, err error) { +func (c *FakeTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &examplev1.TestTypeList{}) + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &v1.TestTypeList{}) if obj == nil { return nil, err @@ -64,8 +63,8 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * if label == nil { label = labels.Everything() } - list := &examplev1.TestTypeList{ListMeta: obj.(*examplev1.TestTypeList).ListMeta} - for _, item := range obj.(*examplev1.TestTypeList).Items { + list := &v1.TestTypeList{ListMeta: obj.(*v1.TestTypeList).ListMeta} + for _, item := range obj.(*v1.TestTypeList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -74,69 +73,69 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * } // Watch returns a watch.Interface that watches the requested testTypes. -func (c *FakeTestTypes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) } // Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Create(ctx context.Context, testType *examplev1.TestType, opts v1.CreateOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Create(ctx context.Context, testType *v1.TestType, opts metav1.CreateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Update(ctx context.Context, testType *examplev1.TestType, opts v1.UpdateOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Update(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *examplev1.TestType, opts v1.UpdateOptions) (*examplev1.TestType, error) { +func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (*v1.TestType, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // Delete takes name of the testType and deletes it. Returns an error if one occurs. -func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &examplev1.TestType{}) + Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &v1.TestType{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOpts) - _, err := c.Fake.Invokes(action, &examplev1.TestTypeList{}) + _, err := c.Fake.Invokes(action, &v1.TestTypeList{}) return err } // Patch applies the patch and returns the patched testType. -func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &examplev1.TestType{}) + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } diff --git a/examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_testtype.go b/examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_testtype.go index 3fc2411c..74efc2bf 100644 --- a/examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_testtype.go +++ b/examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_testtype.go @@ -23,7 +23,6 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -36,9 +35,9 @@ type FakeTestTypes struct { ns string } -var testtypesResource = schema.GroupVersionResource{Group: "example.apiserver.code-generator.k8s.io", Version: "", Resource: "testtypes"} +var testtypesResource = example.SchemeGroupVersion.WithResource("testtypes") -var testtypesKind = schema.GroupVersionKind{Group: "example.apiserver.code-generator.k8s.io", Version: "", Kind: "TestType"} +var testtypesKind = example.SchemeGroupVersion.WithKind("TestType") // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. func (c *FakeTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *example.TestType, err error) { diff --git a/examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_testtype.go b/examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_testtype.go index 0250c024..ae867d95 100644 --- a/examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_testtype.go +++ b/examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_testtype.go @@ -23,7 +23,6 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakeTestTypes struct { Fake *FakeSecondExample } -var testtypesResource = schema.GroupVersionResource{Group: "example.test.apiserver.code-generator.k8s.io", Version: "", Resource: "testtypes"} +var testtypesResource = example2.SchemeGroupVersion.WithResource("testtypes") -var testtypesKind = schema.GroupVersionKind{Group: "example.test.apiserver.code-generator.k8s.io", Version: "", Kind: "TestType"} +var testtypesKind = example2.SchemeGroupVersion.WithKind("TestType") // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. func (c *FakeTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *example2.TestType, err error) { diff --git a/examples/apiserver/clientset/internalversion/typed/example3.io/internalversion/fake/fake_testtype.go b/examples/apiserver/clientset/internalversion/typed/example3.io/internalversion/fake/fake_testtype.go index 5730cc0d..075f6113 100644 --- a/examples/apiserver/clientset/internalversion/typed/example3.io/internalversion/fake/fake_testtype.go +++ b/examples/apiserver/clientset/internalversion/typed/example3.io/internalversion/fake/fake_testtype.go @@ -23,7 +23,6 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -36,9 +35,9 @@ type FakeTestTypes struct { ns string } -var testtypesResource = schema.GroupVersionResource{Group: "example.dots.apiserver.code-generator.k8s.io", Version: "", Resource: "testtypes"} +var testtypesResource = example3io.SchemeGroupVersion.WithResource("testtypes") -var testtypesKind = schema.GroupVersionKind{Group: "example.dots.apiserver.code-generator.k8s.io", Version: "", Kind: "TestType"} +var testtypesKind = example3io.SchemeGroupVersion.WithKind("TestType") // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. func (c *FakeTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *example3io.TestType, err error) { diff --git a/examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_testtype.go b/examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_testtype.go index 861a0973..28ff5065 100644 --- a/examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_testtype.go +++ b/examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_testtype.go @@ -21,13 +21,12 @@ package fake import ( "context" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - examplev1 "k8s.io/code-generator/examples/apiserver/apis/example/v1" + v1 "k8s.io/code-generator/examples/apiserver/apis/example/v1" ) // FakeTestTypes implements TestTypeInterface @@ -36,25 +35,25 @@ type FakeTestTypes struct { ns string } -var testtypesResource = schema.GroupVersionResource{Group: "example.apiserver.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} +var testtypesResource = v1.SchemeGroupVersion.WithResource("testtypes") -var testtypesKind = schema.GroupVersionKind{Group: "example.apiserver.code-generator.k8s.io", Version: "v1", Kind: "TestType"} +var testtypesKind = v1.SchemeGroupVersion.WithKind("TestType") // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. -func (c *FakeTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &examplev1.TestType{}) + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result *examplev1.TestTypeList, err error) { +func (c *FakeTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &examplev1.TestTypeList{}) + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &v1.TestTypeList{}) if obj == nil { return nil, err @@ -64,8 +63,8 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * if label == nil { label = labels.Everything() } - list := &examplev1.TestTypeList{ListMeta: obj.(*examplev1.TestTypeList).ListMeta} - for _, item := range obj.(*examplev1.TestTypeList).Items { + list := &v1.TestTypeList{ListMeta: obj.(*v1.TestTypeList).ListMeta} + for _, item := range obj.(*v1.TestTypeList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -74,69 +73,69 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * } // Watch returns a watch.Interface that watches the requested testTypes. -func (c *FakeTestTypes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) } // Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Create(ctx context.Context, testType *examplev1.TestType, opts v1.CreateOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Create(ctx context.Context, testType *v1.TestType, opts metav1.CreateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Update(ctx context.Context, testType *examplev1.TestType, opts v1.UpdateOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Update(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *examplev1.TestType, opts v1.UpdateOptions) (*examplev1.TestType, error) { +func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (*v1.TestType, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // Delete takes name of the testType and deletes it. Returns an error if one occurs. -func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &examplev1.TestType{}) + Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &v1.TestType{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOpts) - _, err := c.Fake.Invokes(action, &examplev1.TestTypeList{}) + _, err := c.Fake.Invokes(action, &v1.TestTypeList{}) return err } // Patch applies the patch and returns the patched testType. -func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &examplev1.TestType{}) + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } diff --git a/examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_testtype.go b/examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_testtype.go index d928c3fc..d77e0f7d 100644 --- a/examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_testtype.go +++ b/examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_testtype.go @@ -21,13 +21,12 @@ package fake import ( "context" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - example2v1 "k8s.io/code-generator/examples/apiserver/apis/example2/v1" + v1 "k8s.io/code-generator/examples/apiserver/apis/example2/v1" ) // FakeTestTypes implements TestTypeInterface @@ -36,25 +35,25 @@ type FakeTestTypes struct { ns string } -var testtypesResource = schema.GroupVersionResource{Group: "example.test.apiserver.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} +var testtypesResource = v1.SchemeGroupVersion.WithResource("testtypes") -var testtypesKind = schema.GroupVersionKind{Group: "example.test.apiserver.code-generator.k8s.io", Version: "v1", Kind: "TestType"} +var testtypesKind = v1.SchemeGroupVersion.WithKind("TestType") // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. -func (c *FakeTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *example2v1.TestType, err error) { +func (c *FakeTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2v1.TestType{}) + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example2v1.TestType), err + return obj.(*v1.TestType), err } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result *example2v1.TestTypeList, err error) { +func (c *FakeTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2v1.TestTypeList{}) + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &v1.TestTypeList{}) if obj == nil { return nil, err @@ -64,8 +63,8 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * if label == nil { label = labels.Everything() } - list := &example2v1.TestTypeList{ListMeta: obj.(*example2v1.TestTypeList).ListMeta} - for _, item := range obj.(*example2v1.TestTypeList).Items { + list := &v1.TestTypeList{ListMeta: obj.(*v1.TestTypeList).ListMeta} + for _, item := range obj.(*v1.TestTypeList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -74,69 +73,69 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * } // Watch returns a watch.Interface that watches the requested testTypes. -func (c *FakeTestTypes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) } // Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Create(ctx context.Context, testType *example2v1.TestType, opts v1.CreateOptions) (result *example2v1.TestType, err error) { +func (c *FakeTestTypes) Create(ctx context.Context, testType *v1.TestType, opts metav1.CreateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2v1.TestType{}) + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example2v1.TestType), err + return obj.(*v1.TestType), err } // Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Update(ctx context.Context, testType *example2v1.TestType, opts v1.UpdateOptions) (result *example2v1.TestType, err error) { +func (c *FakeTestTypes) Update(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2v1.TestType{}) + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example2v1.TestType), err + return obj.(*v1.TestType), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *example2v1.TestType, opts v1.UpdateOptions) (*example2v1.TestType, error) { +func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (*v1.TestType, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2v1.TestType{}) + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example2v1.TestType), err + return obj.(*v1.TestType), err } // Delete takes name of the testType and deletes it. Returns an error if one occurs. -func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &example2v1.TestType{}) + Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &v1.TestType{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOpts) - _, err := c.Fake.Invokes(action, &example2v1.TestTypeList{}) + _, err := c.Fake.Invokes(action, &v1.TestTypeList{}) return err } // Patch applies the patch and returns the patched testType. -func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *example2v1.TestType, err error) { +func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &example2v1.TestType{}) + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example2v1.TestType), err + return obj.(*v1.TestType), err } diff --git a/examples/apiserver/clientset/versioned/typed/example3.io/v1/fake/fake_testtype.go b/examples/apiserver/clientset/versioned/typed/example3.io/v1/fake/fake_testtype.go index 9070765e..fa742d56 100644 --- a/examples/apiserver/clientset/versioned/typed/example3.io/v1/fake/fake_testtype.go +++ b/examples/apiserver/clientset/versioned/typed/example3.io/v1/fake/fake_testtype.go @@ -21,13 +21,12 @@ package fake import ( "context" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - example3iov1 "k8s.io/code-generator/examples/apiserver/apis/example3.io/v1" + v1 "k8s.io/code-generator/examples/apiserver/apis/example3.io/v1" ) // FakeTestTypes implements TestTypeInterface @@ -36,25 +35,25 @@ type FakeTestTypes struct { ns string } -var testtypesResource = schema.GroupVersionResource{Group: "example.dots.apiserver.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} +var testtypesResource = v1.SchemeGroupVersion.WithResource("testtypes") -var testtypesKind = schema.GroupVersionKind{Group: "example.dots.apiserver.code-generator.k8s.io", Version: "v1", Kind: "TestType"} +var testtypesKind = v1.SchemeGroupVersion.WithKind("TestType") // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. -func (c *FakeTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *example3iov1.TestType, err error) { +func (c *FakeTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example3iov1.TestType{}) + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example3iov1.TestType), err + return obj.(*v1.TestType), err } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result *example3iov1.TestTypeList, err error) { +func (c *FakeTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example3iov1.TestTypeList{}) + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &v1.TestTypeList{}) if obj == nil { return nil, err @@ -64,8 +63,8 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * if label == nil { label = labels.Everything() } - list := &example3iov1.TestTypeList{ListMeta: obj.(*example3iov1.TestTypeList).ListMeta} - for _, item := range obj.(*example3iov1.TestTypeList).Items { + list := &v1.TestTypeList{ListMeta: obj.(*v1.TestTypeList).ListMeta} + for _, item := range obj.(*v1.TestTypeList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -74,69 +73,69 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * } // Watch returns a watch.Interface that watches the requested testTypes. -func (c *FakeTestTypes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) } // Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Create(ctx context.Context, testType *example3iov1.TestType, opts v1.CreateOptions) (result *example3iov1.TestType, err error) { +func (c *FakeTestTypes) Create(ctx context.Context, testType *v1.TestType, opts metav1.CreateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example3iov1.TestType{}) + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example3iov1.TestType), err + return obj.(*v1.TestType), err } // Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Update(ctx context.Context, testType *example3iov1.TestType, opts v1.UpdateOptions) (result *example3iov1.TestType, err error) { +func (c *FakeTestTypes) Update(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example3iov1.TestType{}) + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example3iov1.TestType), err + return obj.(*v1.TestType), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *example3iov1.TestType, opts v1.UpdateOptions) (*example3iov1.TestType, error) { +func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (*v1.TestType, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example3iov1.TestType{}) + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example3iov1.TestType), err + return obj.(*v1.TestType), err } // Delete takes name of the testType and deletes it. Returns an error if one occurs. -func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &example3iov1.TestType{}) + Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &v1.TestType{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOpts) - _, err := c.Fake.Invokes(action, &example3iov1.TestTypeList{}) + _, err := c.Fake.Invokes(action, &v1.TestTypeList{}) return err } // Patch applies the patch and returns the patched testType. -func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *example3iov1.TestType, err error) { +func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &example3iov1.TestType{}) + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example3iov1.TestType), err + return obj.(*v1.TestType), err } diff --git a/examples/crd/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go b/examples/crd/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go index 18b1b5dc..4ee6812f 100644 --- a/examples/crd/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go +++ b/examples/crd/clientset/versioned/typed/example/v1/fake/fake_clustertesttype.go @@ -22,13 +22,12 @@ import ( "context" autoscalingv1 "k8s.io/api/autoscaling/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - examplev1 "k8s.io/code-generator/examples/crd/apis/example/v1" + v1 "k8s.io/code-generator/examples/crd/apis/example/v1" ) // FakeClusterTestTypes implements ClusterTestTypeInterface @@ -36,24 +35,24 @@ type FakeClusterTestTypes struct { Fake *FakeExampleV1 } -var clustertesttypesResource = schema.GroupVersionResource{Group: "example.crd.code-generator.k8s.io", Version: "v1", Resource: "clustertesttypes"} +var clustertesttypesResource = v1.SchemeGroupVersion.WithResource("clustertesttypes") -var clustertesttypesKind = schema.GroupVersionKind{Group: "example.crd.code-generator.k8s.io", Version: "v1", Kind: "ClusterTestType"} +var clustertesttypesKind = v1.SchemeGroupVersion.WithKind("ClusterTestType") // Get takes name of the clusterTestType, and returns the corresponding clusterTestType object, and an error if there is any. -func (c *FakeClusterTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootGetAction(clustertesttypesResource, name), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootGetAction(clustertesttypesResource, name), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // List takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors. -func (c *FakeClusterTestTypes) List(ctx context.Context, opts v1.ListOptions) (result *examplev1.ClusterTestTypeList, err error) { +func (c *FakeClusterTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) { obj, err := c.Fake. - Invokes(testing.NewRootListAction(clustertesttypesResource, clustertesttypesKind, opts), &examplev1.ClusterTestTypeList{}) + Invokes(testing.NewRootListAction(clustertesttypesResource, clustertesttypesKind, opts), &v1.ClusterTestTypeList{}) if obj == nil { return nil, err } @@ -62,8 +61,8 @@ func (c *FakeClusterTestTypes) List(ctx context.Context, opts v1.ListOptions) (r if label == nil { label = labels.Everything() } - list := &examplev1.ClusterTestTypeList{ListMeta: obj.(*examplev1.ClusterTestTypeList).ListMeta} - for _, item := range obj.(*examplev1.ClusterTestTypeList).Items { + list := &v1.ClusterTestTypeList{ListMeta: obj.(*v1.ClusterTestTypeList).ListMeta} + for _, item := range obj.(*v1.ClusterTestTypeList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -72,69 +71,69 @@ func (c *FakeClusterTestTypes) List(ctx context.Context, opts v1.ListOptions) (r } // Watch returns a watch.Interface that watches the requested clusterTestTypes. -func (c *FakeClusterTestTypes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeClusterTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewRootWatchAction(clustertesttypesResource, opts)) } // Create takes the representation of a clusterTestType and creates it. Returns the server's representation of the clusterTestType, and an error, if there is any. -func (c *FakeClusterTestTypes) Create(ctx context.Context, clusterTestType *examplev1.ClusterTestType, opts v1.CreateOptions) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Create(ctx context.Context, clusterTestType *v1.ClusterTestType, opts metav1.CreateOptions) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(clustertesttypesResource, clusterTestType), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootCreateAction(clustertesttypesResource, clusterTestType), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // Update takes the representation of a clusterTestType and updates it. Returns the server's representation of the clusterTestType, and an error, if there is any. -func (c *FakeClusterTestTypes) Update(ctx context.Context, clusterTestType *examplev1.ClusterTestType, opts v1.UpdateOptions) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Update(ctx context.Context, clusterTestType *v1.ClusterTestType, opts metav1.UpdateOptions) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(clustertesttypesResource, clusterTestType), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootUpdateAction(clustertesttypesResource, clusterTestType), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeClusterTestTypes) UpdateStatus(ctx context.Context, clusterTestType *examplev1.ClusterTestType, opts v1.UpdateOptions) (*examplev1.ClusterTestType, error) { +func (c *FakeClusterTestTypes) UpdateStatus(ctx context.Context, clusterTestType *v1.ClusterTestType, opts metav1.UpdateOptions) (*v1.ClusterTestType, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "status", clusterTestType), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "status", clusterTestType), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // Delete takes name of the clusterTestType and deletes it. Returns an error if one occurs. -func (c *FakeClusterTestTypes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeClusterTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(clustertesttypesResource, name, opts), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootDeleteActionWithOptions(clustertesttypesResource, name, opts), &v1.ClusterTestType{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeClusterTestTypes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeClusterTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewRootDeleteCollectionAction(clustertesttypesResource, listOpts) - _, err := c.Fake.Invokes(action, &examplev1.ClusterTestTypeList{}) + _, err := c.Fake.Invokes(action, &v1.ClusterTestTypeList{}) return err } // Patch applies the patch and returns the patched clusterTestType. -func (c *FakeClusterTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *examplev1.ClusterTestType, err error) { +func (c *FakeClusterTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ClusterTestType, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clustertesttypesResource, name, pt, data, subresources...), &examplev1.ClusterTestType{}) + Invokes(testing.NewRootPatchSubresourceAction(clustertesttypesResource, name, pt, data, subresources...), &v1.ClusterTestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.ClusterTestType), err + return obj.(*v1.ClusterTestType), err } // GetScale takes name of the clusterTestType, and returns the corresponding scale object, and an error if there is any. -func (c *FakeClusterTestTypes) GetScale(ctx context.Context, clusterTestTypeName string, options v1.GetOptions) (result *autoscalingv1.Scale, err error) { +func (c *FakeClusterTestTypes) GetScale(ctx context.Context, clusterTestTypeName string, options metav1.GetOptions) (result *autoscalingv1.Scale, err error) { obj, err := c.Fake. Invokes(testing.NewRootGetSubresourceAction(clustertesttypesResource, "scale", clusterTestTypeName), &autoscalingv1.Scale{}) if obj == nil { @@ -144,7 +143,7 @@ func (c *FakeClusterTestTypes) GetScale(ctx context.Context, clusterTestTypeName } // UpdateScale takes the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any. -func (c *FakeClusterTestTypes) UpdateScale(ctx context.Context, clusterTestTypeName string, scale *autoscalingv1.Scale, opts v1.UpdateOptions) (result *autoscalingv1.Scale, err error) { +func (c *FakeClusterTestTypes) UpdateScale(ctx context.Context, clusterTestTypeName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (result *autoscalingv1.Scale, err error) { obj, err := c.Fake. Invokes(testing.NewRootUpdateSubresourceAction(clustertesttypesResource, "scale", scale), &autoscalingv1.Scale{}) if obj == nil { diff --git a/examples/crd/clientset/versioned/typed/example/v1/fake/fake_testtype.go b/examples/crd/clientset/versioned/typed/example/v1/fake/fake_testtype.go index 38281d5e..a0cab07c 100644 --- a/examples/crd/clientset/versioned/typed/example/v1/fake/fake_testtype.go +++ b/examples/crd/clientset/versioned/typed/example/v1/fake/fake_testtype.go @@ -21,13 +21,12 @@ package fake import ( "context" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - examplev1 "k8s.io/code-generator/examples/crd/apis/example/v1" + v1 "k8s.io/code-generator/examples/crd/apis/example/v1" ) // FakeTestTypes implements TestTypeInterface @@ -36,25 +35,25 @@ type FakeTestTypes struct { ns string } -var testtypesResource = schema.GroupVersionResource{Group: "example.crd.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} +var testtypesResource = v1.SchemeGroupVersion.WithResource("testtypes") -var testtypesKind = schema.GroupVersionKind{Group: "example.crd.code-generator.k8s.io", Version: "v1", Kind: "TestType"} +var testtypesKind = v1.SchemeGroupVersion.WithKind("TestType") // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. -func (c *FakeTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &examplev1.TestType{}) + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result *examplev1.TestTypeList, err error) { +func (c *FakeTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &examplev1.TestTypeList{}) + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &v1.TestTypeList{}) if obj == nil { return nil, err @@ -64,8 +63,8 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * if label == nil { label = labels.Everything() } - list := &examplev1.TestTypeList{ListMeta: obj.(*examplev1.TestTypeList).ListMeta} - for _, item := range obj.(*examplev1.TestTypeList).Items { + list := &v1.TestTypeList{ListMeta: obj.(*v1.TestTypeList).ListMeta} + for _, item := range obj.(*v1.TestTypeList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -74,69 +73,69 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * } // Watch returns a watch.Interface that watches the requested testTypes. -func (c *FakeTestTypes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) } // Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Create(ctx context.Context, testType *examplev1.TestType, opts v1.CreateOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Create(ctx context.Context, testType *v1.TestType, opts metav1.CreateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Update(ctx context.Context, testType *examplev1.TestType, opts v1.UpdateOptions) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Update(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *examplev1.TestType, opts v1.UpdateOptions) (*examplev1.TestType, error) { +func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (*v1.TestType, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &examplev1.TestType{}) + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } // Delete takes name of the testType and deletes it. Returns an error if one occurs. -func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &examplev1.TestType{}) + Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &v1.TestType{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOpts) - _, err := c.Fake.Invokes(action, &examplev1.TestTypeList{}) + _, err := c.Fake.Invokes(action, &v1.TestTypeList{}) return err } // Patch applies the patch and returns the patched testType. -func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *examplev1.TestType, err error) { +func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &examplev1.TestType{}) + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*examplev1.TestType), err + return obj.(*v1.TestType), err } diff --git a/examples/crd/clientset/versioned/typed/example2/v1/fake/fake_testtype.go b/examples/crd/clientset/versioned/typed/example2/v1/fake/fake_testtype.go index cb6dfd96..c4f2d153 100644 --- a/examples/crd/clientset/versioned/typed/example2/v1/fake/fake_testtype.go +++ b/examples/crd/clientset/versioned/typed/example2/v1/fake/fake_testtype.go @@ -21,13 +21,12 @@ package fake import ( "context" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - example2v1 "k8s.io/code-generator/examples/crd/apis/example2/v1" + v1 "k8s.io/code-generator/examples/crd/apis/example2/v1" ) // FakeTestTypes implements TestTypeInterface @@ -36,25 +35,25 @@ type FakeTestTypes struct { ns string } -var testtypesResource = schema.GroupVersionResource{Group: "example.test.crd.code-generator.k8s.io", Version: "v1", Resource: "testtypes"} +var testtypesResource = v1.SchemeGroupVersion.WithResource("testtypes") -var testtypesKind = schema.GroupVersionKind{Group: "example.test.crd.code-generator.k8s.io", Version: "v1", Kind: "TestType"} +var testtypesKind = v1.SchemeGroupVersion.WithKind("TestType") // Get takes name of the testType, and returns the corresponding testType object, and an error if there is any. -func (c *FakeTestTypes) Get(ctx context.Context, name string, options v1.GetOptions) (result *example2v1.TestType, err error) { +func (c *FakeTestTypes) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &example2v1.TestType{}) + Invokes(testing.NewGetAction(testtypesResource, c.ns, name), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example2v1.TestType), err + return obj.(*v1.TestType), err } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result *example2v1.TestTypeList, err error) { +func (c *FakeTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &example2v1.TestTypeList{}) + Invokes(testing.NewListAction(testtypesResource, testtypesKind, c.ns, opts), &v1.TestTypeList{}) if obj == nil { return nil, err @@ -64,8 +63,8 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * if label == nil { label = labels.Everything() } - list := &example2v1.TestTypeList{ListMeta: obj.(*example2v1.TestTypeList).ListMeta} - for _, item := range obj.(*example2v1.TestTypeList).Items { + list := &v1.TestTypeList{ListMeta: obj.(*v1.TestTypeList).ListMeta} + for _, item := range obj.(*v1.TestTypeList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -74,69 +73,69 @@ func (c *FakeTestTypes) List(ctx context.Context, opts v1.ListOptions) (result * } // Watch returns a watch.Interface that watches the requested testTypes. -func (c *FakeTestTypes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(testtypesResource, c.ns, opts)) } // Create takes the representation of a testType and creates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Create(ctx context.Context, testType *example2v1.TestType, opts v1.CreateOptions) (result *example2v1.TestType, err error) { +func (c *FakeTestTypes) Create(ctx context.Context, testType *v1.TestType, opts metav1.CreateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &example2v1.TestType{}) + Invokes(testing.NewCreateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example2v1.TestType), err + return obj.(*v1.TestType), err } // Update takes the representation of a testType and updates it. Returns the server's representation of the testType, and an error, if there is any. -func (c *FakeTestTypes) Update(ctx context.Context, testType *example2v1.TestType, opts v1.UpdateOptions) (result *example2v1.TestType, err error) { +func (c *FakeTestTypes) Update(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &example2v1.TestType{}) + Invokes(testing.NewUpdateAction(testtypesResource, c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example2v1.TestType), err + return obj.(*v1.TestType), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *example2v1.TestType, opts v1.UpdateOptions) (*example2v1.TestType, error) { +func (c *FakeTestTypes) UpdateStatus(ctx context.Context, testType *v1.TestType, opts metav1.UpdateOptions) (*v1.TestType, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &example2v1.TestType{}) + Invokes(testing.NewUpdateSubresourceAction(testtypesResource, "status", c.ns, testType), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example2v1.TestType), err + return obj.(*v1.TestType), err } // Delete takes name of the testType and deletes it. Returns an error if one occurs. -func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { +func (c *FakeTestTypes) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &example2v1.TestType{}) + Invokes(testing.NewDeleteActionWithOptions(testtypesResource, c.ns, name, opts), &v1.TestType{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { +func (c *FakeTestTypes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { action := testing.NewDeleteCollectionAction(testtypesResource, c.ns, listOpts) - _, err := c.Fake.Invokes(action, &example2v1.TestTypeList{}) + _, err := c.Fake.Invokes(action, &v1.TestTypeList{}) return err } // Patch applies the patch and returns the patched testType. -func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *example2v1.TestType, err error) { +func (c *FakeTestTypes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.TestType, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &example2v1.TestType{}) + Invokes(testing.NewPatchSubresourceAction(testtypesResource, c.ns, name, pt, data, subresources...), &v1.TestType{}) if obj == nil { return nil, err } - return obj.(*example2v1.TestType), err + return obj.(*v1.TestType), err }