@@ -814,6 +814,15 @@ func (m *ODLMOperator) processMapObject(ctx context.Context, key string, mapObj
814
814
if err != nil {
815
815
return err
816
816
}
817
+
818
+ if valueRef == "true" {
819
+ finalObject [key ] = true
820
+ continue
821
+ } else if valueRef == "false" {
822
+ finalObject [key ] = false
823
+ continue
824
+ }
825
+
817
826
if valueRef != "" {
818
827
// Check if the returned value is a JSON array string and the field should be an array
819
828
if strings .HasPrefix (valueRef , "[" ) && strings .HasSuffix (valueRef , "]" ) {
@@ -869,6 +878,15 @@ func (m *ODLMOperator) processTemplateValue(ctx context.Context, value interface
869
878
return valueRef , nil
870
879
}
871
880
881
+ if boolValue , hasBool := templateRef ["boolean" ]; hasBool {
882
+ if b , ok := boolValue .(bool ); ok {
883
+ if b {
884
+ return "true" , nil
885
+ }
886
+ return "false" , nil
887
+ }
888
+ }
889
+
872
890
templateRefObj , err := m .convertToTemplateValueRef (templateRef , instanceType , instanceName , instanceNs )
873
891
if err != nil {
874
892
return "" , err
@@ -929,7 +947,13 @@ func (m *ODLMOperator) GetValueFromBranch(ctx context.Context, branch *util.Valu
929
947
return "" , nil
930
948
}
931
949
932
- // Handle direct literal value first
950
+ if branch .Boolean != nil {
951
+ if * branch .Boolean {
952
+ return "true" , nil
953
+ }
954
+ return "false" , nil
955
+ }
956
+
933
957
if branch .Literal != "" {
934
958
return branch .Literal , nil
935
959
}
@@ -939,9 +963,14 @@ func (m *ODLMOperator) GetValueFromBranch(ctx context.Context, branch *util.Valu
939
963
// Create a slice to hold processed values
940
964
var processedValues []interface {}
941
965
942
- // Iterate over the array items
943
966
for _ , item := range branch .Array {
944
- if item .Literal != "" {
967
+ if item .Boolean != nil {
968
+ if * item .Boolean {
969
+ processedValues = append (processedValues , true )
970
+ } else {
971
+ processedValues = append (processedValues , false )
972
+ }
973
+ } else if item .Literal != "" {
945
974
// For literal values in array, add directly
946
975
processedValues = append (processedValues , item .Literal )
947
976
} else if len (item .Map ) > 0 {
@@ -1044,10 +1073,12 @@ func (m *ODLMOperator) EvaluateExpression(ctx context.Context, expr *util.Logica
1044
1073
// Helper function to get comparison values
1045
1074
getComparisonValues := func (left , right * util.ValueSource ) (string , string , error ) {
1046
1075
leftVal , err := m .GetValueFromSource (ctx , left , instanceType , instanceName , instanceNs )
1076
+
1047
1077
if err != nil {
1048
1078
return "" , "" , err
1049
1079
}
1050
1080
rightVal , err := m .GetValueFromSource (ctx , right , instanceType , instanceName , instanceNs )
1081
+
1051
1082
if err != nil {
1052
1083
return "" , "" , err
1053
1084
}
@@ -1178,6 +1209,13 @@ func (m *ODLMOperator) GetValueFromSource(ctx context.Context, source *util.Valu
1178
1209
return "" , nil
1179
1210
}
1180
1211
1212
+ if source .Boolean != nil {
1213
+ if * source .Boolean {
1214
+ return "true" , nil
1215
+ }
1216
+ return "false" , nil
1217
+ }
1218
+
1181
1219
if source .Literal != "" {
1182
1220
return source .Literal , nil
1183
1221
}
@@ -1375,26 +1413,33 @@ func (m *ODLMOperator) GetValueRefFromObject(ctx context.Context, instanceType,
1375
1413
return "" , errors .Wrapf (err , "failed to get %s %s/%s" , objKind , objNs , objName )
1376
1414
}
1377
1415
1378
- // Set the Value Reference label for the object
1379
- m .EnsureLabel (obj , map [string ]string {
1380
- constant .ODLMWatchedLabel : "true" ,
1381
- })
1382
- // Set the Value Reference Annotation for the Secret
1383
- m .EnsureAnnotation (obj , map [string ]string {
1384
- constant .ODLMReferenceAnnotation : instanceType + "." + instanceNs + "." + instanceName ,
1385
- })
1386
- // Update the object with the Value Reference label
1387
- if err := m .Update (ctx , & obj ); err != nil {
1388
- return "" , errors .Wrapf (err , "failed to update %s %s/%s" , objKind , obj .GetNamespace (), obj .GetName ())
1389
- }
1390
- klog .V (2 ).Infof ("Set the Value Reference label for %s %s/%s" , objKind , obj .GetNamespace (), obj .GetName ())
1416
+ // Comment out the following lines as we do not need to set labels and annotations for the CRD
1417
+
1418
+ // // Set the Value Reference label for the object
1419
+ // m.EnsureLabel(obj, map[string]string{
1420
+ // constant.ODLMWatchedLabel: "true",
1421
+ // })
1422
+ // // Set the Value Reference Annotation for the Secret
1423
+ // m.EnsureAnnotation(obj, map[string]string{
1424
+ // constant.ODLMReferenceAnnotation: instanceType + "." + instanceNs + "." + instanceName,
1425
+ // })
1426
+ // // Update the object with the Value Reference label
1427
+ // if err := m.Update(ctx, &obj); err != nil {
1428
+ // return "", errors.Wrapf(err, "failed to update %s %s/%s", objKind, obj.GetNamespace(), obj.GetName())
1429
+ // }
1430
+ // klog.V(2).Infof("Set the Value Reference label for %s %s/%s", objKind, obj.GetNamespace(), obj.GetName())
1391
1431
1392
1432
if path == "" {
1393
1433
return "" , nil
1394
1434
}
1395
1435
1396
1436
sanitizedString , err := util .SanitizeObjectString (path , obj .Object )
1397
1437
if err != nil {
1438
+ // Instead of returning an error for a missing path, log it as a warning and return empty string
1439
+ if strings .Contains (err .Error (), "not found" ) {
1440
+ klog .Warningf ("Path %v from %s %s/%s was not found: %v" , path , objKind , objNs , objName , err )
1441
+ return "" , nil
1442
+ }
1398
1443
return "" , errors .Wrapf (err , "failed to parse path %v from %s %s/%s" , path , obj .GetKind (), obj .GetNamespace (), obj .GetName ())
1399
1444
}
1400
1445
0 commit comments