@@ -104,50 +104,50 @@ func TestEnsureTrustedCABundleConfigMap(t *testing.T) {
104104 if cm .Labels [trustedCABundleInjectLabel ] != "true" {
105105 t .Errorf ("expected inject label in patch target, got %q" , cm .Labels [trustedCABundleInjectLabel ])
106106 }
107- if patch .Type () != types .MergePatchType {
108- t .Errorf ("expected MergePatch, got %s" , patch .Type ())
109- }
110- return nil
111- })
112- },
113- wantPatch : true ,
107+ if patch .Type () != types .JSONPatchType {
108+ t .Errorf ("expected JSONPatch, got %s" , patch .Type ())
109+ }
110+ return nil
111+ })
114112 },
115- {
116- // Regression test for: labels updating with app: external-secrets of cm
117- // external-secrets-trusted-ca-bundle will block the reconcile in the http_proxy env.
118- //
119- // When the managed label (app= external-secrets) is removed from the ConfigMap,
120- // the object falls out of the label-filtered cache. The cached Exists() returns
121- // false, Create() fails with AlreadyExists, and the controller must patch only
122- // the metadata (labels/annotations), leaving CNO-managed Data/BinaryData untouched.
123- name : " Create returns AlreadyExists (label-filtered cache miss): patches metadata to restore labels" ,
124- resourceMetadata : testResourceMetadata ( commontest . TestExternalSecretsConfig ()),
125- preReq : func ( _ * Reconciler , cached * fakes. FakeCtrlClient , _ * fakes. FakeCtrlClient ) {
126- cached . ExistsCalls ( func ( _ context. Context , _ types. NamespacedName , _ client. Object ) ( bool , error ) {
127- return false , nil
128- })
129- cached . CreateCalls ( func ( _ context. Context , _ client. Object , _ ... client. CreateOption ) error {
130- return apierrors . NewAlreadyExists (schema. GroupResource { Resource : "configmaps" }, trustedCABundleConfigMapName )
131- })
132- cached . PatchCalls ( func ( _ context. Context , obj client. Object , patch client. Patch , _ ... client. PatchOption ) error {
133- cm , ok := obj .( * corev1. ConfigMap )
134- if ! ok {
135- t . Errorf ( "expected ConfigMap, got %T" , obj )
136- }
137- if cm . Labels [ "app" ] != "external-secrets" {
138- t . Errorf ( "expected app=external-secrets label in patch target, got %q" , cm . Labels [ "app" ])
139- }
140- if cm .Labels [trustedCABundleInjectLabel ] != "true" {
141- t . Errorf ( "expected inject label in patch target, got %q" , cm . Labels [ trustedCABundleInjectLabel ])
142- }
143- if patch . Type () != types . MergePatchType {
144- t . Errorf ( "expected MergePatch, got %s" , patch . Type ())
145- }
146- return nil
147- })
148- },
149- wantPatch : true ,
113+ wantPatch : true ,
114+ },
115+ {
116+ // Regression test for: labels updating with app: external-secrets of cm
117+ // external-secrets-trusted-ca-bundle will block the reconcile in the http_proxy env.
118+ //
119+ // When the managed label (app=external-secrets) is removed from the ConfigMap,
120+ // the object falls out of the label-filtered cache. The cached Exists() returns
121+ // false, Create() fails with AlreadyExists, and the controller must patch only
122+ // the metadata (labels/annotations), leaving CNO-managed Data/BinaryData untouched.
123+ name : "Create returns AlreadyExists (label-filtered cache miss): patches metadata to restore labels" ,
124+ resourceMetadata : testResourceMetadata ( commontest . TestExternalSecretsConfig ()),
125+ preReq : func ( _ * Reconciler , cached * fakes. FakeCtrlClient , _ * fakes. FakeCtrlClient ) {
126+ cached . ExistsCalls ( func ( _ context. Context , _ types. NamespacedName , _ client. Object ) ( bool , error ) {
127+ return false , nil
128+ } )
129+ cached . CreateCalls ( func ( _ context. Context , _ client. Object , _ ... client. CreateOption ) error {
130+ return apierrors . NewAlreadyExists (schema. GroupResource { Resource : "configmaps" }, trustedCABundleConfigMapName )
131+ } )
132+ cached . PatchCalls ( func ( _ context. Context , obj client. Object , patch client. Patch , _ ... client. PatchOption ) error {
133+ cm , ok := obj .( * corev1. ConfigMap )
134+ if ! ok {
135+ t . Errorf ( "expected ConfigMap, got %T" , obj )
136+ }
137+ if cm . Labels [ "app" ] != "external-secrets" {
138+ t . Errorf ( "expected app=external-secrets label in patch target, got %q" , cm .Labels ["app" ])
139+ }
140+ if cm . Labels [ trustedCABundleInjectLabel ] != "true" {
141+ t . Errorf ( "expected inject label in patch target, got %q" , cm . Labels [ trustedCABundleInjectLabel ])
142+ }
143+ if patch . Type () != types . JSONPatchType {
144+ t . Errorf ( "expected JSONPatch, got %s" , patch . Type ())
145+ }
146+ return nil
147+ })
150148 },
149+ wantPatch : true ,
150+ },
151151 {
152152 name : "proxy not configured: ConfigMap reconcile skipped" ,
153153 resourceMetadata : testResourceMetadata (commontest .TestExternalSecretsConfig ()),
0 commit comments