providerv1

package
v0.0.0-...-d91e878 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProviderPlugin

func NewProviderPlugin(bpProvider provider.Provider) providerserverv1.ProviderServer

NewProviderPlugin creates a new instance of a provider plugin from a blueprint framework provider.Provider implementation. This produces a gRPC server plugin that the build engine host can use to interact with the provider.

func NewProviderPluginFromDefinition

func NewProviderPluginFromDefinition(definition ProviderPluginDefinition) providerserverv1.ProviderServer

NewProviderPluginFromDefinition creates a new instance of a provider plugin from a ProviderPluginDefinition. This produces a gRPC server plugin that the build engine host can use to interact with the provider.

Types

type ContextFunc

type ContextFunc[Arg any] func(context.Context, Arg) error

ContextFunc is a function that takes a context and an argument and returns an error.

func Retryable

func Retryable[Arg any](function ContextFunc[Arg]) ContextFunc[Arg]

Retryable wraps a function that only returns an error and makes it retryable in the plugin system.

func Timeout

func Timeout[Arg any](function ContextFunc[Arg], timeout time.Duration) ContextFunc[Arg]

Timeout wraps a function that only returns an error and apples a timeout to it. Timeouts can be due to transient or permanent issues, to retry a timeout error, wrap the timeout function with Retryable.

type ContextFuncReturnValue

type ContextFuncReturnValue[Arg any, Value any] func(context.Context, Arg) (Value, error)

ContextFuncReturnValue is a function that takes a context, an argument and returns a value and an error.

func RetryableReturnValue

func RetryableReturnValue[Arg any, Value any](
	function ContextFuncReturnValue[Arg, Value],
) ContextFuncReturnValue[Arg, Value]

RetryableReturnValue wraps a function that returns a value and an error and makes it retryable in the plugin system.

func TimeoutReturnValue

func TimeoutReturnValue[Arg any, Value any](
	function ContextFuncReturnValue[Arg, Value],
	timeout time.Duration,
) ContextFuncReturnValue[Arg, Value]

TimeoutReturnValue wraps a function that returns a value and an error and applies a timeout to it. Timeouts can be due to transient or permanent issues, to retry a timeout error, wrap the timeout function with RetryableReturnValue.

type PluginError

type PluginError struct {
	ErrorCode providerserverv1.ErrorCode
	Message   string
}

PluginError provides a custom error type to be used in the plugin system, this is converted to a logical error when returning to the build engine host as opposed to a protocol error.

func (PluginError) Error

func (p PluginError) Error() string

type ProviderPluginDefinition

type ProviderPluginDefinition struct {
	Namespace           string
	Resources           map[string]provider.Resource
	DataSources         map[string]provider.DataSource
	Links               map[string]provider.Link
	CustomVariableTypes map[string]provider.CustomVariableType
}

ProviderPluginDefinition is a template to be used when creating provider plugins. It provides a structure that allows you to define the resources, data sources, links and custom variable types that are supported by the provider 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.

type ResourceDefinition

type ResourceDefinition struct {
	// The type of the resource, prefixed by the namespace of the provider.
	// Example: "aws/lambda/function" for the "aws" provider.
	Type string

	// The schema of the resource used for validation.
	Schema map[string]*schema.Schema

	// Specifies whether this 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.
	CommonTerminal bool

	// A function that can be used to dynamically determine whether a resource is likely
	// to be a common terminal resource (does not link out to other resources).
	CommonTerminalFunc func(ctx context.Context, params core.BlueprintParams) (bool, error)

	// A static list of resource types that this resource can link to.
	CanLinkTo []string

	// A function that can be used to dynamically determine what resource types this resource
	// can link to.
	CanLinkToFunc func(
		ctx context.Context,
		params core.BlueprintParams,
	) ([]string, error)

	// A function to stage the changes for a resource prior to deployment.
	// This will diff against the current resource state and the desired state
	// and indicate what is likely to change.
	// In a lot of cases, there are values that are not known until the resource is deployed
	// so it is best to given an estimate of what will change.
	StageChangesFunc func(
		ctx context.Context,
		input *provider.ResourceStageChangesInput,
	) (*provider.ResourceStageChangesOutput, error)

	// A function to retrieve the current state of the resource from the upstream system.
	// (e.g. fetch the state of an Lambda Function from AWS)
	GetExternalStateFunc func(
		ctx context.Context,
		input *provider.ResourceGetExternalStateInput,
	) (*provider.ResourceGetExternalStateOutput, error)

	// A function to deploy the resource.
	DeployFunc func(
		ctx context.Context,
		input *provider.ResourceDeployInput,
	) (*provider.ResourceDeployOutput, error)

	// A function to delete the resource in the upstream provider.
	DestroyFunc func(
		ctx context.Context,
		input *provider.ResourceDestroyInput,
	) error
}

ResourceDefinition is a template to be used for defining resources when creating provider plugins. It provides a structure that allows you to define a schema and behaviour of a resource.

Jump to

Keyboard shortcuts

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