Skip to content

Commit 1505413

Browse files
committed
chore: safeguards
Signed-off-by: Armando Ruocco <[email protected]>
1 parent af6be5c commit 1505413

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

internal/client/client.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,58 @@ func (e *ExtendedClient) RemoveSecret(key client.ObjectKey) {
107107
}
108108
}
109109
}
110+
111+
func (e *ExtendedClient) Update(
112+
ctx context.Context,
113+
obj client.Object,
114+
opts ...client.UpdateOption,
115+
) error {
116+
if e.isCacheDisabled() {
117+
return e.Client.Update(ctx, obj, opts...)
118+
}
119+
120+
if _, ok := obj.(*corev1.Secret); !ok {
121+
return e.Client.Update(ctx, obj, opts...)
122+
}
123+
124+
e.RemoveSecret(client.ObjectKeyFromObject(obj))
125+
126+
return e.Client.Update(ctx, obj, opts...)
127+
}
128+
129+
func (e *ExtendedClient) Delete(
130+
ctx context.Context,
131+
obj client.Object,
132+
opts ...client.DeleteOption,
133+
) error {
134+
if e.isCacheDisabled() {
135+
return e.Client.Delete(ctx, obj, opts...)
136+
}
137+
138+
if _, ok := obj.(*corev1.Secret); !ok {
139+
return e.Client.Delete(ctx, obj, opts...)
140+
}
141+
142+
e.RemoveSecret(client.ObjectKeyFromObject(obj))
143+
144+
return e.Client.Delete(ctx, obj, opts...)
145+
}
146+
147+
func (e *ExtendedClient) Patch(
148+
ctx context.Context,
149+
obj client.Object,
150+
patch client.Patch,
151+
opts ...client.PatchOption,
152+
) error {
153+
if e.isCacheDisabled() {
154+
return e.Client.Patch(ctx, obj, patch, opts...)
155+
}
156+
157+
if _, ok := obj.(*corev1.Secret); !ok {
158+
return e.Client.Patch(ctx, obj, patch, opts...)
159+
}
160+
161+
e.RemoveSecret(client.ObjectKeyFromObject(obj))
162+
163+
return e.Client.Patch(ctx, obj, patch, opts...)
164+
}

0 commit comments

Comments
 (0)