Documentation
¶
Index ¶
- Variables
- type CEL
- type Collection
- type Dependencies
- type Dependency
- func (d *Dependency) Chart() *chart.Chart
- func (d *Dependency) DependsOn() []string
- func (d *Dependency) IntegrationsProvided() []string
- func (d *Dependency) IntegrationsRequired() string
- func (d *Dependency) LoggerWith(logger *slog.Logger) *slog.Logger
- func (d *Dependency) Name() string
- func (d *Dependency) Namespace() string
- func (d *Dependency) ProductName() string
- func (d *Dependency) SetNamespace(namespace string)
- func (d *Dependency) UseProductNamespace() string
- func (d *Dependency) Weight() (int, error)
- type DependencyWalkFn
- type Integrations
- type Resolver
- type Topology
- func (t *Topology) Append(d Dependency)
- func (t *Topology) AppendAfter(name string, dependencies ...Dependency)
- func (t *Topology) Contains(name string) bool
- func (t *Topology) Dependencies() Dependencies
- func (t *Topology) GetDependency(name string) (*Dependency, error)
- func (t *Topology) PrependBefore(name string, dependencies ...Dependency)
- func (t *Topology) Walk(fn DependencyWalkFn) error
- type TopologyBuilder
Constants ¶
This section is empty.
Variables ¶
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") )
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") )
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") )
var ErrCircularDependency = fmt.Errorf("circular dependency detected")
ErrCircularDependency reports a circular dependency.
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.
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.
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 (*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) 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 ¶
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.