...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package k8s
16
17 import (
18 "context"
19 "fmt"
20
21 "k8s.io/apimachinery/pkg/api/meta"
22
23 "k8s.io/apimachinery/pkg/runtime"
24 "sigs.k8s.io/controller-runtime/pkg/client"
25 )
26
27 type errorClient struct {
28 }
29
30
31
32
33 func NewErroringClient() client.Client {
34 return &errorClient{}
35 }
36
37 func (e *errorClient) Get(_ context.Context, key client.ObjectKey, _ client.Object, _ ...client.GetOption) error {
38 return fmt.Errorf("unexpected call to client.Get(...) for %v", key)
39 }
40
41 func (e *errorClient) List(_ context.Context, _ client.ObjectList, _ ...client.ListOption) error {
42 return fmt.Errorf("unexpected call to client.List(...)")
43 }
44
45 func (e *errorClient) Create(_ context.Context, obj client.Object, _ ...client.CreateOption) error {
46 return fmt.Errorf("unexpected call to client.Create(...) for object with kind %v", obj.GetObjectKind())
47 }
48
49 func (e *errorClient) Delete(_ context.Context, obj client.Object, _ ...client.DeleteOption) error {
50 return fmt.Errorf("unexpected call to client.Delete(...) for object with kind %v", obj.GetObjectKind())
51 }
52
53 func (e *errorClient) Update(_ context.Context, obj client.Object, _ ...client.UpdateOption) error {
54 return fmt.Errorf("unexpected call to client.Update(...) for object with kind %v", obj.GetObjectKind())
55 }
56
57 func (e *errorClient) Patch(_ context.Context, obj client.Object, _ client.Patch, _ ...client.PatchOption) error {
58 return fmt.Errorf("unexpected call to client.Patch(...) for object with kind %v", obj.GetObjectKind())
59 }
60
61 func (e *errorClient) DeleteAllOf(_ context.Context, obj client.Object, _ ...client.DeleteAllOfOption) error {
62 return fmt.Errorf("unexpected call to client.DeleteAllOf(...) for object with kind %v", obj.GetObjectKind())
63 }
64
65 func (e *errorClient) Scheme() *runtime.Scheme {
66 panic("unexpected call to client.Scheme(...)")
67 }
68
69 func (e *errorClient) RESTMapper() meta.RESTMapper {
70 panic("unexpected call to client.RESTMapper(...)")
71 }
72
73 func (e *errorClient) Status() client.StatusWriter {
74 return e
75 }
76
View as plain text