resolver

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ProductNameAnnotation defines the product name a chart is reponsible for.
	ProductNameAnnotation = fmt.Sprintf("%s/product-name", constants.RepoURI)

	// DependsOnAnnotation defines the list of Helm chart names a chart requires
	// to be installed before it can be installed.
	DependsOnAnnotation = fmt.Sprintf("%s/depends-on", constants.RepoURI)

	// UseProductNamespaceAnnotation defines the Helm chart should use the same
	// namespace than the referred product name.
	UseProductNamespaceAnnotation = fmt.Sprintf(
		"%s/use-product-namespace",
		constants.RepoURI,
	)
)
View Source
var (
	// ErrInvalidCollection the collection is invalid.
	ErrInvalidCollection error = errors.New("invalid collection")
	// ErrDependencyNotFound the dependency is not found in the collection.
	ErrDependencyNotFound error = errors.New("dependency not found")
)
View Source
var ErrCircularDependency = fmt.Errorf("circular dependency detected")

ErrCircularDependency reports a circular dependency.

View Source
var ErrMissingDependency = fmt.Errorf("unmet dependency detected")

ErrMissingDependency reports an unmet dependency.

Functions

This section is empty.

Types

type Collection

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

Collection represents a collection of dependencies the Resolver can utilize. The collection is concise, all dependencies and product names must be unique.

func NewCollection

func NewCollection(charts []chart.Chart) (*Collection, error)

NewCollection creates a new Collection from the given charts. It returns an error if there are duplicate charts and product names.

func (*Collection) Get

func (c *Collection) Get(name string) (*Dependency, error)

Get returns the dependency with the given name.

func (*Collection) GetProductDependency

func (c *Collection) GetProductDependency(product string) (*Dependency, error)

GetProductDependency returns the dependency associated with the informed product. Returns error when no dependency is found.

func (*Collection) Walk

func (c *Collection) Walk(fn CollectionWalkFn) error

Walk iterates over all dependencies in the collection and calls the provided function for each entry.

type CollectionWalkFn

type CollectionWalkFn func(string, Dependency) error

CollectionWalkFn is a function that is called for each dependency in the collection, the dependency name and instance are passed to it.

type Dependencies

type Dependencies []Dependency

Dependencies represents a slice of Dependency instances.

type Dependency

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

Dependency represent a installer Dependency, which consists of a Helm chart instance, namespace and metadata. The relevant Helm chart metadata is read by helper methods.

func NewDependency

func NewDependency(hc *chart.Chart) *Dependency

NewDependency creates a new Dependency for the Helm chart and initially using empty target namespace.

func NewDependencyWithNamespace

func NewDependencyWithNamespace(hc *chart.Chart, ns string) *Dependency

NewDependencyWithNamespace creates a new Dependency for the Helm chart and sets the target namespace.

func (*Dependency) Chart

func (d *Dependency) Chart() *chart.Chart

Chart exposes the Helm chart instance.

func (*Dependency) DependsOn

func (d *Dependency) DependsOn() []string

DependsOn returns a slice of dependencies names from the chart's annotation.

func (*Dependency) LoggerWith

func (d *Dependency) LoggerWith(logger *slog.Logger) *slog.Logger

LoggerWith decorates the logger with dependency information.

func (*Dependency) Name

func (d *Dependency) Name() string

Name returns the name of the Helm chart.

func (*Dependency) Namespace

func (d *Dependency) Namespace() string

Namespace returns the namespace.

func (*Dependency) ProductName

func (d *Dependency) ProductName() string

ProductName returns the product name from the chart annotations.

func (*Dependency) SetNamespace

func (d *Dependency) SetNamespace(namespace string)

SetNamespace sets the namespace for this dependency.

func (*Dependency) UseProductNamespace

func (d *Dependency) UseProductNamespace() string

UseProductNamespace returns the product namespace from the chart annotations.

type Resolver

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

Resolver represents the actor that resolves dependencies between charts.

func NewResolver

func NewResolver(cfg *config.Config, c *Collection, t *Topology) *Resolver

NewResolver instantiates a new Resolver. It takes the configuration, collection and topology as parameters.

func (*Resolver) Print

func (r *Resolver) Print(w io.Writer)

Print prints the resolved topology to the writer formatted as a table.

func (*Resolver) Resolve

func (r *Resolver) Resolve() error

Resolve resolves the all dependencies in the collection to create the topology.

type Topology

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

Topology represents the dependency topology, determines the order in which charts (dependencies) will be installed.

func NewTopology

func NewTopology() *Topology

NewTopology creates a new topology instance.

func (*Topology) Append

func (t *Topology) Append(d Dependency)

Append adds a new dependency to the end of the topology.

func (*Topology) AppendAfter

func (t *Topology) AppendAfter(name string, dependencies ...Dependency)

AppendAfter inserts dependencies after a given dependency name. If the dependency does not exist, it appends to the end the slice.

func (*Topology) Contains

func (t *Topology) Contains(name string) bool

Contains checks if a dependency Contains in the topology.

func (*Topology) Dependencies

func (t *Topology) Dependencies() Dependencies

Dependencies exposes the list of dependencies.

func (*Topology) GetDependency

func (t *Topology) GetDependency(name string) (*Dependency, error)

GetDependency returns the dependency for a given dependency name.

func (*Topology) PrependBefore

func (t *Topology) PrependBefore(name string, dependencies ...Dependency)

PrependBefore prepends a list of dependencies before a specific dependency.

Jump to

Keyboard shortcuts

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