@@ -19,6 +19,7 @@ package declarative
19
19
import (
20
20
"context"
21
21
"fmt"
22
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
22
23
"path/filepath"
23
24
"strings"
24
25
@@ -130,6 +131,13 @@ func (r *Reconciler) reconcileExists(ctx context.Context, name types.NamespacedN
130
131
}
131
132
}()
132
133
134
+ err = parseListKind (objects )
135
+
136
+ if err != nil {
137
+ log .Error (err , "Parsing list kind" )
138
+ return reconcile.Result {}, fmt .Errorf ("error parsing list kind: %v" , err )
139
+ }
140
+
133
141
err = r .injectOwnerRef (ctx , instance , objects )
134
142
if err != nil {
135
143
return reconcile.Result {}, err
@@ -403,3 +411,30 @@ func (r *Reconciler) IsKustomizeOptionUsed() bool {
403
411
func (r * Reconciler ) SetSink (sink Sink ) {
404
412
r .options .sink = sink
405
413
}
414
+
415
+ func parseListKind (infos * manifest.Objects ) error {
416
+ for i , item := range infos .Items {
417
+ if item .Kind == "List" {
418
+ fmt .Println ("haaa!" )
419
+ obj := item .UnstructuredObject ()
420
+
421
+ err := obj .EachListItem (func (obj runtime.Object ) error {
422
+ castItem := obj .(* unstructured.Unstructured )
423
+ newObj , err := manifest .NewObject (castItem )
424
+ if err != nil {
425
+ return err
426
+ }
427
+ infos .Items = append (infos .Items , newObj )
428
+ return nil
429
+ })
430
+
431
+ if err != nil {
432
+ return err
433
+ }
434
+
435
+ infos .Items = append (infos .Items [:i ], infos .Items [i + 1 :]... )
436
+ }
437
+ }
438
+
439
+ return nil
440
+ }
0 commit comments