resolver

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstraintSolver

type ConstraintSolver struct {
	// contains filtered or unexported fields
}

ConstraintSolver implements a more sophisticated dependency resolution algorithm that can handle conflicting constraints and backtracking

func NewConstraintSolver

func NewConstraintSolver(sources []source.CookbookSource) *ConstraintSolver

NewConstraintSolver creates a new constraint solver

func (*ConstraintSolver) Solve

func (cs *ConstraintSolver) Solve(ctx context.Context, requirements []*Requirement) (*Resolution, error)

Solve attempts to find a solution that satisfies all constraints

type CookbookNode

type CookbookNode struct {
	Name     string
	Version  *berkshelf.Version
	Cookbook *berkshelf.Cookbook
	Resolved bool
	// contains filtered or unexported fields
}

CookbookNode represents a cookbook in the dependency graph

func (*CookbookNode) ID

func (n *CookbookNode) ID() int64

ID implements graph.Node interface

func (*CookbookNode) String

func (n *CookbookNode) String() string

String returns a string representation of the cookbook node

type DefaultResolver

type DefaultResolver struct {
	// contains filtered or unexported fields
}

DefaultResolver implements the Resolver interface

func NewResolver

func NewResolver(sources []source.CookbookSource) *DefaultResolver

NewResolver creates a new resolver with the given sources

func (*DefaultResolver) Resolve

func (r *DefaultResolver) Resolve(ctx context.Context, requirements []*Requirement) (*Resolution, error)

Resolve implements concurrent I/O operations for dependency resolution

func (*DefaultResolver) SetMaxWorkers

func (r *DefaultResolver) SetMaxWorkers(workers int)

SetMaxWorkers configures the number of concurrent workers for I/O operations

type DependencyGraph

type DependencyGraph struct {
	// contains filtered or unexported fields
}

DependencyGraph represents cookbook dependencies using gonum's graph

func NewDependencyGraph

func NewDependencyGraph() *DependencyGraph

NewDependencyGraph creates a new dependency graph

func (*DependencyGraph) AddCookbook

func (g *DependencyGraph) AddCookbook(cookbook *berkshelf.Cookbook) *CookbookNode

AddCookbook adds a cookbook to the graph

func (*DependencyGraph) AddDependency

func (g *DependencyGraph) AddDependency(from, to *CookbookNode, constraint *berkshelf.Constraint)

AddDependency adds a dependency edge between cookbooks

func (*DependencyGraph) AllCookbooks

func (g *DependencyGraph) AllCookbooks() []*CookbookNode

AllCookbooks returns all cookbook nodes in the graph

func (*DependencyGraph) Clone

func (g *DependencyGraph) Clone() *DependencyGraph

Clone creates a deep copy of the dependency graph

func (*DependencyGraph) EdgeCount

func (g *DependencyGraph) EdgeCount() int

EdgeCount returns the number of dependency relationships in the graph

func (*DependencyGraph) GetCookbook

func (g *DependencyGraph) GetCookbook(name string) (*CookbookNode, bool)

GetCookbook retrieves a cookbook node by name

func (*DependencyGraph) GetCycles

func (g *DependencyGraph) GetCycles() [][]string

GetCycles returns any circular dependencies found in the graph

func (*DependencyGraph) GetDependencies

func (g *DependencyGraph) GetDependencies(node *CookbookNode) []*CookbookNode

GetDependencies returns all direct dependencies of a cookbook

func (*DependencyGraph) GetDependents

func (g *DependencyGraph) GetDependents(node *CookbookNode) []*CookbookNode

GetDependents returns all cookbooks that depend on the given cookbook

func (*DependencyGraph) HasCycles

func (g *DependencyGraph) HasCycles() bool

HasCycles checks if the dependency graph has circular dependencies

func (*DependencyGraph) HasDependency

func (g *DependencyGraph) HasDependency(from, to *CookbookNode) bool

HasDependency checks if a dependency exists between two cookbooks

func (*DependencyGraph) NodeCount

