Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Support uncached for subresources
Browse files Browse the repository at this point in the history
Signed-off-by: Darren Shepherd <darren@acorn.io>
  • Loading branch information
ibuildthecloud committed Aug 9, 2023
1 parent dc9bf52 commit 5b03d4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pkg/runtime/cached.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ type subResourceClient struct {
}

func (s *subResourceClient) Get(ctx context.Context, obj kclient.Object, subResource kclient.Object, opts ...kclient.SubResourceGetOption) error {
return s.reader.Get(ctx, obj, subResource, opts...)
return s.reader.Get(ctx, uncached.Unwrap(obj).(kclient.Object), subResource, opts...)
}

func (s *subResourceClient) Create(ctx context.Context, obj kclient.Object, subResource kclient.Object, opts ...kclient.SubResourceCreateOption) error {
return s.writer.Create(ctx, obj, subResource, opts...)
return s.writer.Create(ctx, uncached.Unwrap(obj).(kclient.Object), subResource, opts...)
}

func (s *subResourceClient) Update(ctx context.Context, obj kclient.Object, opts ...kclient.SubResourceUpdateOption) error {
err := s.writer.Update(ctx, obj, opts...)
err := s.writer.Update(ctx, uncached.Unwrap(obj).(kclient.Object), opts...)
if err != nil {
return err
}
Expand All @@ -248,7 +248,7 @@ func (s *subResourceClient) Update(ctx context.Context, obj kclient.Object, opts
}

func (s *subResourceClient) Patch(ctx context.Context, obj kclient.Object, patch kclient.Patch, opts ...kclient.SubResourcePatchOption) error {
err := s.writer.Patch(ctx, obj, patch, opts...)
err := s.writer.Patch(ctx, uncached.Unwrap(obj).(kclient.Object), patch, opts...)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/runtime/multi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/acorn-io/baaah/pkg/uncached"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -154,7 +155,7 @@ func (m multiClient) Watch(ctx context.Context, obj kclient.ObjectList, opts ...
}

func (m multiClient) getClient(obj runtime.Object) (kclient.WithWatch, error) {
gvk, err := m.GroupVersionKindFor(obj)
gvk, err := m.GroupVersionKindFor(uncached.Unwrap(obj))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 5b03d4c

Please sign in to comment.