@@ -20,6 +20,8 @@ import (
20
20
"context"
21
21
"errors"
22
22
"fmt"
23
+ "k8s.io/apimachinery/pkg/api/meta"
24
+ "k8s.io/client-go/dynamic"
23
25
"path/filepath"
24
26
"strings"
25
27
@@ -184,6 +186,40 @@ func (r *Reconciler) reconcileExists(ctx context.Context, name types.NamespacedN
184
186
if err != nil {
185
187
return reconcile.Result {}, err
186
188
}
189
+
190
+ // dynamic config
191
+ dynamicClientset , err := dynamic .NewForConfig (r .config )
192
+ if err != nil {
193
+ log .Error (err ,"Unable to create dynamic client" )
194
+ return reconcile.Result {}, err
195
+ }
196
+
197
+ newItems := []* manifest.Object {}
198
+ for _ , obj := range objects .Items {
199
+
200
+ // Uses unsafe method?? Is it safe?
201
+ getOptions := metav1.GetOptions {}
202
+ gvk , _ := meta .UnsafeGuessKindToResource (obj .GroupVersionKind ())
203
+ ns := obj .UnstructuredObject ().GetNamespace ()
204
+ unstruct , err := dynamicClientset .Resource (gvk ).Namespace (ns ).Get (context .Background (),
205
+ obj .Name , getOptions )
206
+ if err != nil {
207
+ log .WithValues ("name" , obj .Name ).Error (err , "Unable to get resource" )
208
+ }
209
+ if unstruct != nil {
210
+ annotations := unstruct .GetAnnotations ()
211
+ if ignoreAnnotation , ok := annotations ["addons.operators.ignore" ]; ok {
212
+ if ignoreAnnotation == "true" {
213
+ log .WithValues ("kind" , obj .Kind ).WithValues ("name" , obj .Name ).Info ("Found ignore annotation on object, " +
214
+ "skipping object" )
215
+ continue
216
+ }
217
+ }
218
+ }
219
+ newItems = append (newItems , obj )
220
+ }
221
+ objects .Items = newItems
222
+
187
223
var manifestStr string
188
224
189
225
m , err := objects .JSONManifest ()
0 commit comments