links

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GroupResourcesBySelector

func GroupResourcesBySelector(spec speccore.BlueprintSpec) map[string]*SelectGroup

GroupResourcesBySelector deals with collecting resources by selectors from the given blueprint spec. This produces a mapping of {selectorAttributeType}::{selectorAttributeKey}:{selectorAttributeValue} ->

{ SelectorResources, CandidateResourcesForSelection }.

For example, "label::app:orderApi" -> { SelectorResources, CandidateResourcesForSelection }.

Types

type ChainLinkNode

type ChainLinkNode struct {
	// ResourceName is the unique name in the spec for the current
	// resource in the chain.
	ResourceName string
	// Resource holds the information about a resource at the blueprint spec schema-level,
	// most importantly the resource type that allows us to efficiently get a resource type
	// provider implementation for a link in a chain.
	Resource *schema.Resource
	// Selectors provides a mapping of the selector attribute to the resources
	// the current resource links to.
	// (e.g. "label::app:orderApi" -> ["createOrderFunction", "removeOrderFunction"])
	Selectors map[string][]string
	// LinkImplementations holds the link provider implementations keyed by resource name
	// for all the resources the current resource in the chain links
	// to.
	LinkImplementations map[string]provider.Link
	// LinksTo holds the chain link nodes for the resources
	// that the curent resource links to.
	LinksTo []*ChainLinkNode
	// LinkedFrom holds the chain link nodes that link to the current resource.
	// This information is important to allow backtracking when the blueprint container
	// is deciding the order in which resources should be deployed.
	LinkedFrom []*ChainLinkNode
	// Paths holds all the different "routes" to get to the current link in a set of chains.
	// These are known as materialised paths in the context of tree data structures.
	// Having this information here allows us to efficiently find out if
	// there is a relationship between two links at any depth in the chain.
	Paths []string
}

ChainLinkNode provides a node in a chain of links that contains the name of the current resource in the chain, selectors used to link it with other resources, the implementation for each outward link and the chain link nodes that the current resource links out to.

func (*ChainLinkNode) Equal

func (l *ChainLinkNode) Equal(otherLink *ChainLinkNode) bool

type LinkError

type LinkError struct {
	ReasonCode   LinkErrorReasonCode
	Err          error
	FromResource *ResourceWithNameAndSelectors
	ToResource   *ResourceWithNameAndSelectors
	FromLink     *ChainLinkNode
	ToLink       *ChainLinkNode
	ChildErrors  []error
}

func (*LinkError) Error

func (e *LinkError) Error() string

type LinkErrorReasonCode

type LinkErrorReasonCode string
const (
	// LinkErrorReasonCodeMissingLinkImpl is provided
	// when the reason for a blueprint chain link building error
	// is due to a missing link implementation
	// when a resource type is reported to be able to link to
	// another resource type.
	LinkErrorReasonCodeMissingLinkImpl LinkErrorReasonCode = "missing_link_implementation"
	// LinkErrorReasonCodeCircularLinks is provided
	// when one or more circular links are found in a blueprint
	// in the process of building our chains to be used the blueprint container
	// for deployment orchestration.
	LinkErrorReasonCodeCircularLinks LinkErrorReasonCode = "circular_links"
	// LinkErrorReasonCodeCircularLink is provided
	// when a circular link is found in a blueprint
	// in the process of building our chains to be used the blueprint container
	// for deployment orchestration.
	LinkErrorReasonCodeCircularLink LinkErrorReasonCode = "circular_link"
)

type ResourceWithNameAndSelectors

type ResourceWithNameAndSelectors struct {
	Name      string
	Resource  *schema.Resource
	Selectors []string
}

ResourceWithNameAndSelectors holds a resource in a blueprint spec schema along with a name in the context of a blueprint and the selectors used to link to other resources.

type SelectGroup

type SelectGroup struct {
	SelectorResources              []*ResourceWithNameAndSelectors
	CandidateResourcesForSelection []*ResourceWithNameAndSelectors
}

SelectGroup provides a grouping of selector and selected resources that should be used under the banner of a selector attribute such as a label. A selector will have a "linkSelector" definition which could be "label::app:orderApi" for example and then the candidate resources for selection are all the resources in the spec that have the "orderApi" label.

type SpecLinkInfo

type SpecLinkInfo interface {
	// Links deals with determining the links for all link selectors
	// and metadata labels defined in the spec.
	// This produces a slice of tree structures that represents link chains in the spec
	// where each link in the chain contains the from and to resource names,
	// the labels in the spec that link them together and the provider.Link implementation.
	// This will return an error when a link defined in the spec
	// is not supported.
	Links(ctx context.Context) ([]*ChainLinkNode, error)
	// Warnings provides a list of warnings for potential issues
	// with the links in a provided specification.
	Warnings(ctx context.Context) ([]string, error)
}

SpecLinkInfo provides the interface for a service that provides information about the links in a blueprint. This is mostly useful for validating and loading a blueprint specification. This also provides information for the blueprint container to source the provider link implementations by resource types.

func NewDefaultLinkInfoProvider

func NewDefaultLinkInfoProvider(
	resourceTypeProviderMap map[string]provider.Provider,
	linkRegistry provider.LinkRegistry,
	spec speccore.BlueprintSpec,
	blueprintParams bpcore.BlueprintParams,
) (SpecLinkInfo, error)

NewDefaultLinkInfoProvider creates a new instance of the default implementation of a link info provider. This prepares all the information as a part of initialisation and validates the linking in the spec. The map of resource providers must be a map of provider resource name to a provider.

Jump to

Keyboard shortcuts

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