deps

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package deps resolves component dependencies based on a collection of components and some input-requirements

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoOpMatcher

func NoOpMatcher(ref bundle.ComponentReference, m MatchMetadata) bool

NoOpMatcher doesn't do any matching; it returns true (use component) for all components.

Types

type AnnotationCriteria

type AnnotationCriteria struct {
	// Match are component annotations that must to be present. This is useful
	// for matching positive characteristics of a component (example: this
	// component passed qualification). Only one of the list of values need be
	// present. In other words, given values A, B, C for Annotation K, the logic
	// is equivalent to A || B || C).
	//
	// If there are multiple keys (annotations) specified, then all annotations
	// must match.  In other words, this is a logical AND operation of the passed
	// in Annotation and the component Annotation.
	//
	// If the list of values is empty, then the annotation is matched for any
	// annotation value.
	Match map[string][]string

	// Exclude are component annotations that must not be present.  This is
	// useful for matching positive characteristics of a component (this
	// component passed qualification). If any of the list of values match,
	// the component is excluded.
	//
	// Unlike Match, if a there are multiple keys (annotations) specified, then
	// only one of the annotations need be matched in order for the component to
	// be excluded.
	//
	// If the list of values is empty, then the annotation is matched
	// for any annotation value.
	Exclude map[string][]string
}

AnnotationCriteria are options for resolving dependencies

type AnnotationMetadata

type AnnotationMetadata struct {
	Annotations map[string]string
}

AnnotationMetadata contains annotation metadata, used for matching against components.

type MatchMetadata

type MatchMetadata interface{}

MatchMetadata is optional metadata stored on the node to be used for matching.

func AnnotationProcessor

func AnnotationProcessor(c *bundle.Component) (MatchMetadata, error)

AnnotationProcessor extracts annotations from a component, to be used for Matching

func NoOpMatchProcessor

func NoOpMatchProcessor(c *bundle.Component) (MatchMetadata, error)

NoOpMatchProcessor doesn't do any processing

type MatchProcessor

type MatchProcessor func(c *bundle.Component) (MatchMetadata, error)

MatchProcessor is a function that's called on every component during the creation of the resolver.

type Matcher

type Matcher func(ref bundle.ComponentReference, m MatchMetadata) bool

Matcher is a function that performs some additional *unconditional* matching on a node. True means that the component should be used; false means it shouldn't.

In other words, the matching that is applied should be consistent across components during the matching phase. If the matching is conditional, which is to say relies on some context of the parents or children, then it will cause errors in dependency resolution.

func AnnotationMatcher

func AnnotationMatcher(criteria *AnnotationCriteria) Matcher

AnnotationMatcher constructs a Matcher that relies on a components annotations.

type ResolveOptions

type ResolveOptions struct {
	// Matcher is a boolean matcher for applying additional unconditional criteria to
	// componenst during the pick-process.
	Matcher Matcher
}

ResolveOptions are options for resolving dependencies

type Resolver

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

Resolver is a dependency resolver.

func NewResolver

func NewResolver(components []*bundle.Component, mp MatchProcessor) (*Resolver, error)

NewResolver takes in a list of components that make up the universe.

func (*Resolver) AllComponents

func (r *Resolver) AllComponents() []*bundle.Component

AllComponents returns all the componenst known by the resolver

func (*Resolver) Component

func (r *Resolver) Component(ref bundle.ComponentReference) *bundle.Component

Component retrieves a component (which is copied for safety), returning nil if isn't known by the resolver.

func (*Resolver) ComponentVersions

func (r *Resolver) ComponentVersions(comp string) []bundle.ComponentReference

ComponentVersions gets the versions for a particular component, returning an empty list of component references if the component cannot be found.

func (*Resolver) HasComponent

func (r *Resolver) HasComponent(ref bundle.ComponentReference) bool

HasComponent indicates whether a component is known by the resolver.

func (*Resolver) Resolve

Resolve resolves dependencies for several components, returning the components references that correspond to that version selection. In general, the latest versions of components are preferred

These components must exist within the Resolver's set of components. If a version is not specified for a component reference, the latest version is used.

Jump to

Keyboard shortcuts

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