mirror of
https://github.com/kubernetes/sample-controller.git
synced 2025-05-04 04:43:01 +08:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a842537244 | ||
![]() |
d8c996121c | ||
![]() |
9c39f54fb0 | ||
![]() |
8f3fccb981 | ||
![]() |
741a4a2a28 | ||
![]() |
8582664224 |
10
go.mod
10
go.mod
@ -6,12 +6,14 @@ go 1.23.0
|
||||
|
||||
godebug default=go1.23
|
||||
|
||||
godebug winsymlink=0
|
||||
|
||||
require (
|
||||
golang.org/x/time v0.7.0
|
||||
k8s.io/api v0.0.0-20241105230147-1ddf895d7e74
|
||||
k8s.io/apimachinery v0.0.0-20241105225905-b5e810677b4f
|
||||
k8s.io/client-go v0.0.0-20241105230542-c1010ffd7de3
|
||||
k8s.io/code-generator v0.0.0-20241105231402-88802cbe5c31
|
||||
k8s.io/api v0.32.3
|
||||
k8s.io/apimachinery v0.32.3
|
||||
k8s.io/client-go v0.32.3
|
||||
k8s.io/code-generator v0.32.3
|
||||
k8s.io/klog/v2 v2.130.1
|
||||
)
|
||||
|
||||
|
16
go.sum
16
go.sum
@ -140,14 +140,14 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/api v0.0.0-20241105230147-1ddf895d7e74 h1:omoqr99s5DbyApsEajh0iIyKzGL/5vkvEgHn0P/q/NQ=
|
||||
k8s.io/api v0.0.0-20241105230147-1ddf895d7e74/go.mod h1:QMjNGKwUJOiB0TWCMJWLvhiVAvOrl9I+MTeV0dr56NE=
|
||||
k8s.io/apimachinery v0.0.0-20241105225905-b5e810677b4f h1:MTmedS366tu07Nh6HBoXS90/6DA5gP62gMyYTF+lT+Q=
|
||||
k8s.io/apimachinery v0.0.0-20241105225905-b5e810677b4f/go.mod h1:HqhdaJUgQqky29T1V0o2yFkt/pZqLFIDyn9Zi/8rxoY=
|
||||
k8s.io/client-go v0.0.0-20241105230542-c1010ffd7de3 h1:ZgoctdRlDLgbqPdEdcgyoyBbVGgNmfcokEkFYjpHZ68=
|
||||
k8s.io/client-go v0.0.0-20241105230542-c1010ffd7de3/go.mod h1:p8opQH8f5aM1YzHrN0yWNcD4qqfAJIaR0+kVTU/TIBw=
|
||||
k8s.io/code-generator v0.0.0-20241105231402-88802cbe5c31 h1:ZT/yC/53DdhNANUvb1irXAlLf4/v38tGDWFWI0SP2tw=
|
||||
k8s.io/code-generator v0.0.0-20241105231402-88802cbe5c31/go.mod h1:DjKky2Zt+GJ7WjeZvo+2J4MVUVMMFDkYyZlKKaMANDs=
|
||||
k8s.io/api v0.32.3 h1:Hw7KqxRusq+6QSplE3NYG4MBxZw1BZnq4aP4cJVINls=
|
||||
k8s.io/api v0.32.3/go.mod h1:2wEDTXADtm/HA7CCMD8D8bK4yuBUptzaRhYcYEEYA3k=
|
||||
k8s.io/apimachinery v0.32.3 h1:JmDuDarhDmA/Li7j3aPrwhpNBA94Nvk5zLeOge9HH1U=
|
||||
k8s.io/apimachinery v0.32.3/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
|
||||
k8s.io/client-go v0.32.3 h1:RKPVltzopkSgHS7aS98QdscAgtgah/+zmpAogooIqVU=
|
||||
k8s.io/client-go v0.32.3/go.mod h1:3v0+3k4IcT9bXTc4V2rt+d2ZPPG700Xy6Oi0Gdl2PaY=
|
||||
k8s.io/code-generator v0.32.3 h1:31p2TVzC9+hVdSkAFruAk3JY+iSfzrJ83Qij1yZutyw=
|
||||
k8s.io/code-generator v0.32.3/go.mod h1:+mbiYID5NLsBuqxjQTygKM/DAdKpAjvBzrJd64NU1G8=
|
||||
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 h1:si3PfKm8dDYxgfbeA6orqrtLkvvIeH8UqffFJDl0bz4=
|
||||
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU=
|
||||
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
|
||||
|
@ -19,129 +19,30 @@ limitations under the License.
|
||||
package fake
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
labels "k8s.io/apimachinery/pkg/labels"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
testing "k8s.io/client-go/testing"
|
||||
gentype "k8s.io/client-go/gentype"
|
||||
v1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
|
||||
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1"
|
||||
)
|
||||
|
||||
// FakeFoos implements FooInterface
|
||||
type FakeFoos struct {
|
||||
// fakeFoos implements FooInterface
|
||||
type fakeFoos struct {
|
||||
*gentype.FakeClientWithList[*v1alpha1.Foo, *v1alpha1.FooList]
|
||||
Fake *FakeSamplecontrollerV1alpha1
|
||||
ns string
|
||||
}
|
||||
|
||||
var foosResource = v1alpha1.SchemeGroupVersion.WithResource("foos")
|
||||
|
||||
var foosKind = v1alpha1.SchemeGroupVersion.WithKind("Foo")
|
||||
|
||||
// Get takes name of the foo, and returns the corresponding foo object, and an error if there is any.
|
||||
func (c *FakeFoos) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Foo, err error) {
|
||||
emptyResult := &v1alpha1.Foo{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetActionWithOptions(foosResource, c.ns, name, options), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return emptyResult, err
|
||||
func newFakeFoos(fake *FakeSamplecontrollerV1alpha1, namespace string) samplecontrollerv1alpha1.FooInterface {
|
||||
return &fakeFoos{
|
||||
gentype.NewFakeClientWithList[*v1alpha1.Foo, *v1alpha1.FooList](
|
||||
fake.Fake,
|
||||
namespace,
|
||||
v1alpha1.SchemeGroupVersion.WithResource("foos"),
|
||||
v1alpha1.SchemeGroupVersion.WithKind("Foo"),
|
||||
func() *v1alpha1.Foo { return &v1alpha1.Foo{} },
|
||||
func() *v1alpha1.FooList { return &v1alpha1.FooList{} },
|
||||
func(dst, src *v1alpha1.FooList) { dst.ListMeta = src.ListMeta },
|
||||
func(list *v1alpha1.FooList) []*v1alpha1.Foo { return gentype.ToPointerSlice(list.Items) },
|
||||
func(list *v1alpha1.FooList, items []*v1alpha1.Foo) { list.Items = gentype.FromPointerSlice(items) },
|
||||
),
|
||||
fake,
|
||||
}
|
||||
return obj.(*v1alpha1.Foo), err
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of Foos that match those selectors.
|
||||
func (c *FakeFoos) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FooList, err error) {
|
||||
emptyResult := &v1alpha1.FooList{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListActionWithOptions(foosResource, foosKind, c.ns, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return emptyResult, err
|
||||
}
|
||||
|
||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1alpha1.FooList{ListMeta: obj.(*v1alpha1.FooList).ListMeta}
|
||||
for _, item := range obj.(*v1alpha1.FooList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested foos.
|
||||
func (c *FakeFoos) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchActionWithOptions(foosResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Create takes the representation of a foo and creates it. Returns the server's representation of the foo, and an error, if there is any.
|
||||
func (c *FakeFoos) Create(ctx context.Context, foo *v1alpha1.Foo, opts v1.CreateOptions) (result *v1alpha1.Foo, err error) {
|
||||
emptyResult := &v1alpha1.Foo{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateActionWithOptions(foosResource, c.ns, foo, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return emptyResult, err
|
||||
}
|
||||
return obj.(*v1alpha1.Foo), err
|
||||
}
|
||||
|
||||
// Update takes the representation of a foo and updates it. Returns the server's representation of the foo, and an error, if there is any.
|
||||
func (c *FakeFoos) Update(ctx context.Context, foo *v1alpha1.Foo, opts v1.UpdateOptions) (result *v1alpha1.Foo, err error) {
|
||||
emptyResult := &v1alpha1.Foo{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateActionWithOptions(foosResource, c.ns, foo, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return emptyResult, err
|
||||
}
|
||||
return obj.(*v1alpha1.Foo), 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 *FakeFoos) UpdateStatus(ctx context.Context, foo *v1alpha1.Foo, opts v1.UpdateOptions) (result *v1alpha1.Foo, err error) {
|
||||
emptyResult := &v1alpha1.Foo{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateSubresourceActionWithOptions(foosResource, "status", c.ns, foo, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return emptyResult, err
|
||||
}
|
||||
return obj.(*v1alpha1.Foo), err
|
||||
}
|
||||
|
||||
// Delete takes name of the foo and deletes it. Returns an error if one occurs.
|
||||
func (c *FakeFoos) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteActionWithOptions(foosResource, c.ns, name, opts), &v1alpha1.Foo{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *FakeFoos) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionActionWithOptions(foosResource, c.ns, opts, listOpts)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1alpha1.FooList{})
|
||||
return err
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched foo.
|
||||
func (c *FakeFoos) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Foo, err error) {
|
||||
emptyResult := &v1alpha1.Foo{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceActionWithOptions(foosResource, c.ns, name, pt, data, opts, subresources...), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return emptyResult, err
|
||||
}
|
||||
return obj.(*v1alpha1.Foo), err
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ type FakeSamplecontrollerV1alpha1 struct {
|
||||
}
|
||||
|
||||
func (c *FakeSamplecontrollerV1alpha1) Foos(namespace string) v1alpha1.FooInterface {
|
||||
return &FakeFoos{c, namespace}
|
||||
return newFakeFoos(c, namespace)
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
|
Loading…
x
Reference in New Issue
Block a user