component

package
v0.26.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjectRootPath = "."
)

Variables

View Source
var (
	ErrMissingField    = errors.New("Missing content field")
	ErrEmptyFieldLabel = errors.New("Unexpected empty field label")
	ErrCUEBuildError   = errors.New("CUE Build Error")
)
View Source
var (
	ErrCyclicDependency     = errors.New("Cyclic dependency detected")
	ErrDuplicateComponentID = errors.New("Duplicate Component ID")
	ErrUnknownComponentID   = errors.New("Unknown Component ID")
)

Functions

func WithPackagePath

func WithPackagePath(packagePath string) buildOption

WithPackagePath provides package path configuration.

func WithProjectRoot

func WithProjectRoot(projectRootPath string) buildOption

WithProjectRoot provides the path to the project root.

Types

type BuildResult

type BuildResult struct {
	Instances          []Instance
	UpdateInstructions []version.UpdateInstruction
}

type Builder

type Builder struct {
}

Builder compiles and decodes CUE kubernetes manifest definitions of a component to the corresponding Go struct.

func NewBuilder

func NewBuilder() Builder

NewBuilder contructs a Builder.

func (Builder) Build

func (b Builder) Build(opts ...buildOption) (*BuildResult, error)

Build accepts options defining which cue package to compile and compiles it to a slice of component Instances.

type DependencyGraph

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

DependencyGraph is an adjacency list which represents the directed acyclic graph of component dependencies. The Dependencies field in the Node struct holds a list of other component ids to which the current component has edges.

func NewDependencyGraph

func NewDependencyGraph() DependencyGraph

func (*DependencyGraph) Delete

func (graph *DependencyGraph) Delete(componentID string)

func (*DependencyGraph) Get

func (graph *DependencyGraph) Get(componentID string) Instance

Get returns the Component if it has been identified by its id. It returns nil if no Node has been found.

func (*DependencyGraph) Insert

func (graph *DependencyGraph) Insert(nodes ...Instance) error

Insert places given Nodes into the DependencyGraph. It returns an error if a given Node id / component id already exists in the graph.

func (*DependencyGraph) TopologicalSort

func (dag *DependencyGraph) TopologicalSort() ([]Instance, error)

TopologicalSort performs a topological sort on the component dependency graph and returns the sorted order. It returns an error if a cycle is detected.

type ExtendedUnstructured

type ExtendedUnstructured = kube.ExtendedUnstructured

type FieldMetadata

type FieldMetadata = kube.ManifestFieldMetadata

type Instance

type Instance interface {
	GetID() string
	GetDependencies() []string
}

Instance represents a Navecd component with its id, dependencies and content. It is the Go equivalent of the CUE definition the user interacts with. ID is constructed based on the content of the component.

type InstanceLayer added in v0.26.2

type InstanceLayer struct {
	Components []Instance
}

InstanceLayer holds a slice of unrelated components, which can be processed concurrently.

func Layer added in v0.26.2

func Layer(instances []Instance) []InstanceLayer

Layer takes a topologically sorted slice of components and packs them into layers. A layer holds a slice of unrelated components, which can be processed concurrently. The zeroth layer contains components with no dependencies. Components are assigned to layers based on their dependencies' layers. If a dependency is in layer 0, the component gets placed into layer 1. If a dependency is in layer 0 and another dependency in layer 2, the component gets placed into layer 3.

type Manifest

type Manifest = kube.Manifest

type Reconciler

type Reconciler struct {
	Log logr.Logger

	// DynamicClient connects to a Kubernetes cluster
	// to create, read, update and delete manifests/objects.
	DynamicClient *kube.ExtendedDynamicClient

	// ChartReconciler reads Helm Packages with their desired state
	// and applies them on a Kubernetes cluster.
	// It stores releases in the inventory, but never collects it.
	ChartReconciler helm.ChartReconciler

	// Instance is a representation of an inventory.
	// It can store, delete and read items.
	// The object does not include the storage itself, it only holds a reference to the storage.
	InventoryInstance *inventory.Instance

	// Managers identify distinct workflows that are modifying the object (especially useful on conflicts!),
	FieldManager string

	// Limit of concurrent reconciliations.
	WorkerPoolSize int
}

Reconciler reads Components with their desired state and applies them on a Kubernetes cluster. It stores objects in the inventory.

func (*Reconciler) Reconcile

func (reconciler *Reconciler) Reconcile(
	ctx context.Context,
	instances []Instance,
) error

Jump to

Keyboard shortcuts

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