K8s: Fix hack/update-codegen (#91867)
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
|
||||
)
|
||||
|
||||
// ExternalNameApplyConfiguration represents an declarative configuration of the ExternalName type for use
|
||||
// ExternalNameApplyConfiguration represents a declarative configuration of the ExternalName type for use
|
||||
// with apply.
|
||||
type ExternalNameApplyConfiguration struct {
|
||||
v1.TypeMetaApplyConfiguration `json:",inline"`
|
||||
@@ -18,7 +18,7 @@ type ExternalNameApplyConfiguration struct {
|
||||
Spec *ExternalNameSpecApplyConfiguration `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
// ExternalName constructs an declarative configuration of the ExternalName type for use with
|
||||
// ExternalName constructs a declarative configuration of the ExternalName type for use with
|
||||
// apply.
|
||||
func ExternalName(name, namespace string) *ExternalNameApplyConfiguration {
|
||||
b := &ExternalNameApplyConfiguration{}
|
||||
@@ -194,3 +194,9 @@ func (b *ExternalNameApplyConfiguration) WithSpec(value *ExternalNameSpecApplyCo
|
||||
b.Spec = value
|
||||
return b
|
||||
}
|
||||
|
||||
// GetName retrieves the value of the Name field in the declarative configuration.
|
||||
func (b *ExternalNameApplyConfiguration) GetName() *string {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
return b.Name
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
package v0alpha1
|
||||
|
||||
// ExternalNameSpecApplyConfiguration represents an declarative configuration of the ExternalNameSpec type for use
|
||||
// ExternalNameSpecApplyConfiguration represents a declarative configuration of the ExternalNameSpec type for use
|
||||
// with apply.
|
||||
type ExternalNameSpecApplyConfiguration struct {
|
||||
Host *string `json:"host,omitempty"`
|
||||
}
|
||||
|
||||
// ExternalNameSpecApplyConfiguration constructs an declarative configuration of the ExternalNameSpec type for use with
|
||||
// ExternalNameSpecApplyConfiguration constructs a declarative configuration of the ExternalNameSpec type for use with
|
||||
// apply.
|
||||
func ExternalNameSpec() *ExternalNameSpecApplyConfiguration {
|
||||
return &ExternalNameSpecApplyConfiguration{}
|
||||
|
||||
@@ -8,8 +8,11 @@ import (
|
||||
v0alpha1 "github.com/grafana/grafana/pkg/apis/alerting_notifications/v0alpha1"
|
||||
servicev0alpha1 "github.com/grafana/grafana/pkg/apis/service/v0alpha1"
|
||||
alertingnotificationsv0alpha1 "github.com/grafana/grafana/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1"
|
||||
internal "github.com/grafana/grafana/pkg/generated/applyconfiguration/internal"
|
||||
applyconfigurationservicev0alpha1 "github.com/grafana/grafana/pkg/generated/applyconfiguration/service/v0alpha1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no
|
||||
@@ -41,3 +44,7 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewTypeConverter(scheme *runtime.Scheme) *testing.TypeConverter {
|
||||
return &testing.TypeConverter{Scheme: scheme, TypeResolver: internal.Parser()}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package fake
|
||||
|
||||
import (
|
||||
applyconfiguration "github.com/grafana/grafana/pkg/generated/applyconfiguration"
|
||||
clientset "github.com/grafana/grafana/pkg/generated/clientset/versioned"
|
||||
notificationsv0alpha1 "github.com/grafana/grafana/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1"
|
||||
fakenotificationsv0alpha1 "github.com/grafana/grafana/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/fake"
|
||||
@@ -19,8 +20,12 @@ import (
|
||||
|
||||
// NewSimpleClientset returns a clientset that will respond with the provided objects.
|
||||
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
|
||||
// without applying any validations and/or defaults. It shouldn't be considered a replacement
|
||||
// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement
|
||||
// for a real clientset and is mostly useful in simple unit tests.
|
||||
//
|
||||
// DEPRECATED: NewClientset replaces this with support for field management, which significantly improves
|
||||
// server side apply testing. NewClientset is only available when apply configurations are generated (e.g.
|
||||
// via --with-applyconfig).
|
||||
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
|
||||
for _, obj := range objects {
|
||||
@@ -62,6 +67,38 @@ func (c *Clientset) Tracker() testing.ObjectTracker {
|
||||
return c.tracker
|
||||
}
|
||||
|
||||
// NewClientset returns a clientset that will respond with the provided objects.
|
||||
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
|
||||
// without applying any validations and/or defaults. It shouldn't be considered a replacement
|
||||
// for a real clientset and is mostly useful in simple unit tests.
|
||||
func NewClientset(objects ...runtime.Object) *Clientset {
|
||||
o := testing.NewFieldManagedObjectTracker(
|
||||
scheme,
|
||||
codecs.UniversalDecoder(),
|
||||
applyconfiguration.NewTypeConverter(scheme),
|
||||
)
|
||||
for _, obj := range objects {
|
||||
if err := o.Add(obj); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
cs := &Clientset{tracker: o}
|
||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
gvr := action.GetResource()
|
||||
ns := action.GetNamespace()
|
||||
watch, err := o.Watch(gvr, ns)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
return true, watch, nil
|
||||
})
|
||||
|
||||
return cs
|
||||
}
|
||||
|
||||
var (
|
||||
_ clientset.Interface = &Clientset{}
|
||||
_ testing.FakeClient = &Clientset{}
|
||||
|
||||
@@ -6,9 +6,6 @@ package v0alpha1
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
v0alpha1 "github.com/grafana/grafana/pkg/apis/service/v0alpha1"
|
||||
servicev0alpha1 "github.com/grafana/grafana/pkg/generated/applyconfiguration/service/v0alpha1"
|
||||
@@ -16,7 +13,7 @@ import (
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
gentype "k8s.io/client-go/gentype"
|
||||
)
|
||||
|
||||
// ExternalNamesGetter has a method to return a ExternalNameInterface.
|
||||
@@ -41,154 +38,18 @@ type ExternalNameInterface interface {
|
||||
|
||||
// externalNames implements ExternalNameInterface
|
||||
type externalNames struct {
|
||||
client rest.Interface
|
||||
ns string
|
||||
*gentype.ClientWithListAndApply[*v0alpha1.ExternalName, *v0alpha1.ExternalNameList, *servicev0alpha1.ExternalNameApplyConfiguration]
|
||||
}
|
||||
|
||||
// newExternalNames returns a ExternalNames
|
||||
func newExternalNames(c *ServiceV0alpha1Client, namespace string) *externalNames {
|
||||
return &externalNames{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
gentype.NewClientWithListAndApply[*v0alpha1.ExternalName, *v0alpha1.ExternalNameList, *servicev0alpha1.ExternalNameApplyConfiguration](
|
||||
"externalnames",
|
||||
c.RESTClient(),
|
||||
scheme.ParameterCodec,
|
||||
namespace,
|
||||
func() *v0alpha1.ExternalName { return &v0alpha1.ExternalName{} },
|
||||
func() *v0alpha1.ExternalNameList { return &v0alpha1.ExternalNameList{} }),
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the externalName, and returns the corresponding externalName object, and an error if there is any.
|
||||
func (c *externalNames) Get(ctx context.Context, name string, options v1.GetOptions) (result *v0alpha1.ExternalName, err error) {
|
||||
result = &v0alpha1.ExternalName{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("externalnames").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of ExternalNames that match those selectors.
|
||||
func (c *externalNames) List(ctx context.Context, opts v1.ListOptions) (result *v0alpha1.ExternalNameList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v0alpha1.ExternalNameList{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("externalnames").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested externalNames.
|
||||
func (c *externalNames) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("externalnames").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch(ctx)
|
||||
}
|
||||
|
||||
// Create takes the representation of a externalName and creates it. Returns the server's representation of the externalName, and an error, if there is any.
|
||||
func (c *externalNames) Create(ctx context.Context, externalName *v0alpha1.ExternalName, opts v1.CreateOptions) (result *v0alpha1.ExternalName, err error) {
|
||||
result = &v0alpha1.ExternalName{}
|
||||
err = c.client.Post().
|
||||
Namespace(c.ns).
|
||||
Resource("externalnames").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(externalName).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Update takes the representation of a externalName and updates it. Returns the server's representation of the externalName, and an error, if there is any.
|
||||
func (c *externalNames) Update(ctx context.Context, externalName *v0alpha1.ExternalName, opts v1.UpdateOptions) (result *v0alpha1.ExternalName, err error) {
|
||||
result = &v0alpha1.ExternalName{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("externalnames").
|
||||
Name(externalName.Name).
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(externalName).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the externalName and deletes it. Returns an error if one occurs.
|
||||
func (c *externalNames) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("externalnames").
|
||||
Name(name).
|
||||
Body(&opts).
|
||||
Do(ctx).
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *externalNames) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
|
||||
var timeout time.Duration
|
||||
if listOpts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("externalnames").
|
||||
VersionedParams(&listOpts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(&opts).
|
||||
Do(ctx).
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched externalName.
|
||||
func (c *externalNames) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v0alpha1.ExternalName, err error) {
|
||||
result = &v0alpha1.ExternalName{}
|
||||
err = c.client.Patch(pt).
|
||||
Namespace(c.ns).
|
||||
Resource("externalnames").
|
||||
Name(name).
|
||||
SubResource(subresources...).
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied externalName.
|
||||
func (c *externalNames) Apply(ctx context.Context, externalName *servicev0alpha1.ExternalNameApplyConfiguration, opts v1.ApplyOptions) (result *v0alpha1.ExternalName, err error) {
|
||||
if externalName == nil {
|
||||
return nil, fmt.Errorf("externalName provided to Apply must not be nil")
|
||||
}
|
||||
patchOpts := opts.ToPatchOptions()
|
||||
data, err := json.Marshal(externalName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := externalName.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("externalName.Name must be provided to Apply")
|
||||
}
|
||||
result = &v0alpha1.ExternalName{}
|
||||
err = c.client.Patch(types.ApplyPatchType).
|
||||
Namespace(c.ns).
|
||||
Resource("externalnames").
|
||||
Name(*name).
|
||||
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
+20
-14
@@ -30,22 +30,24 @@ var externalnamesKind = v0alpha1.SchemeGroupVersion.WithKind("ExternalName")
|
||||
|
||||
// Get takes name of the externalName, and returns the corresponding externalName object, and an error if there is any.
|
||||
func (c *FakeExternalNames) Get(ctx context.Context, name string, options v1.GetOptions) (result *v0alpha1.ExternalName, err error) {
|
||||
emptyResult := &v0alpha1.ExternalName{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(externalnamesResource, c.ns, name), &v0alpha1.ExternalName{})
|
||||
Invokes(testing.NewGetActionWithOptions(externalnamesResource, c.ns, name, options), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, err
|
||||
}
|
||||
return obj.(*v0alpha1.ExternalName), err
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of ExternalNames that match those selectors.
|
||||
func (c *FakeExternalNames) List(ctx context.Context, opts v1.ListOptions) (result *v0alpha1.ExternalNameList, err error) {
|
||||
emptyResult := &v0alpha1.ExternalNameList{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(externalnamesResource, externalnamesKind, c.ns, opts), &v0alpha1.ExternalNameList{})
|
||||
Invokes(testing.NewListActionWithOptions(externalnamesResource, externalnamesKind, c.ns, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, err
|
||||
}
|
||||
|
||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||
@@ -64,28 +66,30 @@ func (c *FakeExternalNames) List(ctx context.Context, opts v1.ListOptions) (resu
|
||||
// Watch returns a watch.Interface that watches the requested externalNames.
|
||||
func (c *FakeExternalNames) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(externalnamesResource, c.ns, opts))
|
||||
InvokesWatch(testing.NewWatchActionWithOptions(externalnamesResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Create takes the representation of a externalName and creates it. Returns the server's representation of the externalName, and an error, if there is any.
|
||||
func (c *FakeExternalNames) Create(ctx context.Context, externalName *v0alpha1.ExternalName, opts v1.CreateOptions) (result *v0alpha1.ExternalName, err error) {
|
||||
emptyResult := &v0alpha1.ExternalName{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(externalnamesResource, c.ns, externalName), &v0alpha1.ExternalName{})
|
||||
Invokes(testing.NewCreateActionWithOptions(externalnamesResource, c.ns, externalName, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, err
|
||||
}
|
||||
return obj.(*v0alpha1.ExternalName), err
|
||||
}
|
||||
|
||||
// Update takes the representation of a externalName and updates it. Returns the server's representation of the externalName, and an error, if there is any.
|
||||
func (c *FakeExternalNames) Update(ctx context.Context, externalName *v0alpha1.ExternalName, opts v1.UpdateOptions) (result *v0alpha1.ExternalName, err error) {
|
||||
emptyResult := &v0alpha1.ExternalName{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(externalnamesResource, c.ns, externalName), &v0alpha1.ExternalName{})
|
||||
Invokes(testing.NewUpdateActionWithOptions(externalnamesResource, c.ns, externalName, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, err
|
||||
}
|
||||
return obj.(*v0alpha1.ExternalName), err
|
||||
}
|
||||
@@ -100,7 +104,7 @@ func (c *FakeExternalNames) Delete(ctx context.Context, name string, opts v1.Del
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *FakeExternalNames) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(externalnamesResource, c.ns, listOpts)
|
||||
action := testing.NewDeleteCollectionActionWithOptions(externalnamesResource, c.ns, opts, listOpts)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v0alpha1.ExternalNameList{})
|
||||
return err
|
||||
@@ -108,11 +112,12 @@ func (c *FakeExternalNames) DeleteCollection(ctx context.Context, opts v1.Delete
|
||||
|
||||
// Patch applies the patch and returns the patched externalName.
|
||||
func (c *FakeExternalNames) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v0alpha1.ExternalName, err error) {
|
||||
emptyResult := &v0alpha1.ExternalName{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(externalnamesResource, c.ns, name, pt, data, subresources...), &v0alpha1.ExternalName{})
|
||||
Invokes(testing.NewPatchSubresourceActionWithOptions(externalnamesResource, c.ns, name, pt, data, opts, subresources...), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, err
|
||||
}
|
||||
return obj.(*v0alpha1.ExternalName), err
|
||||
}
|
||||
@@ -130,11 +135,12 @@ func (c *FakeExternalNames) Apply(ctx context.Context, externalName *servicev0al
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("externalName.Name must be provided to Apply")
|
||||
}
|
||||
emptyResult := &v0alpha1.ExternalName{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(externalnamesResource, c.ns, *name, types.ApplyPatchType, data), &v0alpha1.ExternalName{})
|
||||
Invokes(testing.NewPatchSubresourceActionWithOptions(externalnamesResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, err
|
||||
}
|
||||
return obj.(*v0alpha1.ExternalName), err
|
||||
}
|
||||
|
||||
@@ -215,6 +215,7 @@ type SharedInformerFactory interface {
|
||||
|
||||
// Start initializes all requested informers. They are handled in goroutines
|
||||
// which run until the stop channel gets closed.
|
||||
// Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync.
|
||||
Start(stopCh <-chan struct{})
|
||||
|
||||
// Shutdown marks a factory as shutting down. At that point no new
|
||||
|
||||
@@ -6,8 +6,8 @@ package v0alpha1
|
||||
|
||||
import (
|
||||
v0alpha1 "github.com/grafana/grafana/pkg/apis/service/v0alpha1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/listers"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
@@ -24,25 +24,17 @@ type ExternalNameLister interface {
|
||||
|
||||
// externalNameLister implements the ExternalNameLister interface.
|
||||
type externalNameLister struct {
|
||||
indexer cache.Indexer
|
||||
listers.ResourceIndexer[*v0alpha1.ExternalName]
|
||||
}
|
||||
|
||||
// NewExternalNameLister returns a new ExternalNameLister.
|
||||
func NewExternalNameLister(indexer cache.Indexer) ExternalNameLister {
|
||||
return &externalNameLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all ExternalNames in the indexer.
|
||||
func (s *externalNameLister) List(selector labels.Selector) (ret []*v0alpha1.ExternalName, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v0alpha1.ExternalName))
|
||||
})
|
||||
return ret, err
|
||||
return &externalNameLister{listers.New[*v0alpha1.ExternalName](indexer, v0alpha1.Resource("externalname"))}
|
||||
}
|
||||
|
||||
// ExternalNames returns an object that can list and get ExternalNames.
|
||||
func (s *externalNameLister) ExternalNames(namespace string) ExternalNameNamespaceLister {
|
||||
return externalNameNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
return externalNameNamespaceLister{listers.NewNamespaced[*v0alpha1.ExternalName](s.ResourceIndexer, namespace)}
|
||||
}
|
||||
|
||||
// ExternalNameNamespaceLister helps list and get ExternalNames.
|
||||
@@ -60,26 +52,5 @@ type ExternalNameNamespaceLister interface {
|
||||
// externalNameNamespaceLister implements the ExternalNameNamespaceLister
|
||||
// interface.
|
||||
type externalNameNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all ExternalNames in the indexer for a given namespace.
|
||||
func (s externalNameNamespaceLister) List(selector labels.Selector) (ret []*v0alpha1.ExternalName, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v0alpha1.ExternalName))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the ExternalName from the indexer for a given namespace and name.
|
||||
func (s externalNameNamespaceLister) Get(name string) (*v0alpha1.ExternalName, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v0alpha1.Resource("externalname"), name)
|
||||
}
|
||||
return obj.(*v0alpha1.ExternalName), nil
|
||||
listers.ResourceIndexer[*v0alpha1.ExternalName]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user