resolver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidExpression the expression is not a valid CEL expression.
	ErrInvalidExpression = errors.New("invalid CEL expression")
	// ErrMissingIntegrations one or more integrations aren't configured.
	ErrMissingIntegrations = errors.New("missing integrations")
)
View Source
var (
	// ErrInvalidCollection the collection is invalid.
	ErrInvalidCollection = errors.New("invalid collection")
	// ErrDependencyNotFound the dependency is not found in the collection.
	ErrDependencyNotFound = errors.New("dependency not found")
)
View Source
var (
	// ErrUnknownIntegration the integration name is not supported, unknown.
	ErrUnknownIntegration = errors.New("unknown integration")
	// ErrPrerequisiteIntegration dependency prerequisite integration(s) missing.
	ErrPrerequisiteIntegration = errors.New(
		"dependency prerequisite integration(s) missing")
)
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 CEL

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

CEL represents the CEL environment with provided integration names, the integrations present in the cluster are represented by a map of integration name and boolean, indicating the integration is configured in the cluster.

func NewCEL

func NewCEL(integrationNames ...string) (*CEL, error)

NewCEL creates a new CEL instance with the all valid integration names. These names are considered variables in the CEL expression, limiting the scope of the expression to only valid integrations.

func (*CEL) Evaluate

func (c *CEL) Evaluate(configured map[string]bool, expression string) error

Evaluate evaluates the provided CEL expression against the current context of integration names and a boolean indicating whether it's configured.

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(_ *api.AppContext, 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) GetProductNameForIntegration

func (c *Collection) GetProductNameForIntegration(integrationName string) string

GetProductNameForIntegration searches and returns the product name by integration name. It goes though all charts and search for annotation "integrations-provided". If it matches integration name, then returns product name, which is from annotation "product-name".

func (*Collection) Walk

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

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

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) IntegrationsProvided

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

IntegrationsProvided returns the integrations provided.

func (*Dependency) IntegrationsRequired

func (d *Dependency) IntegrationsRequired() string

IntegrationsRequired returns the integrations required.

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.

func (*Dependency) Weight

func (d *Dependency) Weight() (int, error)

Weight returns the weight of this dependency. If no weight is specified, zero is returned. The weight must be specified as an integer value.

type DependencyWalkFn

type DependencyWalkFn func(string, Dependency) error

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

type Integrations

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

Integrations represents the actor which inspects the integrations provided and required by each Helm chart (dependency) in the Topology.

func NewIntegrations

func NewIntegrations(
	ctx context.Context,
	cfg *config.Config,
	manager *integrations.Manager,
) (*Integrations, error)

NewIntegrations creates a new Integrations instance. It populates the a map with the integrations that are currently configured in the cluster, marking the others as missing.

func (*Integrations) Inspect

func (i *Integrations) Inspect(t *Topology) error

Inspect walks the Topology in two passes to evaluate integrations provided and required by each dependency. The two-pass approach makes validation order-independent: all provisions are collected first, then all requirements are evaluated against the complete state.

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, taking the weight into account.

func (*Topology) Walk

func (t *Topology) Walk(fn DependencyWalkFn) error

Walk traverses the topology and calls the informed function for each dependency.

type TopologyBuilder

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

TopologyBuilder represents the complete workflow to generate a consolidated Topology, with dependencies and integrations verified.

func NewTopologyBuilder

func NewTopologyBuilder(
	appCtx *api.AppContext,
	logger *slog.Logger,
	cfs *chartfs.ChartFS,
	integrationsManager *integrations.Manager,
) (*TopologyBuilder, error)

NewTopologyBuilder creates a new TopologyBuilder instance.

func (*TopologyBuilder) Build

func (t *TopologyBuilder) Build(
	ctx context.Context,
	cfg *config.Config,
) (*Topology, error)

Build inspects the dependencies, based on the cluster configuration, inspects the integrations and generates a consolidated Topology.

func (*TopologyBuilder) GetCollection

func (t *TopologyBuilder) GetCollection() *Collection

GetCollection exposes the collection instance.

Jump to

Keyboard shortcuts

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