Skip to content

Commit 73adcbd

Browse files
authored
Add missing SubResource methods to MemoryStore (#172)
1 parent 7f5baf1 commit 73adcbd

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

memorystore/memorystore.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ type Store struct {
4242
entries map[clientutils.ObjectRef]client.Object
4343
}
4444

45+
// ensure Store implements client.Client
46+
var _ client.Client = (*Store)(nil)
47+
4548
// Objects returns all objects that are stored in this store.
4649
func (s *Store) Objects() []client.Object {
4750
res := make([]client.Object, 0, len(s.entries))
@@ -306,6 +309,43 @@ func (s *Store) Patch(_ context.Context, _ client.Object, _ client.Patch, _ ...c
306309
return fmt.Errorf("patch is not supported")
307310
}
308311

312+
// Status implements client.StatusClient.
313+
func (s *Store) Status() client.SubResourceWriter {
314+
return s.SubResource("status")
315+
}
316+
317+
func (s *Store) SubResource(subResource string) client.SubResourceClient {
318+
return &subResourceClient{client: s, subResource: subResource}
319+
}
320+
321+
// subResourceClient is client.SubResourceWriter that writes to subresources.
322+
type subResourceClient struct {
323+
client *Store
324+
subResource string
325+
}
326+
327+
// ensure subResourceClient implements client.SubResourceClient.
328+
var _ client.SubResourceClient = (*subResourceClient)(nil)
329+
330+
func (sc *subResourceClient) Get(ctx context.Context, obj client.Object, subResource client.Object, opts ...client.SubResourceGetOption) error {
331+
return fmt.Errorf("get is not supported")
332+
}
333+
334+
// Create implements client.SubResourceClient
335+
func (sc *subResourceClient) Create(ctx context.Context, obj client.Object, subResource client.Object, opts ...client.SubResourceCreateOption) error {
336+
return fmt.Errorf("create is not supported")
337+
}
338+
339+
// Update implements client.SubResourceClient
340+
func (sc *subResourceClient) Update(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error {
341+
return fmt.Errorf("update is not supported")
342+
}
343+
344+
// Patch implements client.SubResourceWriter.
345+
func (sc *subResourceClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.SubResourcePatchOption) error {
346+
return fmt.Errorf("patch is not supported")
347+
}
348+
309349
// Scheme returns the used scheme of the Store.
310350
func (s *Store) Scheme() *runtime.Scheme {
311351
return s.scheme

0 commit comments

Comments
 (0)