solver

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAnnotation = errors.New("required annotation missing")

	ErrResourceDependency = errors.New("resource dependedncy error")

	ErrGraph = errors.New("graph error")

	ErrConstraint = errors.New("constraint error")
)

Functions

func SolveApplicationSet

func SolveApplicationSet(ctx context.Context, applications ApplicationIndex, applicationset *unikornv1.ApplicationSet) (sat.Set[AppVersion], error)

SolveApplicationSet walks the graph Dykstra style loading in referenced dependencies. Where things get interesting is if a dependency is pulled in multiple times but the originally selected version conflicts with other dependency constraints then we have a conflict, and have to backtrack and try again with another version. Unlike typical SAT solver problems, choosing a different version can have the fun effect of changing its dependencies!

Types

type AppVersion

type AppVersion struct {
	Name    string
	Version unikornv1core.SemanticVersion
}

AppVersion wraps up applicationID and version tuples in a comparable and easy to use form when interacting with the SAT solver.

func NewAppVersion

func NewAppVersion(name string, version unikornv1core.SemanticVersion) AppVersion

type ApplicationIndex

type ApplicationIndex map[string]*unikornv1core.HelmApplication

func NewApplicationIndex

func NewApplicationIndex(applications ...*unikornv1core.HelmApplication) (ApplicationIndex, error)

func (ApplicationIndex) Get

type GraphVisitor

type GraphVisitor[T comparable] interface {
	// Visit is called when a new node is encountered, it accepts
	// the node itself and an enqueue function.
	Visit(node T, enqueue func(T)) error
}

GraphVisitor is used to visit a node in the graph.

type GraphWalker

type GraphWalker[T comparable] struct {
	// contains filtered or unexported fields
}

func NewGraphWalker

func NewGraphWalker[T comparable]() *GraphWalker[T]

func (*GraphWalker[T]) Enqueue

func (g *GraphWalker[T]) Enqueue(t T)

func (*GraphWalker[T]) Walk

func (g *GraphWalker[T]) Walk(visitor GraphVisitor[T]) error

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

func (*Queue[T]) Empty

func (q *Queue[T]) Empty() bool

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() T

func (*Queue[T]) Push

func (q *Queue[T]) Push(value T)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL