MCPcopy Create free account
hub / github.com/cel-expr/cel-go / applyQualifiers

Function applyQualifiers

interpreter/attributes.go:1302–1336  ·  view source on GitHub ↗
(vars Activation, obj any, qualifiers []Qualifier)

Source from the content-addressed store, hash-verified

1300}
1301
1302func applyQualifiers(vars Activation, obj any, qualifiers []Qualifier) (any, bool, error) {
1303 optObj, isOpt := obj.(*types.Optional)
1304 if isOpt {
1305 if !optObj.HasValue() {
1306 return optObj, false, nil
1307 }
1308 obj = optObj.GetValue()
1309 }
1310
1311 var err error
1312 for _, qual := range qualifiers {
1313 var qualObj any
1314 isOpt = isOpt || qual.IsOptional()
1315 if isOpt {
1316 var present bool
1317 qualObj, present, err = qual.QualifyIfPresent(vars, obj, false)
1318 if err != nil {
1319 return nil, false, err
1320 }
1321 if !present {
1322 // We return optional none here with a presence of 'false' as the layers
1323 // above will attempt to call types.OptionalOf() on a present value if any
1324 // of the qualifiers is optional.
1325 return types.OptionalNone, false, nil
1326 }
1327 } else {
1328 qualObj, err = qual.Qualify(vars, obj)
1329 if err != nil {
1330 return nil, false, err
1331 }
1332 }
1333 obj = qualObj
1334 }
1335 return obj, isOpt, nil
1336}
1337
1338// attrQualify performs a qualification using the result of an attribute evaluation.
1339func attrQualify(fac AttributeFactory, vars Activation, obj any, qualAttr Attribute) (any, error) {

Callers 2

ResolveMethod · 0.85
ResolveMethod · 0.85

Calls 5

HasValueMethod · 0.80
GetValueMethod · 0.80
IsOptionalMethod · 0.65
QualifyIfPresentMethod · 0.65
QualifyMethod · 0.65

Tested by

no test coverage detected