From 647d62e4f2884cd4d090b990d4cc9ae50b4c9d5a Mon Sep 17 00:00:00 2001 From: Andreas Fritzler Date: Mon, 16 Jan 2023 13:20:26 +0100 Subject: [PATCH] Add `GetOptions` to client GET method As the client interface has changed with kube 1.26 the `GetOptions` has now to be passed in the GET method. Otherwise you might end up with the following error: ``` cannot use s (variable of type *memorystore.Store) as client.Client value in argument to utils.GetSecretSelector: *memorystore.Store does not implement client.Client (wrong type for method Get) have Get(_ context.Context, objectKey types.NamespacedName, obj client.Object) error want Get(ctx context.Context, key types.NamespacedName, obj client.Object, opts ...client.GetOption) error (typecheck) ``` --- memorystore/memorystore.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/memorystore/memorystore.go b/memorystore/memorystore.go index b79680a..aa29ba2 100644 --- a/memorystore/memorystore.go +++ b/memorystore/memorystore.go @@ -111,7 +111,13 @@ func (s *Store) Create(_ context.Context, obj client.Object, opts ...client.Crea } // Get implements client.Get. -func (s *Store) Get(_ context.Context, objectKey client.ObjectKey, obj client.Object) error { +func (s *Store) Get(_ context.Context, objectKey client.ObjectKey, obj client.Object, opts ...client.GetOption) error { + o := &client.GetOptions{} + o.ApplyOptions(opts) + if err := validateClientGetOptions(o); err != nil { + return err + } + key, err := clientutils.ObjectRefFromObject(s.scheme, obj) if err != nil { return err @@ -129,6 +135,13 @@ func (s *Store) Get(_ context.Context, objectKey client.ObjectKey, obj client.Ob return s.scheme.Convert(v, obj, nil) } +func validateClientGetOptions(opts *client.GetOptions) error { + if opts.Raw != nil { + return fmt.Errorf("raw is not supported") + } + return nil +} + func validateClientListOptions(opts *client.ListOptions) error { if opts.Raw != nil { return fmt.Errorf("raw is not supported")