@@ -2281,84 +2281,6 @@ func BenchmarkSync(b *testing.B) {
22812281 }
22822282}
22832283
2284- func TestNeedsClientSideApplyMigration (t * testing.T ) {
2285- syncCtx := newTestSyncCtx (nil )
2286-
2287- tests := []struct {
2288- name string
2289- liveObj * unstructured.Unstructured
2290- expected bool
2291- }{
2292- {
2293- name : "nil object" ,
2294- liveObj : nil ,
2295- expected : false ,
2296- },
2297- {
2298- name : "object with no managed fields" ,
2299- liveObj : testingutils .NewPod (),
2300- expected : false ,
2301- },
2302- {
2303- name : "object with kubectl-client-side-apply fields" ,
2304- liveObj : func () * unstructured.Unstructured {
2305- obj := testingutils .NewPod ()
2306- obj .SetManagedFields ([]metav1.ManagedFieldsEntry {
2307- {
2308- Manager : "kubectl-client-side-apply" ,
2309- Operation : metav1 .ManagedFieldsOperationUpdate ,
2310- FieldsV1 : & metav1.FieldsV1 {Raw : []byte (`{"f:metadata":{"f:annotations":{}}}` )},
2311- },
2312- })
2313- return obj
2314- }(),
2315- expected : true ,
2316- },
2317- {
2318- name : "object with only argocd-controller fields" ,
2319- liveObj : func () * unstructured.Unstructured {
2320- obj := testingutils .NewPod ()
2321- obj .SetManagedFields ([]metav1.ManagedFieldsEntry {
2322- {
2323- Manager : "argocd-controller" ,
2324- Operation : metav1 .ManagedFieldsOperationApply ,
2325- FieldsV1 : & metav1.FieldsV1 {Raw : []byte (`{"f:spec":{"f:replicas":{}}}` )},
2326- },
2327- })
2328- return obj
2329- }(),
2330- expected : false ,
2331- },
2332- {
2333- name : "object with mixed field managers" ,
2334- liveObj : func () * unstructured.Unstructured {
2335- obj := testingutils .NewPod ()
2336- obj .SetManagedFields ([]metav1.ManagedFieldsEntry {
2337- {
2338- Manager : "kubectl-client-side-apply" ,
2339- Operation : metav1 .ManagedFieldsOperationUpdate ,
2340- FieldsV1 : & metav1.FieldsV1 {Raw : []byte (`{"f:metadata":{"f:annotations":{}}}` )},
2341- },
2342- {
2343- Manager : "argocd-controller" ,
2344- Operation : metav1 .ManagedFieldsOperationApply ,
2345- FieldsV1 : & metav1.FieldsV1 {Raw : []byte (`{"f:spec":{"f:replicas":{}}}` )},
2346- },
2347- })
2348- return obj
2349- }(),
2350- expected : true ,
2351- },
2352- }
2353-
2354- for _ , tt := range tests {
2355- t .Run (tt .name , func (t * testing.T ) {
2356- result := syncCtx .needsClientSideApplyMigration (tt .liveObj , "kubectl-client-side-apply" )
2357- assert .Equal (t , tt .expected , result )
2358- })
2359- }
2360- }
2361-
23622284func diffResultListClusterResource () * diff.DiffResultList {
23632285 ns1 := testingutils .NewNamespace ()
23642286 ns1 .SetName ("ns-1" )
@@ -2383,4 +2305,3 @@ func diffResultListClusterResource() *diff.DiffResultList {
23832305
23842306 return & diffResultList
23852307}
2386- >> >> >> > b3a2ec1 (fix (sync ): ApplyOutOfSyncOnly = true sync option is not honoured for cluster scoped resources (#765 ))
0 commit comments