resolver

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ProductNameAnnotation defines the product name a chart is responsible 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)

	// WeightAnnotation defines the weight a chart has in the topology, which
	// allows moving a dependency down or up in the topology. The annotation
	// "depends-on" takes preference over the weight annotation.
	WeightAnnotation = fmt.Sprintf("%s/weight", 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,
	)

	// IntegrationsProvidedAnnotation defines the list of integrations secrets a
	// Helm chart provides.
	IntegrationsProvidedAnnotation = fmt.Sprintf(
		"%s/integrations-provided",
		constants.RepoURI,
	)

	// IntegrationsRequiredAnnotation defines the list of integrations secrets a
	// Helm chart requires.
	IntegrationsRequiredAnnotation = fmt.Sprintf(
		"%s/integrations-required",
		constants.RepoURI,
	)
)
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 error = errors.New("invalid collection")
	// ErrDependencyNotFound the dependency is not found in the collection.
	ErrDependencyNotFound error = 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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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(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 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 added in v1.8.0

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

IntegrationsProvided returns the integrations provided

func (*Dependency) IntegrationsRequired added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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

Inspect loops the Topology and evaluates the integrations required by each dependency, as well integrations provided by them. The inspection keeps the state of the integrations configured in the cluster.

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 added in v1.8.0

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

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

type TopologyBuilder added in v1.8.0

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 added in v1.8.0

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

NewTopologyBuilder creates a new TopologyBuilder instance.

func (*TopologyBuilder) Build added in v1.8.0

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 added in v1.8.0

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