@@ -35,7 +35,9 @@ func NewDefaultSatResolver(rcp cache.SourceProvider, catsrcLister v1alpha1lister
35
35
return & SatResolver {
36
36
cache : cache .New (rcp , cache .WithLogger (logger ), cache .WithCatalogSourceLister (catsrcLister )),
37
37
log : logger ,
38
- pc : & predicateConverter {},
38
+ pc : & predicateConverter {
39
+ celEnv : constraints .NewCelEnvironment (),
40
+ },
39
41
}
40
42
}
41
43
@@ -346,26 +348,6 @@ func (r *SatResolver) getBundleInstallables(preferredNamespace string, bundleSta
346
348
continue
347
349
}
348
350
349
- for _ , prop := range bundle .Properties {
350
- if prop .Type != "olm.constraint" {
351
- continue
352
- }
353
-
354
- var val constraints.Constraint
355
- if err := json .Unmarshal ([]byte (prop .Value ), & val ); err != nil {
356
- errs = append (errs , err )
357
- continue
358
- }
359
-
360
- pred , err := cache .CreateCelPredicate (r .celEnv , val .Cel .Rule , val .Message )
361
- if err != nil {
362
- errs = append (errs , err )
363
- continue
364
- }
365
-
366
- dependencyPredicates = append (dependencyPredicates , pred )
367
- }
368
-
369
351
for _ , d := range dependencyPredicates {
370
352
sourcePredicate := cache .False ()
371
353
// Build a filter matching all (catalog,
@@ -757,7 +739,9 @@ func sortChannel(bundles []*cache.Entry) ([]*cache.Entry, error) {
757
739
}
758
740
759
741
// predicateConverter configures olm.constraint value -> predicate conversion for the resolver.
760
- type predicateConverter struct {}
742
+ type predicateConverter struct {
743
+ celEnv * constraints.CelEnvironment
744
+ }
761
745
762
746
// convertDependencyProperties converts all known constraint properties to predicates.
763
747
func (pc * predicateConverter ) convertDependencyProperties (properties []* api.Property ) ([]cache.Predicate , error ) {
@@ -834,6 +818,8 @@ func (pc *predicateConverter) convertConstraints(constraints ...constraints.Cons
834
818
case constraint .None != nil :
835
819
subs , perr := pc .convertConstraints (constraint .None .Constraints ... )
836
820
preds [i ], err = cache .Not (subs ... ), perr
821
+ case constraint .Cel != nil :
822
+ preds [i ], err = cache .CreateCelPredicate (pc .celEnv , constraint .Cel .Rule , constraint .Message )
837
823
default :
838
824
// Unknown constraint types are handled by constraints.Parse(),
839
825
// but parsed constraints may be empty.
0 commit comments