func (g *DependencyGraph) NodeCount() int

NodeCount returns the number of cookbooks in the graph

func (*DependencyGraph) TopologicalSort

func (g *DependencyGraph) TopologicalSort() ([]*CookbookNode, error)

TopologicalSort returns cookbooks in dependency order

type Requirement

type Requirement struct {
	Name       string
	Constraint *berkshelf.Constraint
	Source     *berkshelf.SourceLocation
}

Requirement represents a cookbook requirement to be resolved

func NewRequirement

func NewRequirement(name string, constraint *berkshelf.Constraint) *Requirement

NewRequirement creates a new requirement

func NewRequirementWithSource

func NewRequirementWithSource(name string, constraint *berkshelf.Constraint, source *berkshelf.SourceLocation) *Requirement

NewRequirementWithSource creates a new requirement with a specific source

func (*Requirement) String

func (r *Requirement) String() string

String returns a string representation of the requirement

type Resolution

type Resolution struct {
	Graph     *DependencyGraph
	Cookbooks map[string]*ResolvedCookbook
	Errors    []error
}

Resolution represents a resolved dependency graph

func NewResolution

func NewResolution() *Resolution

NewResolution creates a new resolution

func (*Resolution) AddCookbook

func (r *Resolution) AddCookbook(cookbook *ResolvedCookbook)

AddCookbook adds a resolved cookbook to the resolution

func (*Resolution) AddError

func (r *Resolution) AddError(err error)

AddError adds an error to the resolution

func (*Resolution) AllCookbooks

func (r *Resolution) AllCookbooks() []*ResolvedCookbook

AllCookbooks returns all resolved cookbooks

func (*Resolution) CookbookCount

func (r *Resolution) CookbookCount() int

CookbookCount returns the number of resolved cookbooks

func (*Resolution) GetCookbook

func (r *Resolution) GetCookbook(name string) (*ResolvedCookbook, bool)

GetCookbook retrieves a resolved cookbook by name

func (*Resolution) HasCookbook

func (r *Resolution) HasCookbook(name string) bool

HasCookbook checks if a cookbook is in the resolution

func (*Resolution) HasErrors

func (r *Resolution) HasErrors() bool

HasErrors returns true if the resolution has any errors

type ResolutionCache

type ResolutionCache struct {
	// contains filtered or unexported fields
}

ResolutionCache caches cookbook metadata and available versions

func NewResolutionCache

func NewResolutionCache() *ResolutionCache

NewResolutionCache creates a new resolution cache

func (*ResolutionCache) Clear

func (c *ResolutionCache) Clear()

Clear clears the cache

func (*ResolutionCache) GetMetadata

func (c *ResolutionCache) GetMetadata(key string) *berkshelf.Cookbook

GetMetadata retrieves cookbook metadata from cache

func (*ResolutionCache) GetVersions

func (c *ResolutionCache) GetVersions(key string) []*berkshelf.Version

GetVersions retrieves versions from cache

func (*ResolutionCache) SetMetadata

func (c *ResolutionCache) SetMetadata(key string, cookbook *berkshelf.Cookbook)

SetMetadata stores cookbook metadata in cache

func (*ResolutionCache) SetVersions

func (c *ResolutionCache) SetVersions(key string, versions []*berkshelf.Version)

SetVersions stores versions in cache

type ResolvedCookbook

type ResolvedCookbook struct {
	Name         string
	Version      *berkshelf.Version
	Source       *berkshelf.SourceLocation
	SourceRef    source.CookbookSource // Reference to the actual source object
	Dependencies map[string]*berkshelf.Version
	Cookbook     *berkshelf.Cookbook
}

ResolvedCookbook represents a cookbook that has been resolved

type Resolver

type Resolver interface {
	Resolve(ctx context.Context, requirements []*Requirement) (*Resolution, error)
}

Resolver defines the interface for dependency resolution

type SolverState

type SolverState struct {
	// contains filtered or unexported fields
}

SolverState represents the current state of the resolution process

Jump to

Keyboard shortcuts

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