transformerv1

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrorReasonCodeCrossAbstractConcreteBoundaryLink indicates that
	// a link crosses the abstract-concrete boundary in the blueprint.
	ErrorReasonCodeCrossAbstractConcreteBoundaryLink errors.ErrorReasonCode = "cross_abstract_concrete_boundary_link"
	// ErrorReasonCodeNoSuchAbstractLinkDefinition indicates that a link references
	// an abstract link type for which there is no definition in the transformer plugin.
	ErrorReasonCodeNoSuchAbstractLinkDefinition errors.ErrorReasonCode = "no_such_abstract_link_definition"
	// ErrorReasonCodeMissingAnnotationResource indicates that an annotation resource
	// referenced in the abstract link definition is missing from the blueprint.
	ErrorReasonCodeMissingAnnotationResource errors.ErrorReasonCode = "missing_annotation_resource"
)

Variables

This section is empty.

Functions

func NewTransformerPlugin

func NewTransformerPlugin(
	bpTransformer transform.SpecTransformer,
	hostInfoContainer pluginutils.HostInfoContainer,
	serviceClient pluginservicev1.ServiceClient,
) transformerserverv1.TransformerServer

NewTransformerPlugin creates a new instance of a transformer plugin from a blueprint framework transform.SpecTransforemr implementation. This produces a gRPC server plugin that the deploy engine host can interact with. The `TransformerPluginDefinition` utility type can be passed in to create a transformer plugin server as it implements the `transform.SpecTransformer` interface.

The host info container is used to retrieve the ID of the host that the plugin was registered with.

The service client is used to communicate with other plugins that are registered with the deploy engine host.

Types

type AbstractLinkDefinition added in v0.5.0

type AbstractLinkDefinition struct {
	// The type of the source abstract resource in the link relationship.
	// (e.g. "celerity/api").
	ResourceTypeA string

	// The type of the destination abstract resource in the link relationship.
	// (e.g. "celerity/handler").
	ResourceTypeB string

	// A summary of the link type that is not formatted that can be used
	// to render descriptions in contexts that formatting is not supported.
	// This will be used in documentation and tooling.
	PlainTextSummary string

	// A summary of the link type that can be formatted using markdown.
	// This will be used in documentation and tooling.
	FormattedSummary string

	// A description of the link type that is not formatted that can be used
	// to render descriptions in contexts that formatting is not supported.
	// This will be used in documentation and tooling.
	PlainTextDescription string

	// A description of the link type that can be formatted using markdown.
	// This will be used in documentation and tooling.
	FormattedDescription string

	// A mapping of annotation names prefixed by resource type that
	// can be used to fine tune the behaviour of a link in a blueprint spec.
	// The format should be as follows:
	// {resourceType}::{annotationName} -> LinkAnnotationDefinition
	// e.g. "celerity/handler::celerity.handler.http.method" -> LinkAnnotationDefinition
	AnnotationDefinitions map[string]*provider.LinkAnnotationDefinition

	// CardinalityA: how many B's each A may link to.
	//   Example: celerity/handler → celerity/api, CardinalityA = {Min: 0, Max: 1}
	//     means a handler may link to at most one api.
	CardinalityA provider.LinkCardinality

	// CardinalityB: how many A's may link to each B.
	//   Example: celerity/api ← celerity/handler, CardinalityB = {Min: 1, Max: 0}
	//     means every api must have at least one handler linking to it
	//     (Max: 0 = unlimited).
	CardinalityB provider.LinkCardinality

	// Custom validation function for constraints that can't be expressed declaratively.
	// Called once per resolved edge matching this definition. Runs after
	// the declarative checks; additional diagnostics are concatenated.
	ValidateFunc func(
		ctx context.Context,
		input *AbstractLinkValidateInput,
	) (*AbstractLinkValidateOutput, error)
}

AbstractLinkDefinition declares a link between two abstract resource types. It is the abstract resource analogue of providerv1.LinkDefinition, minus the execution logic as abstract links don't deploy anything; they are expanded into concrete resource properties and links during transformation.

func (*AbstractLinkDefinition) GetAnnotationDefinitions added in v0.5.0

func (*AbstractLinkDefinition) GetCardinality added in v0.5.0

func (*AbstractLinkDefinition) GetType added in v0.5.0

func (*AbstractLinkDefinition) GetTypeDescription added in v0.5.0

type AbstractLinkValidateInput added in v0.5.0

type AbstractLinkValidateInput struct {
	Edge               *linktypes.ResolvedLink
	LinkGraph          linktypes.DeclaredLinkGraph
	TransformerContext transform.Context
}

AbstractLinkValidateInput is the input to the custom validate function for an AbstractLinkDefinition.

type AbstractLinkValidateOutput added in v0.5.0

type AbstractLinkValidateOutput struct {
	Diagnostics []*core.Diagnostic
}

AbstractLinkValidateOutput is the output of the custom validate function for an AbstractLinkDefinition.

type AbstractResourceDefinition

