1
16
17 package client
18
19 import (
20 "context"
21
22 "k8s.io/apimachinery/pkg/api/meta"
23 "k8s.io/apimachinery/pkg/runtime"
24 "k8s.io/apimachinery/pkg/runtime/schema"
25 )
26
27
28
29 func NewDryRunClient(c Client) Client {
30 return &dryRunClient{client: c}
31 }
32
33 var _ Client = &dryRunClient{}
34
35
36 type dryRunClient struct {
37 client Client
38 }
39
40
41 func (c *dryRunClient) Scheme() *runtime.Scheme {
42 return c.client.Scheme()
43 }
44
45
46 func (c *dryRunClient) RESTMapper() meta.RESTMapper {
47 return c.client.RESTMapper()
48 }
49
50
51 func (c *dryRunClient) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error) {
52 return c.client.GroupVersionKindFor(obj)
53 }
54
55
56 func (c *dryRunClient) IsObjectNamespaced(obj runtime.Object) (bool, error) {
57 return c.client.IsObjectNamespaced(obj)
58 }
59
60
61 func (c *dryRunClient) Create(ctx context.Context, obj Object, opts ...CreateOption) error {
62 return c.client.Create(ctx, obj, append(opts, DryRunAll)...)
63 }
64
65
66 func (c *dryRunClient) Update(ctx context.Context, obj Object, opts ...UpdateOption) error {
67 return c.client.Update(ctx, obj, append(opts, DryRunAll)...)
68 }
69
70
71 func (c *dryRunClient) Delete(ctx context.Context, obj Object, opts ...DeleteOption) error {
72 return c.client.Delete(ctx, obj, append(opts, DryRunAll)...)
73 }
74
75
76 func (c *dryRunClient) DeleteAllOf(ctx context.Context, obj Object, opts ...DeleteAllOfOption) error {
77 return c.client.DeleteAllOf(ctx, obj, append(opts, DryRunAll)...)
78 }
79
80
81 func (c *dryRunClient) Patch(ctx context.Context, obj Object, patch Patch, opts ...PatchOption) error {
82 return c.client.Patch(ctx, obj, patch, append(opts, DryRunAll)...)
83 }
84
85
86 func (c *dryRunClient) Get(ctx context.Context, key ObjectKey, obj Object, opts ...GetOption) error {
87 return c.client.Get(ctx, key, obj, opts...)
88 }
89
90
91 func (c *dryRunClient) List(ctx context.Context, obj ObjectList, opts ...ListOption) error {
92 return c.client.List(ctx, obj, opts...)
93 }
94
95
96 func (c *dryRunClient) Status() SubResourceWriter {
97 return c.SubResource("status")
98 }
99
100
101 func (c *dryRunClient) SubResource(subResource string) SubResourceClient {
102 return &dryRunSubResourceClient{client: c.client.SubResource(subResource)}
103 }
104
105
106 var _ SubResourceWriter = &dryRunSubResourceClient{}
107
108
109
110 type dryRunSubResourceClient struct {
111 client SubResourceClient
112 }
113
114 func (sw *dryRunSubResourceClient) Get(ctx context.Context, obj, subResource Object, opts ...SubResourceGetOption) error {
115 return sw.client.Get(ctx, obj, subResource, opts...)
116 }
117
118 func (sw *dryRunSubResourceClient) Create(ctx context.Context, obj, subResource Object, opts ...SubResourceCreateOption) error {
119 return sw.client.Create(ctx, obj, subResource, append(opts, DryRunAll)...)
120 }
121
122
123 func (sw *dryRunSubResourceClient) Update(ctx context.Context, obj Object, opts ...SubResourceUpdateOption) error {
124 return sw.client.Update(ctx, obj, append(opts, DryRunAll)...)
125 }
126
127
128 func (sw *dryRunSubResourceClient) Patch(ctx context.Context, obj Object, patch Patch, opts ...SubResourcePatchOption) error {
129 return sw.client.Patch(ctx, obj, patch, append(opts, DryRunAll)...)
130 }
131
View as plain text