@@ -722,6 +722,15 @@ func (m *ODLMOperator) processMapObject(ctx context.Context, key string, mapObj
722
722
if err != nil {
723
723
return err
724
724
}
725
+
726
+ if valueRef == "true" {
727
+ finalObject [key ] = true
728
+ continue
729
+ } else if valueRef == "false" {
730
+ finalObject [key ] = false
731
+ continue
732
+ }
733
+
725
734
if valueRef != "" {
726
735
// Check if the returned value is a JSON array string and the field should be an array
727
736
if strings .HasPrefix (valueRef , "[" ) && strings .HasSuffix (valueRef , "]" ) {
@@ -777,6 +786,15 @@ func (m *ODLMOperator) processTemplateValue(ctx context.Context, value interface
777
786
return valueRef , nil
778
787
}
779
788
789
+ if boolValue , hasBool := templateRef ["boolean" ]; hasBool {
790
+ if b , ok := boolValue .(bool ); ok {
791
+ if b {
792
+ return "true" , nil
793
+ }
794
+ return "false" , nil
795
+ }
796
+ }
797
+
780
798
templateRefObj , err := m .convertToTemplateValueRef (templateRef , instanceType , instanceName , instanceNs )
781
799
if err != nil {
782
800
return "" , err
@@ -837,7 +855,13 @@ func (m *ODLMOperator) GetValueFromBranch(ctx context.Context, branch *util.Valu
837
855
return "" , nil
838
856
}
839
857
840
- // Handle direct literal value first
858
+ if branch .Boolean != nil {
859
+ if * branch .Boolean {
860
+ return "true" , nil
861
+ }
862
+ return "false" , nil
863
+ }
864
+
841
865
if branch .Literal != "" {
842
866
return branch .Literal , nil
843
867
}
@@ -847,9 +871,14 @@ func (m *ODLMOperator) GetValueFromBranch(ctx context.Context, branch *util.Valu
847
871
// Create a slice to hold processed values
848
872
var processedValues []interface {}
849
873
850
- // Iterate over the array items
851
874
for _ , item := range branch .Array {
852
- if item .Literal != "" {
875
+ if item .Boolean != nil {
876
+ if * item .Boolean {
877
+ processedValues = append (processedValues , true )
878
+ } else {
879
+ processedValues = append (processedValues , false )
880
+ }
881
+ } else if item .Literal != "" {
853
882
// For literal values in array, add directly
854
883
processedValues = append (processedValues , item .Literal )
855
884
} else if len (item .Map ) > 0 {
@@ -952,10 +981,12 @@ func (m *ODLMOperator) EvaluateExpression(ctx context.Context, expr *util.Logica
952
981
// Helper function to get comparison values
953
982
getComparisonValues := func (left , right * util.ValueSource ) (string , string , error ) {
954
983
leftVal , err := m .GetValueFromSource (ctx , left , instanceType , instanceName , instanceNs )
984
+
955
985
if err != nil {
956
986
return "" , "" , err
957
987
}
958
988
rightVal , err := m .GetValueFromSource (ctx , right , instanceType , instanceName , instanceNs )
989
+
959
990
if err != nil {
960
991
return "" , "" , err
961
992
}
@@ -1086,6 +1117,13 @@ func (m *ODLMOperator) GetValueFromSource(ctx context.Context, source *util.Valu
1086
1117
return "" , nil
1087
1118
}
1088
1119
1120
+ if source .Boolean != nil {
1121
+ if * source .Boolean {
1122
+ return "true" , nil
1123
+ }
1124
+ return "false" , nil
1125
+ }
1126
+
1089
1127
if source .Literal != "" {
1090
1128
return source .Literal , nil
1091
1129
}
@@ -1283,26 +1321,33 @@ func (m *ODLMOperator) GetValueRefFromObject(ctx context.Context, instanceType,
1283
1321
return "" , errors .Wrapf (err , "failed to get %s %s/%s" , objKind , objNs , objName )
1284
1322
}
1285
1323
1286
- // Set the Value Reference label for the object
1287
- m .EnsureLabel (obj , map [string ]string {
1288
- constant .ODLMWatchedLabel : "true" ,
1289
- })
1290
- // Set the Value Reference Annotation for the Secret
1291
- m .EnsureAnnotation (obj , map [string ]string {
1292
- constant .ODLMReferenceAnnotation : instanceType + "." + instanceNs + "." + instanceName ,
1293
- })
1294
- // Update the object with the Value Reference label
1295
- if err := m .Update (ctx , & obj ); err != nil {
1296
- return "" , errors .Wrapf (err , "failed to update %s %s/%s" , objKind , obj .GetNamespace (), obj .GetName ())
1297
- }
1298
- klog .V (2 ).Infof ("Set the Value Reference label for %s %s/%s" , objKind , obj .GetNamespace (), obj .GetName ())
1324
+ // Comment out the following lines as we do not need to set labels and annotations for the CRD
1325
+
1326
+ // // Set the Value Reference label for the object
1327
+ // m.EnsureLabel(obj, map[string]string{
1328
+ // constant.ODLMWatchedLabel: "true",
1329
+ // })
1330
+ // // Set the Value Reference Annotation for the Secret
1331
+ // m.EnsureAnnotation(obj, map[string]string{
1332
+ // constant.ODLMReferenceAnnotation: instanceType + "." + instanceNs + "." + instanceName,
1333
+ // })
1334
+ // // Update the object with the Value Reference label
1335
+ // if err := m.Update(ctx, &obj); err != nil {
1336
+ // return "", errors.Wrapf(err, "failed to update %s %s/%s", objKind, obj.GetNamespace(), obj.GetName())
1337
+ // }
1338
+ // klog.V(2).Infof("Set the Value Reference label for %s %s/%s", objKind, obj.GetNamespace(), obj.GetName())
1299
1339
1300
1340
if path == "" {
1301
1341
return "" , nil
1302
1342
}
1303
1343
1304
1344
sanitizedString , err := util .SanitizeObjectString (path , obj .Object )
1305
1345
if err != nil {
1346
+ // Instead of returning an error for a missing path, log it as a warning and return empty string
1347
+ if strings .Contains (err .Error (), "not found" ) {
1348
+ klog .Warningf ("Path %v from %s %s/%s was not found: %v" , path , objKind , objNs , objName , err )
1349
+ return "" , nil
1350
+ }
1306
1351
return "" , errors .Wrapf (err , "failed to parse path %v from %s %s/%s" , path , obj .GetKind (), obj .GetNamespace (), obj .GetName ())
1307
1352
}
1308
1353
0 commit comments