type AbstractResourceDefinition struct {
	// The type of the abstract resource.
	// Example: "celerity/handler".
	Type string

	// A human-readable label for the abstract resource type.
	// This will be used in documentation and tooling.
	Label string

	// A summary of the abstract resource type that is not formatted that can be used
	// to render descriptions in contexts that formatting is not supported.
	// This will be used in documentation and tooling.
	PlainTextSummary string

	// A summary of the abstract resource type that can be formatted using markdown.
	// This will be used in documentation and tooling.
	FormattedSummary string

	// A description of the abstract resource type that is not formatted that can be used
	// to render descriptions in contexts that formatting is not supported.
	// This will be used in documentation and tooling.
	PlainTextDescription string

	// A description of the abstract resource type that can be formatted using markdown.
	// This will be used in documentation and tooling.
	FormattedDescription string

	// A list of plain text examples that can be used to
	// demonstrate how to use the abstract resource.
	// This will be used in documentation and tooling.
	PlainTextExamples []string

	// A list of markdown examples that can be used to
	// demonstrate how to use the abstract resource.
	// This will be used in documentation and tooling.
	FormattedExamples []string

	// The schema of the abstract resource specification that comes under the `spec` field
	// of a resource in a blueprint.
	Schema *provider.ResourceDefinitionsSchema

	// Holds the name of the field in the abstract resource schema
	// that holds the third-party
	// ID of the abstract resource.
	// This is used to resolve references to a resource in a blueprint
	// where only the name of the resource is specified.
	// For example, references such as `resources.processOrderHandler` or
	// `processOrderHandler` should resolve to the ID of the resource in the blueprint.
	// The ID field must be a top-level property of the resource spec schema.
	//
	// For abstract resources, this should point to an underlying ID value
	// in the primary concrete resource that the abstract resource expands to.
	IDField string

	// Specifies whether this abstract resource is expected to have a common use-case
	// as a terminal resource that does not link out to other resources.
	// This is useful for providing useful warnings to users about their blueprints
	// without overloading them with warnings for all resources that don't have any outbound
	// links that could have.
	// If CommonTerminalFunc is provided, this static value will not be used.
	CommonTerminal bool

	// A function that can be used to dynamically determine whether an abstract resource is likely
	// to be a common terminal resource (does not link out to other resources).
	CommonTerminalFunc func(
		ctx context.Context,
		input *transform.AbstractResourceIsCommonTerminalInput,
	) (*transform.AbstractResourceIsCommonTerminalOutput, error)

	// A function to apply custom validation for an abstract resource
	// that goes beyond validating against the resource spec schema which
	// the blueprint framework takes care of.
	// When not provided, the plugin will return a result with an empty list
	// of diagnostics.
	CustomValidateFunc func(
		ctx context.Context,
		input *transform.AbstractResourceValidateInput,
	) (*transform.AbstractResourceValidateOutput, error)
}

AbstractResourceDefinition is a template to be used for defining abstract resources when creating transformer plugins. It provides a structure that allows you to define a schema and behaviour of a resource. This implements the `transform.AbstractResource` interface and can be used in the same way as any other resource implementation used in a transformer plugin.

type TransformerPluginDefinition

type TransformerPluginDefinition struct {

	// The transform name string that is to be used in the
	// `transform` field of a blueprint.
	TransformName string

	// Configuration definition for the transformer plugin.
	TransformerConfigDefinition *core.ConfigDefinition

	// A mapping of asbtract resource types to their
	// implementations.
	AbstractResources map[string]transform.AbstractResource

	// A set of link definitions between abstract resource types
	// owned by this transformer. Each entry is keyed by
	// "{ResourceTypeA}::{ResourceTypeB}" for fast edge-class lookup.
	// (e.g. "celerity/handler::celerity/api")
	AbstractLinks map[string]*AbstractLinkDefinition

	// A function to transform a blueprint.
	// If this function is not set, the default implementation
	// will return the input blueprint as the transformed blueprint.
	TransformFunc func(
		ctx context.Context,
		input *transform.SpecTransformerTransformInput,
	) (*transform.SpecTransformerTransformOutput, error)
}

TransformerPluginDefinition is a template to be used when creating transformer plugins. It provides a structure that allows you to define the abstract resources supported by the transformer plugin. This doesn't have to be used but is a useful way to define the plugin's capabilities, there are multiple convenience functions to create new plugins. This implements the `transform.SpecTransformer` interface and can be used in the same way as any other transformer implementation to create a transformer plugin.

func (p *TransformerPluginDefinition) AbstractLink(
	ctx context.Context,
	linkType string,
) (transform.AbstractLink, error)

func (*TransformerPluginDefinition) AbstractResource

func (p *TransformerPluginDefinition) AbstractResource(
	ctx context.Context,
	abstractResourceType string,
) (transform.AbstractResource, error)

func (*TransformerPluginDefinition) ConfigDefinition

func (p *TransformerPluginDefinition) ConfigDefinition(
	ctx context.Context,
) (*core.ConfigDefinition, error)

func (*TransformerPluginDefinition) GetTransformName

func (p *TransformerPluginDefinition) GetTransformName(
	ctx context.Context,
) (string, error)

func (*TransformerPluginDefinition) ListAbstractLinkTypes added in v0.5.0

func (p *TransformerPluginDefinition) ListAbstractLinkTypes(
	ctx context.Context,
) ([]string, error)

func (*TransformerPluginDefinition) ListAbstractResourceTypes

func (p *TransformerPluginDefinition) ListAbstractResourceTypes(
	ctx context.Context,
) ([]string, error)

Jump to

Keyboard shortcuts

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