operator-framework / deppy

Deppy: The dependency resolver for Kubernetes
Apache License 2.0
15 stars 21 forks source link

Add Entity universe #37

Closed perdasilva closed 1 year ago

perdasilva commented 1 year ago

The entity universe represents the complete set of entities over which deppy will operate. The entity universe surfaces methods for searching and sorting entities. The entity universe gives constraint factories the access to the entities in a queryable form, for instance:

func packageDependency(subject solver.Identifier, packageName string, versionRange string) []solver.Constraint {
  ids := entityUniverse.Search(universe.And(withPackageName(packageName), withinVersion(versionRange))).Sort(byChannelAndVersion).CollectIds()
  return []solver.Constraint{solver.Dependency(subject, ids...)}
}

where withPackageName, withinVersion, byChannelAndVersion are Predicate and SortFunction implementations

perdasilva commented 1 year ago

/hold until entity PR gets merged

perdasilva commented 1 year ago

/hold cancel

timflannagan commented 1 year ago

Could we add an example in the PR description of how we'd expect this library to consumed during any constraint building operations if you had already have something in mind?