Skip to content

Commit f9e4148

Browse files
committed
Accept narrower interfaces
The Get function only uses methods defined in client.Reader. The Delete function only uses methods defined in client.Writer. Therefore they can accept client.Reader and client.Writer, instead of client.Client, which combines both client.Reader and client.Writer. This change allows callers that can only pass in a client.Reader or client.Writer.
1 parent 691e5c4 commit f9e4148

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

controllers/external/util.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
)
3232

3333
// Get uses the client and reference to get an external, unstructured object.
34-
func Get(ctx context.Context, c client.Client, ref *corev1.ObjectReference, namespace string) (*unstructured.Unstructured, error) {
34+
func Get(ctx context.Context, c client.Reader, ref *corev1.ObjectReference, namespace string) (*unstructured.Unstructured, error) {
3535
if ref == nil {
3636
return nil, errors.Errorf("cannot get object - object reference not set")
3737
}
@@ -47,7 +47,7 @@ func Get(ctx context.Context, c client.Client, ref *corev1.ObjectReference, name
4747
}
4848

4949
// Delete uses the client and reference to delete an external, unstructured object.
50-
func Delete(ctx context.Context, c client.Client, ref *corev1.ObjectReference) error {
50+
func Delete(ctx context.Context, c client.Writer, ref *corev1.ObjectReference) error {
5151
obj := new(unstructured.Unstructured)
5252
obj.SetAPIVersion(ref.APIVersion)
5353
obj.SetKind(ref.Kind)

0 commit comments

Comments
 (0)