Skip to content

Commit 647d62e

Browse files
committed
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) ```
1 parent 4675c15 commit 647d62e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

memorystore/memorystore.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ func (s *Store) Create(_ context.Context, obj client.Object, opts ...client.Crea
111111
}
112112

113113
// Get implements client.Get.
114-
func (s *Store) Get(_ context.Context, objectKey client.ObjectKey, obj client.Object) error {
114+
func (s *Store) Get(_ context.Context, objectKey client.ObjectKey, obj client.Object, opts ...client.GetOption) error {
115+
o := &client.GetOptions{}
116+
o.ApplyOptions(opts)
117+
if err := validateClientGetOptions(o); err != nil {
118+
return err
119+
}
120+
115121
key, err := clientutils.ObjectRefFromObject(s.scheme, obj)
116122
if err != nil {
117123
return err
@@ -129,6 +135,13 @@ func (s *Store) Get(_ context.Context, objectKey client.ObjectKey, obj client.Ob
129135
return s.scheme.Convert(v, obj, nil)
130136
}
131137

138+
func validateClientGetOptions(opts *client.GetOptions) error {
139+
if opts.Raw != nil {
140+
return fmt.Errorf("raw is not supported")
141+
}
142+
return nil
143+
}
144+
132145
func validateClientListOptions(opts *client.ListOptions) error {
133146
if opts.Raw != nil {
134147
return fmt.Errorf("raw is not supported")

0 commit comments

Comments
 (0)