function

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MPL-2.0 Imports: 11 Imported by: 4

Documentation

Overview

Package function contains all interfaces, request types, and response types for a Terraform Provider function implementation.

In Terraform, a function is a concept which enables provider developers to offer practitioners a pure function call in their configuration. Functions are defined by a function name, such as "parse_xyz", a definition representing the ordered list of parameters with associated data types and a result data type, and the function logic.

The main starting point for implementations in this package is the Function type which represents an instance of a function that has its own argument data when called. The Function implementations are referenced by a [provider.Provider] type Functions method, which enables the function for practitioner and testing usage.

Practitioner feedback is provided by the FuncError type, rather than the diag.Diagnostic type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgumentsData

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

ArgumentsData is the zero-based positional argument data sent by Terraform for a single function call. Use the Get method or GetArgument method in the Function type Run method to fetch the data.

This data is automatically populated by the framework based on the function definition. For unit testing, use the NewArgumentsData function to manually create the data.

func NewArgumentsData

func NewArgumentsData(values []attr.Value) ArgumentsData

NewArgumentsData creates an ArgumentsData. This is only necessary for unit testing as the framework automatically creates this data.

func (ArgumentsData) Equal

func (d ArgumentsData) Equal(o ArgumentsData) bool

Equal returns true if all the underlying values are equivalent.

func (ArgumentsData) Get

func (d ArgumentsData) Get(ctx context.Context, targets ...any) *FuncError

Get retrieves all argument data and populates the targets with the values. All arguments must be present in the targets, including all parameters and an optional variadic parameter, otherwise an error diagnostic will be raised. Each target type must be acceptable for the data type in the parameter definition.

Variadic parameter argument data must be consumed by a types.Tuple or Go slice type with an element type appropriate for the parameter definition ([]T). The framework automatically populates this tuple with elements matching the zero, one, or more arguments passed.

func (ArgumentsData) GetArgument

func (d ArgumentsData) GetArgument(ctx context.Context, position int, target any) *FuncError

GetArgument retrieves the argument data found at the given zero-based position and populates the target with the value. The target type must be acceptable for the data type in the parameter definition.

Variadic parameter argument data must be consumed by a types.Tuple or Go slice type with an element type appropriate for the parameter definition ([]T) at the position after all parameters. The framework automatically populates this tuple with elements matching the zero, one, or more arguments passed.

type BoolParameter

type BoolParameter struct {
	// AllowNullValue when enabled denotes that a null argument value can be
	// passed to the function. When disabled, Terraform returns an error if the
	// argument value is null.
	//
	// Enabling this requires reading argument values as *bool or [types.Bool].
	AllowNullValue bool

	// AllowUnknownValues when enabled denotes that an unknown argument value
	// can be passed to the function. When disabled, Terraform skips the
	// function call entirely and assumes an unknown value result from the
	// function.
	//
	// Enabling this requires reading argument values as [types.Bool].
	AllowUnknownValues bool

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.BoolType]. When retrieving data, the
	// [basetypes.BoolValuable] implementation associated with this custom
	// type must be used in place of [types.Bool].
	CustomType basetypes.BoolTypable

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this parameter is,
	// what it is for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description string

	// MarkdownDescription is used in various tooling, like the
	// documentation generator, to give practitioners more information
	// about what this parameter is, what it is for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Name is a short usage name for the parameter, such as "data". This name
	// is used in documentation, such as generating a function signature,
	// however its usage may be extended in the future.
	//
	// If no name is provided, this will default to "param" with a suffix of the
	// position the parameter is in the function definition. ("param1", "param2", etc.)
	// If the parameter is variadic, the default name will be "varparam".
	//
	// This must be a valid Terraform identifier, such as starting with an
	// alphabetical character and followed by alphanumeric or underscore
	// characters.
	Name string

	// Validators is a list of bool validators that should be applied to the
	// parameter.
	Validators []BoolParameterValidator
}

BoolParameter represents a function parameter that is a boolean.

When retrieving the argument value for this parameter:

  • If CustomType is set, use its associated value type.
  • If AllowUnknownValues is enabled, you must use the types.Bool value type.
  • If AllowNullValue is enabled, you must use types.Bool or *bool value types.
  • Otherwise, use types.Bool or *bool, or bool value types.

Terraform configurations set this parameter's argument data using expressions that return a bool or directly via true/false keywords.

func (BoolParameter) GetAllowNullValue

func (p BoolParameter) GetAllowNullValue() bool

GetAllowNullValue returns if the parameter accepts a null value.

func (BoolParameter) GetAllowUnknownValues

func (p BoolParameter) GetAllowUnknownValues() bool

GetAllowUnknownValues returns if the parameter accepts an unknown value.

func (BoolParameter) GetDescription

func (p BoolParameter) GetDescription() string

GetDescription returns the parameter plaintext description.

func (BoolParameter) GetMarkdownDescription

func (p BoolParameter) GetMarkdownDescription() string

GetMarkdownDescription returns the parameter Markdown description.

func (BoolParameter) GetName

func (p BoolParameter) GetName() string

GetName returns the parameter name.

func (BoolParameter) GetType

func (p BoolParameter) GetType() attr.Type

GetType returns the parameter data type.

func (BoolParameter) GetValidators added in v1.8.0

func (p BoolParameter) GetValidators() []BoolParameterValidator

GetValidators returns the list of validators for the parameter.

type BoolParameterValidator added in v1.8.0

type BoolParameterValidator interface {

	// ValidateParameterBool performs the validation.
	ValidateParameterBool(context.Context, BoolParameterValidatorRequest, *BoolParameterValidatorResponse)
}

BoolParameterValidator is a function validator for types.Bool parameters.

type BoolParameterValidatorRequest added in v1.8.0

type BoolParameterValidatorRequest struct {
	// ArgumentPosition contains the position of the argument for validation.
	// Use this position for any response diagnostics.
	ArgumentPosition int64

	// Value contains the value of the argument for validation.
	Value types.Bool
}

BoolParameterValidatorRequest is a request for types.Bool schema validation.

type BoolParameterValidatorResponse added in v1.8.0

type BoolParameterValidatorResponse struct {
	// Error is a function error generated during validation of the Value.
	Error *FuncError
}

BoolParameterValidatorResponse is a response to a BoolParameterValidatorRequest.

type BoolReturn

type BoolReturn struct {
	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.BoolType]. When setting data, the
	// [basetypes.BoolValuable] implementation associated with this custom
	// type must be used in place of [types.Bool].
	CustomType basetypes.BoolTypable
}

BoolReturn represents a function return that is a boolean.

When setting the value for this return:

- If CustomType is set, use its associated value type. - Otherwise, use types.Bool, *bool, or bool.

func (BoolReturn) GetType

func (r BoolReturn) GetType() attr.Type

GetType returns the return data type.

func (BoolReturn) NewResultData

func (r BoolReturn) NewResultData(ctx context.Context) (ResultData, *FuncError)

NewResultData returns a new result data based on the type.

type Definition

type Definition struct {
	// Parameters is the ordered list of function parameters and their
	// associated data types.
	Parameters []Parameter

	// VariadicParameter is an optional final parameter which can accept zero or
	// more arguments when the function is called. The argument data is sent as
	// a tuple, where all elements are of the same associated data type.
	VariadicParameter Parameter

	// Return is the function call response data type.
	Return Return

	// Summary is a short description of the function, preferably a single
	// sentence. Use the Description field for longer documentation about the
	// function and its implementation.
	Summary string

	// Description is the longer documentation for usage, such as editor
	// integrations, to give practitioners more information about the purpose of
	// the function and how its logic is implemented. It should be plaintext
	// formatted.
	Description string

	// MarkdownDescription is the longer documentation for usage, such as a
	// registry, to give practitioners more information about the purpose of the
	// function and how its logic is implemented.
	MarkdownDescription string

	// DeprecationMessage defines warning diagnostic details to display when
	// practitioner configurations use this function. The warning diagnostic
	// summary is automatically set to "Function Deprecated" along with
	// configuration source file and line information.
	DeprecationMessage string
}

Definition is a function definition. Always set at least the Result field.

func (Definition) ValidateImplementation

func (d Definition) ValidateImplementation(ctx context.Context, req DefinitionValidateRequest, resp *DefinitionValidateResponse)

ValidateImplementation contains logic for validating the provider-defined implementation of the definition to prevent unexpected errors or panics. This logic runs during the GetProviderSchema RPC, or via provider-defined unit testing, and should never include false positives.

type DefinitionRequest

type DefinitionRequest struct{}

DefinitionRequest represents a request for the Function to return its definition, such as its ordered parameters and result. An instance of this request struct is supplied as an argument to the Function type Definition method.

type DefinitionResponse

type DefinitionResponse struct {
	// Definition is the function definition.
	Definition Definition

	// Diagnostics report errors or warnings related to defining the function.
	// An empty slice indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics
}

DefinitionResponse represents a response to a DefinitionRequest. An instance of this response struct is supplied as an argument to the Function type Definition method. Always set at least the Definition field.

type DefinitionValidateRequest added in v1.7.0

type DefinitionValidateRequest struct {
	// FuncName is the name of the function definition being validated.
	FuncName string
}

DefinitionValidateRequest represents a request for the Function to validate its definition. An instance of this request struct is supplied as an argument to the Definition type ValidateImplementation method.

type DefinitionValidateResponse added in v1.7.0

type DefinitionValidateResponse struct {
	// Diagnostics report errors or warnings related to validation of a function
	// definition. An empty slice indicates success, with no warnings or errors
	// generated.
	Diagnostics diag.Diagnostics
}

DefinitionValidateResponse represents a response to a DefinitionValidateRequest. An instance of this response struct is supplied as an argument to the Definition type ValidateImplementation method.

type DynamicParameter added in v1.7.0

type DynamicParameter struct {
	// AllowNullValue when enabled denotes that a null argument value can be
	// passed to the function. When disabled, Terraform returns an error if the
	// argument value is null.
	AllowNullValue bool

	// AllowUnknownValues when enabled denotes that an unknown argument value
	// can be passed to the function. When disabled, Terraform skips the
	// function call entirely and assumes an unknown value result from the
	// function.
	AllowUnknownValues bool

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.DynamicType]. When retrieving data, the
	// [basetypes.DynamicValuable] implementation associated with this custom
	// type must be used in place of [types.Dynamic].
	CustomType basetypes.DynamicTypable

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this parameter is,
	// what it is for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description string

	// MarkdownDescription is used in various tooling, like the
	// documentation generator, to give practitioners more information
	// about what this parameter is, what it is for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Name is a short usage name for the parameter, such as "data". This name
	// is used in documentation, such as generating a function signature,
	// however its usage may be extended in the future.
	//
	// If no name is provided, this will default to "param" with a suffix of the
	// position the parameter is in the function definition. ("param1", "param2", etc.)
	// If the parameter is variadic, the default name will be "varparam".
	//
	// This must be a valid Terraform identifier, such as starting with an
	// alphabetical character and followed by alphanumeric or underscore
	// characters.
	Name string

	// Validators is a list of dynamic validators that should be applied to the
	// parameter.
	Validators []DynamicParameterValidator
}

DynamicParameter represents a function parameter that is a dynamic, rather than a static type. Static types are always preferable over dynamic types in Terraform as practitioners will receive less helpful configuration assistance from validation error diagnostics and editor integrations.

When retrieving the argument value for this parameter:

  • If CustomType is set, use its associated value type.
  • Otherwise, use the types.Dynamic value type.

The concrete value type for a dynamic is determined at runtime by Terraform, if defined in the configuration.

func (DynamicParameter) GetAllowNullValue added in v1.7.0

func (p DynamicParameter) GetAllowNullValue() bool

GetAllowNullValue returns if the parameter accepts a null value.

func (DynamicParameter) GetAllowUnknownValues added in v1.7.0

func (p DynamicParameter) GetAllowUnknownValues() bool

GetAllowUnknownValues returns if the parameter accepts an unknown value.

func (DynamicParameter) GetDescription added in v1.7.0

func (p DynamicParameter) GetDescription() string

GetDescription returns the parameter plaintext description.

func (DynamicParameter) GetMarkdownDescription added in v1.7.0

func (p DynamicParameter) GetMarkdownDescription() string

GetMarkdownDescription returns the parameter Markdown description.

func (DynamicParameter) GetName added in v1.7.0

func (p DynamicParameter) GetName() string

GetName returns the parameter name.

func (DynamicParameter) GetType added in v1.7.0

func (p DynamicParameter) GetType() attr.Type

GetType returns the parameter data type.

func (DynamicParameter) GetValidators added in v1.8.0

func (p DynamicParameter) GetValidators() []DynamicParameterValidator

GetValidators returns the list of validators for the parameter.

type DynamicParameterValidator added in v1.8.0

type DynamicParameterValidator interface {

	// ValidateParameterDynamic performs the validation.
	ValidateParameterDynamic(context.Context, DynamicParameterValidatorRequest, *DynamicParameterValidatorResponse)
}

DynamicParameterValidator is a function validator for types.Dynamic parameters.

type DynamicParameterValidatorRequest added in v1.8.0

type DynamicParameterValidatorRequest struct {
	// ArgumentPosition contains the position of the argument for validation.
	// Use this position for any response diagnostics.
	ArgumentPosition int64

	// Value contains the value of the argument for validation.
	Value types.Dynamic
}

DynamicParameterValidatorRequest is a request for types.Dynamic schema validation.

type DynamicParameterValidatorResponse added in v1.8.0

type DynamicParameterValidatorResponse struct {
	// Error is a function error generated during validation of the Value.
	Error *FuncError
}

DynamicParameterValidatorResponse is a response to a DynamicParameterValidatorRequest.

type DynamicReturn added in v1.7.0

type DynamicReturn struct {
	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.DynamicType]. When setting data, the
	// [basetypes.DynamicValuable] implementation associated with this custom
	// type must be used in place of [types.Dynamic].
	CustomType basetypes.DynamicTypable
}

DynamicReturn represents a function return that is a dynamic, rather than a static type. Static types are always preferable over dynamic types in Terraform as practitioners will receive less helpful configuration assistance from validation error diagnostics and editor integrations.

When setting the value for this return:

- If CustomType is set, use its associated value type. - Otherwise, use the types.Dynamic value type.

func (DynamicReturn) GetType added in v1.7.0

func (r DynamicReturn) GetType() attr.Type

GetType returns the return data type.

func (DynamicReturn) NewResultData added in v1.7.0

func (r DynamicReturn) NewResultData(ctx context.Context) (ResultData, *FuncError)

NewResultData returns a new result data based on the type.

type Float64Parameter

type Float64Parameter struct {
	// AllowNullValue when enabled denotes that a null argument value can be
	// passed to the function. When disabled, Terraform returns an error if the
	// argument value is null.
	AllowNullValue bool

	// AllowUnknownValues when enabled denotes that an unknown argument value
	// can be passed to the function. When disabled, Terraform skips the
	// function call entirely and assumes an unknown value result from the
	// function.
	AllowUnknownValues bool

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.Float64Type]. When retrieving data, the
	// [basetypes.Float64Valuable] implementation associated with this custom
	// type must be used in place of [types.Float64].
	CustomType basetypes.Float64Typable

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this parameter is,
	// what it is for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description string

	// MarkdownDescription is used in various tooling, like the
	// documentation generator, to give practitioners more information
	// about what this parameter is, what it is for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Name is a short usage name for the parameter, such as "data". This name
	// is used in documentation, such as generating a function signature,
	// however its usage may be extended in the future.
	//
	// If no name is provided, this will default to "param" with a suffix of the
	// position the parameter is in the function definition. ("param1", "param2", etc.)
	// If the parameter is variadic, the default name will be "varparam".
	//
	// This must be a valid Terraform identifier, such as starting with an
	// alphabetical character and followed by alphanumeric or underscore
	// characters.
	Name string

	// Validators is a list of float64 validators that should be applied to the
	// parameter.
	Validators []Float64ParameterValidator
}

Float64Parameter represents a function parameter that is a 64-bit floating point number.

When retrieving the argument value for this parameter:

  • If CustomType is set, use its associated value type.
  • If AllowUnknownValues is enabled, you must use the types.Float64 value type.
  • If AllowNullValue is enabled, you must use types.Float64 or *float64 value types.
  • Otherwise, use types.Float64 or *float64, or float64 value types.

Terraform configurations set this parameter's argument data using expressions that return a number or directly via numeric syntax.

func (Float64Parameter) GetAllowNullValue

func (p Float64Parameter) GetAllowNullValue() bool

GetAllowNullValue returns if the parameter accepts a null value.

func (Float64Parameter) GetAllowUnknownValues

func (p Float64Parameter) GetAllowUnknownValues() bool

GetAllowUnknownValues returns if the parameter accepts an unknown value.

func (Float64Parameter) GetDescription

func (p Float64Parameter) GetDescription() string

GetDescription returns the parameter plaintext description.

func (Float64Parameter) GetMarkdownDescription

func (p Float64Parameter) GetMarkdownDescription() string

GetMarkdownDescription returns the parameter Markdown description.

func (Float64Parameter) GetName

func (p Float64Parameter) GetName() string

GetName returns the parameter name.

func (Float64Parameter) GetType

func (p Float64Parameter) GetType() attr.Type

GetType returns the parameter data type.

func (Float64Parameter) GetValidators added in v1.8.0

func (p Float64Parameter) GetValidators() []Float64ParameterValidator

GetValidators returns the list of validators for the parameter.

type Float64ParameterValidator added in v1.8.0

type Float64ParameterValidator interface {

	// ValidateParameterFloat64 performs the validation.
	ValidateParameterFloat64(context.Context, Float64ParameterValidatorRequest, *Float64ParameterValidatorResponse)
}

Float64ParameterValidator is a function validator for types.Float64 parameters.

type Float64ParameterValidatorRequest added in v1.8.0

type Float64ParameterValidatorRequest struct {
	// ArgumentPosition contains the position of the argument for validation.
	// Use this position for any response diagnostics.
	ArgumentPosition int64

	// Value contains the value of the argument for validation.
	Value types.Float64
}

Float64ParameterValidatorRequest is a request for types.Float64 schema validation.

type Float64ParameterValidatorResponse added in v1.8.0

type Float64ParameterValidatorResponse struct {
	// Error is a function error generated during validation of the Value.
	Error *FuncError
}

Float64ParameterValidatorResponse is a response to a Float64ParameterValidatorRequest.

type Float64Return

type Float64Return struct {
	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.Float64Type]. When setting data, the
	// [basetypes.Float64Valuable] implementation associated with this custom
	// type must be used in place of [types.Float64].
	CustomType basetypes.Float64Typable
}

Float64Return represents a function return that is a 64-bit floating point number.

When setting the value for this return:

- If CustomType is set, use its associated value type. - Otherwise, use types.Float64, *float64, or float64.

func (Float64Return) GetType

func (r Float64Return) GetType() attr.Type

GetType returns the return data type.

func (Float64Return) NewResultData

func (r Float64Return) NewResultData(ctx context.Context) (ResultData, *FuncError)

NewResultData returns a new result data based on the type.

type FuncError added in v1.6.0

type FuncError struct {
	// Text is a practitioner-oriented description of the problem. This should
	// contain sufficient detail to provide both general and more specific information
	// regarding the issue. For example "Error executing function: foo can only contain
	// letters, numbers, and digits."
	Text string
	// FunctionArgument is a zero-based, int64 value that identifies the specific
	// function argument position that caused the error. Only errors that pertain
	// to a function argument will include this information.
	FunctionArgument *int64
}

FuncError is an error type specifically for function errors.

func ConcatFuncErrors added in v1.6.0

func ConcatFuncErrors(funcErrs ...*FuncError) *FuncError

ConcatFuncErrors returns a new function error with the text from all supplied function errors concatenated together. If any of the function errors have a function argument, the first one encountered will be used.

func FuncErrorFromDiags added in v1.6.0

func FuncErrorFromDiags(ctx context.Context, diags diag.Diagnostics) *FuncError

FuncErrorFromDiags iterates over the given diagnostics and returns a new function error with the summary and detail text from all error diagnostics concatenated together. Diagnostics with a severity of warning are logged but are not included in the returned function error.

func NewArgumentFuncError added in v1.6.0

func NewArgumentFuncError(functionArgument int64, text string) *FuncError

NewArgumentFuncError returns a new function error with the given message and function argument.

func NewFuncError added in v1.6.0

func NewFuncError(text string) *FuncError

NewFuncError returns a new function error with the given message.

func (*FuncError) Equal added in v1.6.0

func (fe *FuncError) Equal(other *FuncError) bool

Equal returns true if the other function error is wholly equivalent.

func (*FuncError) Error added in v1.6.0

func (fe *FuncError) Error() string

Error returns the error text.

type Function

type Function interface {
	// Metadata should return the name of the function, such as parse_xyz.
	Metadata(context.Context, MetadataRequest, *MetadataResponse)

	// Definition should return the definition for the function.
	Definition(context.Context, DefinitionRequest, *DefinitionResponse)

	// Run should return the result of the function logic. It is called when
	// Terraform reaches a function call in the configuration. Argument data
	// values should be read from the [RunRequest] and the result value set in
	// the [RunResponse].
	Run(context.Context, RunRequest, *RunResponse)
}

Function represents an instance of a function. This is the core interface that all functions must implement.

Provider-defined functions are supported in Terraform version 1.8 and later.

type Int64Parameter

type Int64Parameter struct {
	// AllowNullValue when enabled denotes that a null argument value can be
	// passed to the function. When disabled, Terraform returns an error if the
	// argument value is null.
	AllowNullValue bool

	// AllowUnknownValues when enabled denotes that an unknown argument value
	// can be passed to the function. When disabled, Terraform skips the
	// function call entirely and assumes an unknown value result from the
	// function.
	AllowUnknownValues bool

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.Int64Type]. When retrieving data, the
	// [basetypes.Int64Valuable] implementation associated with this custom
	// type must be used in place of [types.Int64].
	CustomType basetypes.Int64Typable

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this parameter is,
	// what it is for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description string

	// MarkdownDescription is used in various tooling, like the
	// documentation generator, to give practitioners more information
	// about what this parameter is, what it is for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Name is a short usage name for the parameter, such as "data". This name
	// is used in documentation, such as generating a function signature,
	// however its usage may be extended in the future.
	//
	// If no name is provided, this will default to "param" with a suffix of the
	// position the parameter is in the function definition. ("param1", "param2", etc.)
	// If the parameter is variadic, the default name will be "varparam".
	//
	// This must be a valid Terraform identifier, such as starting with an
	// alphabetical character and followed by alphanumeric or underscore
	// characters.
	Name string

	// Validators is a list of int64 validators that should be applied to the
	// parameter.
	Validators []Int64ParameterValidator
}

Int64Parameter represents a function parameter that is a 64-bit integer.

When retrieving the argument value for this parameter:

  • If CustomType is set, use its associated value type.
  • If AllowUnknownValues is enabled, you must use the types.Int64 value type.
  • If AllowNullValue is enabled, you must use types.Int64 or *int64 value types.
  • Otherwise, use types.Int64 or *int64, or int64 value types.

Terraform configurations set this parameter's argument data using expressions that return a number or directly via numeric syntax.

func (Int64Parameter) GetAllowNullValue

func (p Int64Parameter) GetAllowNullValue() bool

GetAllowNullValue returns if the parameter accepts a null value.

func (Int64Parameter) GetAllowUnknownValues

func (p Int64Parameter) GetAllowUnknownValues() bool

GetAllowUnknownValues returns if the parameter accepts an unknown value.

func (Int64Parameter) GetDescription

func (p Int64Parameter) GetDescription() string

GetDescription returns the parameter plaintext description.

func (Int64Parameter) GetMarkdownDescription

func (p Int64Parameter) GetMarkdownDescription() string

GetMarkdownDescription returns the parameter Markdown description.

func (Int64Parameter) GetName

func (p Int64Parameter) GetName() string

GetName returns the parameter name.

func (Int64Parameter) GetType

func (p Int64Parameter) GetType() attr.Type

GetType returns the parameter data type.

func (Int64Parameter) GetValidators added in v1.8.0

func (p Int64Parameter) GetValidators() []Int64ParameterValidator

GetValidators returns the list of validators for the parameter.

type Int64ParameterValidator added in v1.8.0

type Int64ParameterValidator interface {

	// ValidateParameterInt64 performs the validation.
	ValidateParameterInt64(context.Context, Int64ParameterValidatorRequest, *Int64ParameterValidatorResponse)
}

Int64ParameterValidator is a function validator for types.Int64 parameters.

type Int64ParameterValidatorRequest added in v1.8.0

type Int64ParameterValidatorRequest struct {
	// ArgumentPosition contains the position of the argument for validation.
	// Use this position for any response diagnostics.
	ArgumentPosition int64

	// Value contains the value of the argument for validation.
	Value types.Int64
}

Int64ParameterValidatorRequest is a request for types.Int64 schema validation.

type Int64ParameterValidatorResponse added in v1.8.0

type Int64ParameterValidatorResponse struct {
	// Error is a function error generated during validation of the Value.
	Error *FuncError
}

Int64ParameterValidatorResponse is a response to a Int64ParameterValidatorRequest.

type Int64Return

type Int64Return struct {
	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.Int64Type]. When setting data, the
	// [basetypes.Int64Valuable] implementation associated with this custom
	// type must be used in place of [types.Int64].
	CustomType basetypes.Int64Typable
}

Int64Return represents a function return that is a 64-bit integer number.

When setting the value for this return:

- If CustomType is set, use its associated value type. - Otherwise, use types.Int64, *int64, or int64.

func (Int64Return) GetType

func (r Int64Return) GetType() attr.Type

GetType returns the return data type.

func (Int64Return) NewResultData

func (r Int64Return) NewResultData(ctx context.Context) (ResultData, *FuncError)

NewResultData returns a new result data based on the type.

type ListParameter

type ListParameter struct {
	// ElementType is the type for all elements of the list. This field must be
	// set.
	//
	// Element types that contain a dynamic type (i.e. types.Dynamic) are not supported.
	// If underlying dynamic values are required, replace this parameter definition with
	// DynamicParameter instead.
	ElementType attr.Type

	// AllowNullValue when enabled denotes that a null argument value can be
	// passed to the function. When disabled, Terraform returns an error if the
	// argument value is null.
	AllowNullValue bool

	// AllowUnknownValues when enabled denotes that an unknown argument value
	// can be passed to the function. When disabled, Terraform skips the
	// function call entirely and assumes an unknown value result from the
	// function.
	AllowUnknownValues bool

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.ListType]. When retrieving data, the
	// [basetypes.ListValuable] implementation associated with this custom
	// type must be used in place of [types.List].
	CustomType basetypes.ListTypable

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this parameter is,
	// what it is for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description string

	// MarkdownDescription is used in various tooling, like the
	// documentation generator, to give practitioners more information
	// about what this parameter is, what it is for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Name is a short usage name for the parameter, such as "data". This name
	// is used in documentation, such as generating a function signature,
	// however its usage may be extended in the future.
	//
	// If no name is provided, this will default to "param" with a suffix of the
	// position the parameter is in the function definition. ("param1", "param2", etc.)
	// If the parameter is variadic, the default name will be "varparam".
	//
	// This must be a valid Terraform identifier, such as starting with an
	// alphabetical character and followed by alphanumeric or underscore
	// characters.
	Name string

	// Validators is a list of list validators that should be applied to the
	// parameter.
	Validators []ListParameterValidator
}

ListParameter represents a function parameter that is an ordered list of a single element type. Either the ElementType or CustomType field must be set.

When retrieving the argument value for this parameter:

  • If CustomType is set, use its associated value type.
  • If AllowUnknownValues is enabled, you must use the types.List value type.
  • Otherwise, use types.List or any Go slice value types compatible with the element type.

Terraform configurations set this parameter's argument data using expressions that return a list or directly via list ("[...]") syntax.

func (ListParameter) GetAllowNullValue

func (p ListParameter) GetAllowNullValue() bool

GetAllowNullValue returns if the parameter accepts a null value.

func (ListParameter) GetAllowUnknownValues

func (p ListParameter) GetAllowUnknownValues() bool

GetAllowUnknownValues returns if the parameter accepts an unknown value.

func (ListParameter) GetDescription

func (p ListParameter) GetDescription() string

GetDescription returns the parameter plaintext description.

func (ListParameter) GetMarkdownDescription

func (p ListParameter) GetMarkdownDescription() string

GetMarkdownDescription returns the parameter Markdown description.

func (ListParameter) GetName

func (p ListParameter) GetName() string

GetName returns the parameter name.

func (ListParameter) GetType

func (p ListParameter) GetType() attr.Type

GetType returns the parameter data type.

func (ListParameter) GetValidators added in v1.8.0

func (p ListParameter) GetValidators() []ListParameterValidator

GetValidators returns the list of validators for the parameter.

func (ListParameter) ValidateImplementation added in v1.7.0

ValidateImplementation contains logic for validating the provider-defined implementation of the parameter to prevent unexpected errors or panics. This logic runs during the GetProviderSchema RPC and should never include false positives.

type ListParameterValidator added in v1.8.0

type ListParameterValidator interface {

	// ValidateParameterList performs the validation.
	ValidateParameterList(context.Context, ListParameterValidatorRequest, *ListParameterValidatorResponse)
}

ListParameterValidator is a function validator for types.List parameters.

type ListParameterValidatorRequest added in v1.8.0

type ListParameterValidatorRequest struct {
	// ArgumentPosition contains the position of the argument for validation.
	// Use this position for any response diagnostics.
	ArgumentPosition int64

	// Value contains the value of the argument for validation.
	Value types.List
}

ListParameterValidatorRequest is a request for types.List schema validation.

type ListParameterValidatorResponse added in v1.8.0

type ListParameterValidatorResponse struct {
	// Error is a function error generated during validation of the Value.
	Error *FuncError
}

ListParameterValidatorResponse is a response to a ListParameterValidatorRequest.

type ListReturn

type ListReturn struct {
	// ElementType is the type for all elements of the list. This field must be
	// set.
	//
	// Element types that contain a dynamic type (i.e. types.Dynamic) are not supported.
	// If underlying dynamic values are required, replace this return definition with
	// DynamicReturn instead.
	ElementType attr.Type

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.ListType]. When setting data, the
	// [basetypes.ListValuable] implementation associated with this custom
	// type must be used in place of [types.List].
	CustomType basetypes.ListTypable
}

ListReturn represents a function return that is an ordered collection of a single element type. Either the ElementType or CustomType field must be set.

When setting the value for this return:

  • If CustomType is set, use its associated value type.
  • Otherwise, use types.List or a Go slice value type compatible with the element type.

func (ListReturn) GetType

func (r ListReturn) GetType() attr.Type

GetType returns the return data type.

func (ListReturn) NewResultData

func (r ListReturn) NewResultData(ctx context.Context) (ResultData, *FuncError)

NewResultData returns a new result data based on the type.

func (ListReturn) ValidateImplementation added in v1.7.0

ValidateImplementation contains logic for validating the provider-defined implementation of the Return to prevent unexpected errors or panics. This logic runs during the GetProviderSchema RPC and should never include false positives.

type MapParameter

type MapParameter struct {
	// ElementType is the type for all elements of the map. This field must be
	// set.
	//
	// Element types that contain a dynamic type (i.e. types.Dynamic) are not supported.
	// If underlying dynamic values are required, replace this parameter definition with
	// DynamicParameter instead.
	ElementType attr.Type

	// AllowNullValue when enabled denotes that a null argument value can be
	// passed to the function. When disabled, Terraform returns an error if the
	// argument value is null.
	AllowNullValue bool

	// AllowUnknownValues when enabled denotes that an unknown argument value
	// can be passed to the function. When disabled, Terraform skips the
	// function call entirely and assumes an unknown value result from the
	// function.
	AllowUnknownValues bool

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.MapType]. When retrieving data, the
	// [basetypes.MapValuable] implementation associated with this custom
	// type must be used in place of [types.Map].
	CustomType basetypes.MapTypable

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this parameter is,
	// what it is for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description string

	// MarkdownDescription is used in various tooling, like the
	// documentation generator, to give practitioners more information
	// about what this parameter is, what it is for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Name is a short usage name for the parameter, such as "data". This name
	// is used in documentation, such as generating a function signature,
	// however its usage may be extended in the future.
	//
	// If no name is provided, this will default to "param" with a suffix of the
	// position the parameter is in the function definition. ("param1", "param2", etc.)
	// If the parameter is variadic, the default name will be "varparam".
	//
	// This must be a valid Terraform identifier, such as starting with an
	// alphabetical character and followed by alphanumeric or underscore
	// characters.
	Name string

	// Validators is a list of map validators that should be applied to the
	// parameter.
	Validators []MapParameterValidator
}

MapParameter represents a function parameter that is a mapping of a single element type. Either the ElementType or CustomType field must be set.

When retrieving the argument value for this parameter:

  • If CustomType is set, use its associated value type.
  • If AllowUnknownValues is enabled, you must use the types.Map value type.
  • Otherwise, use types.Map or any Go map value types compatible with the element type.

Terraform configurations set this parameter's argument data using expressions that return a map or directly via map ("{...}") syntax.

func (MapParameter) GetAllowNullValue

func (p MapParameter) GetAllowNullValue() bool

GetAllowNullValue returns if the parameter accepts a null value.

func (MapParameter) GetAllowUnknownValues

func (p MapParameter) GetAllowUnknownValues() bool

GetAllowUnknownValues returns if the parameter accepts an unknown value.

func (MapParameter) GetDescription

func (p MapParameter) GetDescription() string

GetDescription returns the parameter plaintext description.

func (MapParameter) GetMarkdownDescription

func (p MapParameter) GetMarkdownDescription() string

GetMarkdownDescription returns the parameter Markdown description.

func (MapParameter) GetName

func (p MapParameter) GetName() string

GetName returns the parameter name.

func (MapParameter) GetType

func (p MapParameter) GetType() attr.Type

GetType returns the parameter data type.

func (MapParameter) GetValidators added in v1.8.0

func (p MapParameter) GetValidators() []MapParameterValidator

GetValidators returns the list of validators for the parameter.

func (MapParameter) ValidateImplementation added in v1.7.0

ValidateImplementation contains logic for validating the provider-defined implementation of the parameter to prevent unexpected errors or panics. This logic runs during the GetProviderSchema RPC and should never include false positives.

type MapParameterValidator added in v1.8.0

type MapParameterValidator interface {

	// ValidateParameterMap performs the validation.
	ValidateParameterMap(context.Context, MapParameterValidatorRequest, *MapParameterValidatorResponse)
}

MapParameterValidator is a function validator for types.Map parameters.

type MapParameterValidatorRequest added in v1.8.0

type MapParameterValidatorRequest struct {
	// ArgumentPosition contains the position of the argument for validation.
	// Use this position for any response diagnostics.
	ArgumentPosition int64

	// Value contains the value of the argument for validation.
	Value types.Map
}

MapParameterValidatorRequest is a request for types.Map schema validation.

type MapParameterValidatorResponse added in v1.8.0

type MapParameterValidatorResponse struct {
	// Error is a function error generated during validation of the Value.
	Error *FuncError
}

MapParameterValidatorResponse is a response to a MapParameterValidatorRequest.

type MapReturn

type MapReturn struct {
	// ElementType is the type for all elements of the map. This field must be
	// set.
	//
	// Element types that contain a dynamic type (i.e. types.Dynamic) are not supported.
	// If underlying dynamic values are required, replace this return definition with
	// DynamicReturn instead.
	ElementType attr.Type

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.MapType]. When setting data, the
	// [basetypes.MapValuable] implementation associated with this custom
	// type must be used in place of [types.Map].
	CustomType basetypes.MapTypable
}

MapReturn represents a function return that is an ordered collect of a single element type. Either the ElementType or CustomType field must be set.

When setting the value for this return:

  • If CustomType is set, use its associated value type.
  • Otherwise, use types.Map or a Go map value type compatible with the element type.

func (MapReturn) GetType

func (r MapReturn) GetType() attr.Type

GetType returns the return data type.

func (MapReturn) NewResultData

func (r MapReturn) NewResultData(ctx context.Context) (ResultData, *FuncError)

NewResultData returns a new result data based on the type.

func (MapReturn) ValidateImplementation added in v1.7.0

ValidateImplementation contains logic for validating the provider-defined implementation of the Return to prevent unexpected errors or panics. This logic runs during the GetProviderSchema RPC and should never include false positives.

type MetadataRequest

type MetadataRequest struct{}

MetadataRequest represents a request for the Function to return metadata, such as its name. An instance of this request struct is supplied as an argument to the Function type Metadata method.

type MetadataResponse

type MetadataResponse struct {
	// Name should be the function name, such as parse_xyz. Unlike data sources
	// and managed resources, the provider name and an underscore should not be
	// included as the Terraform configuration syntax for provider function
	// calls already include the provider name.
	Name string
}

MetadataResponse represents a response to a MetadataRequest. An instance of this response struct is supplied as an argument to the Function type Metadata method.

type NumberParameter

type NumberParameter struct {
	// AllowNullValue when enabled denotes that a null argument value can be
	// passed to the function. When disabled, Terraform returns an error if the
	// argument value is null.
	AllowNullValue bool

	// AllowUnknownValues when enabled denotes that an unknown argument value
	// can be passed to the function. When disabled, Terraform skips the
	// function call entirely and assumes an unknown value result from the
	// function.
	AllowUnknownValues bool

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.NumberType]. When retrieving data, the
	// [basetypes.NumberValuable] implementation associated with this custom
	// type must be used in place of [types.Number].
	CustomType basetypes.NumberTypable

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this parameter is,
	// what it is for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description string

	// MarkdownDescription is used in various tooling, like the
	// documentation generator, to give practitioners more information
	// about what this parameter is, what it is for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Name is a short usage name for the parameter, such as "data". This name
	// is used in documentation, such as generating a function signature,
	// however its usage may be extended in the future.
	//
	// If no name is provided, this will default to "param" with a suffix of the
	// position the parameter is in the function definition. ("param1", "param2", etc.)
	// If the parameter is variadic, the default name will be "varparam".
	//
	// This must be a valid Terraform identifier, such as starting with an
	// alphabetical character and followed by alphanumeric or underscore
	// characters.
	Name string

	// Validators is a list of validators that can be used to validate the
	// parameter.
	Validators []NumberParameterValidator
}

NumberParameter represents a function parameter that is a 512-bit arbitrary precision number.

When retrieving the argument value for this parameter:

  • If CustomType is set, use its associated value type.
  • If AllowUnknownValues is enabled, you must use the types.Number value type.
  • Otherwise, use types.Number or *big.Float value types.

Terraform configurations set this parameter's argument data using expressions that return a number or directly via numeric syntax.

func (NumberParameter) GetAllowNullValue

func (p NumberParameter) GetAllowNullValue() bool

GetAllowNullValue returns if the parameter accepts a null value.

func (NumberParameter) GetAllowUnknownValues

func (p NumberParameter) GetAllowUnknownValues() bool

GetAllowUnknownValues returns if the parameter accepts an unknown value.

func (NumberParameter) GetDescription

func (p NumberParameter) GetDescription() string

GetDescription returns the parameter plaintext description.

func (NumberParameter) GetMarkdownDescription

func (p NumberParameter) GetMarkdownDescription() string

GetMarkdownDescription returns the parameter Markdown description.

func (NumberParameter) GetName

func (p NumberParameter) GetName() string

GetName returns the parameter name.

func (NumberParameter) GetType

func (p NumberParameter) GetType() attr.Type

GetType returns the parameter data type.

func (NumberParameter) GetValidators added in v1.8.0

func (p NumberParameter) GetValidators() []NumberParameterValidator

GetValidators returns the list of validators for the parameter.

type NumberParameterValidator added in v1.8.0

type NumberParameterValidator interface {

	// ValidateParameterNumber performs the validation.
	ValidateParameterNumber(context.Context, NumberParameterValidatorRequest, *NumberParameterValidatorResponse)
}

NumberParameterValidator is a function validator for types.Number parameters.

type NumberParameterValidatorRequest added in v1.8.0

type NumberParameterValidatorRequest struct {
	// ArgumentPosition contains the position of the argument for validation.
	// Use this position for any response diagnostics.
	ArgumentPosition int64

	// Value contains the value of the argument for validation.
	Value types.Number
}

NumberParameterValidatorRequest is a request for types.Number schema validation.

type NumberParameterValidatorResponse added in v1.8.0

type NumberParameterValidatorResponse struct {
	// Error is a function error generated during validation of the Value.
	Error *FuncError
}

NumberParameterValidatorResponse is a response to a NumberParameterValidatorRequest.

type NumberReturn

type NumberReturn struct {
	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.NumberType]. When setting data, the
	// [basetypes.NumberValuable] implementation associated with this custom
	// type must be used in place of [types.Number].
	CustomType basetypes.NumberTypable
}

NumberReturn represents a function return that is a 512-bit arbitrary precision number.

When setting the value for this return:

- If CustomType is set, use its associated value type. - Otherwise, use types.Number or *big.Float.

func (NumberReturn) GetType

func (r NumberReturn) GetType() attr.Type

GetType returns the return data type.

func (NumberReturn) NewResultData

func (r NumberReturn) NewResultData(ctx context.Context) (ResultData, *FuncError)

NewResultData returns a new result data based on the type.

type ObjectParameter

type ObjectParameter struct {
	// AttributeTypes is the mapping of underlying attribute names to attribute
	// types. This field must be set.
	//
	// Attribute types that contain a collection with a nested dynamic type (i.e. types.List[types.Dynamic]) are not supported.
	// If underlying dynamic collection values are required, replace this parameter definition with
	// DynamicParameter instead.
	AttributeTypes map[string]attr.Type

	// AllowNullValue when enabled denotes that a null argument value can be
	// passed to the function. When disabled, Terraform returns an error if the
	// argument value is null.
	AllowNullValue bool

	// AllowUnknownValues when enabled denotes that an unknown argument value
	// can be passed to the function. When disabled, Terraform skips the
	// function call entirely and assumes an unknown value result from the
	// function.
	AllowUnknownValues bool

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.ObjectType]. When retrieving data, the
	// [basetypes.ObjectValuable] implementation associated with this custom
	// type must be used in place of [types.Object].
	CustomType basetypes.ObjectTypable

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this parameter is,
	// what it is for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description string

	// MarkdownDescription is used in various tooling, like the
	// documentation generator, to give practitioners more information
	// about what this parameter is, what it is for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Name is a short usage name for the parameter, such as "data". This name
	// is used in documentation, such as generating a function signature,
	// however its usage may be extended in the future.
	//
	// If no name is provided, this will default to "param" with a suffix of the
	// position the parameter is in the function definition. ("param1", "param2", etc.)
	// If the parameter is variadic, the default name will be "varparam".
	//
	// This must be a valid Terraform identifier, such as starting with an
	// alphabetical character and followed by alphanumeric or underscore
	// characters.
	Name string

	// Validators is a list of object validators that should be applied to the
	// parameter.
	Validators []ObjectParameterValidator
}

ObjectParameter represents a function parameter that is a mapping of defined attribute names to values. Either the AttributeTypes or CustomType field must be set.

When retrieving the argument value for this parameter:

  • If CustomType is set, use its associated value type.
  • If AllowUnknownValues is enabled, you must use the types.Object value type.
  • If AllowNullValue is enabled, you must use the types.Object or a compatible Go *struct value type.
  • Otherwise, use types.Object or compatible *struct/struct value types.

Terraform configurations set this parameter's argument data using expressions that return an object or directly via object ("{...}") syntax.

func (ObjectParameter) GetAllowNullValue

func (p ObjectParameter) GetAllowNullValue() bool

GetAllowNullValue returns if the parameter accepts a null value.

func (ObjectParameter) GetAllowUnknownValues

func (p ObjectParameter) GetAllowUnknownValues() bool

GetAllowUnknownValues returns if the parameter accepts an unknown value.

func (ObjectParameter) GetDescription

func (p ObjectParameter) GetDescription() string

GetDescription returns the parameter plaintext description.

func (ObjectParameter) GetMarkdownDescription

func (p ObjectParameter) GetMarkdownDescription() string

GetMarkdownDescription returns the parameter Markdown description.

func (ObjectParameter) GetName

func (p ObjectParameter) GetName() string

GetName returns the parameter name.

func (ObjectParameter) GetType

func (p ObjectParameter) GetType() attr.Type

GetType returns the parameter data type.

func (ObjectParameter) GetValidators added in v1.8.0

func (p ObjectParameter) GetValidators() []ObjectParameterValidator

GetValidators returns the list of validators for the parameter.

func (ObjectParameter) ValidateImplementation added in v1.7.0

ValidateImplementation contains logic for validating the provider-defined implementation of the parameter to prevent unexpected errors or panics. This logic runs during the GetProviderSchema RPC and should never include false positives.

type ObjectParameterValidator added in v1.8.0

type ObjectParameterValidator interface {

	// ValidateParameterObject ValidateParameterSet performs the validation.
	ValidateParameterObject(context.Context, ObjectParameterValidatorRequest, *ObjectParameterValidatorResponse)
}

ObjectParameterValidator is a function validator for types.Object parameters.

type ObjectParameterValidatorRequest added in v1.8.0

type ObjectParameterValidatorRequest struct {
	// ArgumentPosition contains the position of the argument for validation.
	// Use this position for any response diagnostics.
	ArgumentPosition int64

	// Value contains the value of the argument for validation.
	Value types.Object
}

ObjectParameterValidatorRequest is a request for types.Object schema validation.

type ObjectParameterValidatorResponse added in v1.8.0

type ObjectParameterValidatorResponse struct {
	// Error is a function error generated during validation of the Value.
	Error *FuncError
}

ObjectParameterValidatorResponse is a response to a ObjectParameterValidatorRequest.

type ObjectReturn

type ObjectReturn struct {
	// AttributeTypes is the mapping of underlying attribute names to attribute
	// types. This field must be set.
	//
	// Attribute types that contain a collection with a nested dynamic type (i.e. types.List[types.Dynamic]) are not supported.
	// If underlying dynamic collection values are required, replace this return definition with
	// DynamicReturn instead.
	AttributeTypes map[string]attr.Type

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.ObjectType]. When setting data, the
	// [basetypes.ObjectValuable] implementation associated with this custom
	// type must be used in place of [types.Object].
	CustomType basetypes.ObjectTypable
}

ObjectReturn represents a function return that is mapping of defined attribute names to values. When setting the value for this return, use types.Object or a compatible Go struct as the value type unless the CustomType field is set. The AttributeTypes field must be set.

func (ObjectReturn) GetType

func (r ObjectReturn) GetType() attr.Type

GetType returns the return data type.

func (ObjectReturn) NewResultData

func (r ObjectReturn) NewResultData(ctx context.Context) (ResultData, *FuncError)

NewResultData returns a new result data based on the type.

func (ObjectReturn) ValidateImplementation added in v1.7.0

ValidateImplementation contains logic for validating the provider-defined implementation of the Return to prevent unexpected errors or panics. This logic runs during the GetProviderSchema RPC and should never include false positives.

type Parameter

type Parameter interface {
	// GetAllowNullValue should return if the parameter accepts a null value.
	GetAllowNullValue() bool

	// GetAllowUnknownValues should return if the parameter accepts an unknown
	// value.
	GetAllowUnknownValues() bool

	// GetDescription should return the plaintext documentation for the
	// parameter.
	GetDescription() string

	// GetMarkdownDescription should return the Markdown documentation for the
	// parameter.
	GetMarkdownDescription() string

	// GetName should return a usage name for the parameter. Parameters are
	// positional, so this name has no meaning except documentation.
	//
	// If the name is returned as an empty string, a default name will be used to prevent Terraform errors for missing names.
	// The default name will be the prefix "param" with a suffix of the position the parameter is in the function definition. (`param1`, `param2`, etc.)
	// If the parameter is variadic, the default name will be `varparam`.
	GetName() string

	// GetType should return the data type for the parameter, which determines
	// what data type Terraform requires for configurations setting the argument
	// during a function call and the argument data type received by the
	// Function type Run method.
	GetType() attr.Type
}

Parameter is the interface for defining function parameters.

type ParameterWithBoolValidators added in v1.8.0

type ParameterWithBoolValidators interface {
	Parameter

	// GetValidators should return a list of Bool validators.
	GetValidators() []BoolParameterValidator
}

ParameterWithBoolValidators is an optional interface on Parameter which enables Bool validation support.

type ParameterWithDynamicValidators added in v1.8.0

type ParameterWithDynamicValidators interface {
	Parameter

	// GetValidators should return a list of Dynamic validators.
	GetValidators() []DynamicParameterValidator
}

ParameterWithDynamicValidators is an optional interface on Parameter which enables Dynamic validation support.

type ParameterWithFloat64Validators added in v1.8.0

type ParameterWithFloat64Validators interface {
	Parameter

	// GetValidators should return a list of Float64 validators.
	GetValidators() []Float64ParameterValidator
}

ParameterWithFloat64Validators is an optional interface on Parameter which enables Float64 validation support.

type ParameterWithInt64Validators added in v1.8.0

type ParameterWithInt64Validators interface {
	Parameter

	// GetValidators should return a list of Int64 validators.
	GetValidators() []Int64ParameterValidator
}

ParameterWithInt64Validators is an optional interface on Parameter which enables Int64 validation support.

type ParameterWithListValidators added in v1.8.0

type ParameterWithListValidators interface {
	Parameter

	// GetValidators should return a list of List validators.
	GetValidators() []ListParameterValidator
}

ParameterWithListValidators is an optional interface on Parameter which enables List validation support.

type ParameterWithMapValidators added in v1.8.0

type ParameterWithMapValidators interface {
	Parameter

	// GetValidators should return a list of Map validators.
	GetValidators() []MapParameterValidator
}

ParameterWithMapValidators is an optional interface on Parameter which enables Map validation support.

type ParameterWithNumberValidators added in v1.8.0

type ParameterWithNumberValidators interface {
	Parameter

	// GetValidators should return a list of Map validators.
	GetValidators() []NumberParameterValidator
}

ParameterWithNumberValidators is an optional interface on Parameter which enables Number validation support.

type ParameterWithObjectValidators added in v1.8.0

type ParameterWithObjectValidators interface {
	Parameter

	// GetValidators should return a list of Object validators.
	GetValidators() []ObjectParameterValidator
}

ParameterWithObjectValidators is an optional interface on Parameter which enables Object validation support.

type ParameterWithSetValidators added in v1.8.0

type ParameterWithSetValidators interface {
	Parameter

	// GetValidators should return a list of Set validators.
	GetValidators() []SetParameterValidator
}

ParameterWithSetValidators is an optional interface on Parameter which enables Set validation support.

type ParameterWithStringValidators added in v1.8.0

type ParameterWithStringValidators interface {
	Parameter

	// GetValidators should return a list of String validators.
	GetValidators() []StringParameterValidator
}

ParameterWithStringValidators is an optional interface on Parameter which enables String validation support.

type ResultData

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

ResultData is the response data sent to Terraform for a single function call. Use the Set method in the Function type Run method to set the result data.

For unit testing, use the NewResultData function to manually create the data for comparison.

func NewResultData

func NewResultData(value attr.Value) ResultData

NewResultData creates a ResultData. This is only necessary for unit testing as the framework automatically creates this data for the Function type Run method.

func (ResultData) Equal

func (d ResultData) Equal(o ResultData) bool

Equal returns true if the value is equivalent.

func (*ResultData) Set

func (d *ResultData) Set(ctx context.Context, value any) *FuncError

Set saves the result data. The value type must be acceptable for the data type in the result definition.

func (ResultData) Value

func (d ResultData) Value() attr.Value

Value returns the saved value.

type Return

type Return interface {
	// GetType should return the data type for the return, which determines
	// what data type Terraform requires for configurations receiving the
	// response of a function call and the return data type required from the
	// Function type Run method.
	GetType() attr.Type

	// NewResultData should return a new ResultData with an unknown value (or
	// best approximation of an invalid value) of the corresponding data type.
	// The Function type Run method is expected to overwrite the value before
	// returning.
	NewResultData(context.Context) (ResultData, *FuncError)
}

Return is the interface for defining function return data.

type RunRequest

type RunRequest struct {
	// Arguments is the data sent from Terraform. Use the ArgumentsData type
	// GetArgument method to retrieve each positional argument.
	Arguments ArgumentsData
}

RunRequest represents a request for the Function to call its implementation logic. An instance of this request struct is supplied as an argument to the Function type Run method.

type RunResponse

type RunResponse struct {
	// Error contains errors related to running the function.
	// A nil error indicates success, with no errors generated.
	// [ConcatFuncErrors] can be used to combine multiple errors into a single error.
	Error *FuncError

	// Result is the data to be returned to Terraform matching the function
	// result definition. This must be set or an error diagnostic is raised. Use
	// the ResultData type Set method to save the data.
	Result ResultData
}

RunResponse represents a response to a RunRequest. An instance of this response struct is supplied as an argument to the Function type Run method.

type SetParameter

type SetParameter struct {
	// ElementType is the type for all elements of the set. This field must be
	// set.
	//
	// Element types that contain a dynamic type (i.e. types.Dynamic) are not supported.
	// If underlying dynamic values are required, replace this parameter definition with
	// DynamicParameter instead.
	ElementType attr.Type

	// AllowNullValue when enabled denotes that a null argument value can be
	// passed to the function. When disabled, Terraform returns an error if the
	// argument value is null.
	AllowNullValue bool

	// AllowUnknownValues when enabled denotes that an unknown argument value
	// can be passed to the function. When disabled, Terraform skips the
	// function call entirely and assumes an unknown value result from the
	// function.
	AllowUnknownValues bool

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.SetType]. When retrieving data, the
	// [basetypes.SetValuable] implementation associated with this custom
	// type must be used in place of [types.Set].
	CustomType basetypes.SetTypable

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this parameter is,
	// what it is for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description string

	// MarkdownDescription is used in various tooling, like the
	// documentation generator, to give practitioners more information
	// about what this parameter is, what it is for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Name is a short usage name for the parameter, such as "data". This name
	// is used in documentation, such as generating a function signature,
	// however its usage may be extended in the future.
	//
	// If no name is provided, this will default to "param" with a suffix of the
	// position the parameter is in the function definition. ("param1", "param2", etc.)
	// If the parameter is variadic, the default name will be "varparam".
	//
	// This must be a valid Terraform identifier, such as starting with an
	// alphabetical character and followed by alphanumeric or underscore
	// characters.
	Name string

	// Validators is a list of set validators that should be applied to the
	// parameter.
	Validators []SetParameterValidator
}

SetParameter represents a function parameter that is an unordered set of a single element type. Either the ElementType or CustomType field must be set.

When retrieving the argument value for this parameter:

  • If CustomType is set, use its associated value type.
  • If AllowUnknownValues is enabled, you must use the types.Set value type.
  • Otherwise, use types.Set or any Go slice value types compatible with the element type.

Terraform configurations set this parameter's argument data using expressions that return a set or directly via set ("[...]") syntax.

func (SetParameter) GetAllowNullValue

func (p SetParameter) GetAllowNullValue() bool

GetAllowNullValue returns if the parameter accepts a null value.

func (SetParameter) GetAllowUnknownValues

func (p SetParameter) GetAllowUnknownValues() bool

GetAllowUnknownValues returns if the parameter accepts an unknown value.

func (SetParameter) GetDescription

func (p SetParameter) GetDescription() string

GetDescription returns the parameter plaintext description.

func (SetParameter) GetMarkdownDescription

func (p SetParameter) GetMarkdownDescription() string

GetMarkdownDescription returns the parameter Markdown description.

func (SetParameter) GetName

func (p SetParameter) GetName() string

GetName returns the parameter name.

func (SetParameter) GetType

func (p SetParameter) GetType() attr.Type

GetType returns the parameter data type.

func (SetParameter) GetValidators added in v1.8.0

func (p SetParameter) GetValidators() []SetParameterValidator

GetValidators returns the list of validators for the parameter.

func (SetParameter) ValidateImplementation added in v1.7.0

ValidateImplementation contains logic for validating the provider-defined implementation of the parameter to prevent unexpected errors or panics. This logic runs during the GetProviderSchema RPC and should never include false positives.

type SetParameterValidator added in v1.8.0

type SetParameterValidator interface {

	// ValidateParameterSet performs the validation.
	ValidateParameterSet(context.Context, SetParameterValidatorRequest, *SetParameterValidatorResponse)
}

SetParameterValidator is a function validator for types.Set parameters.

type SetParameterValidatorRequest added in v1.8.0

type SetParameterValidatorRequest struct {
	// ArgumentPosition contains the position of the argument for validation.
	// Use this position for any response diagnostics.
	ArgumentPosition int64

	// Value contains the value of the argument for validation.
	Value types.Set
}

SetParameterValidatorRequest is a request for types.Set schema validation.

type SetParameterValidatorResponse added in v1.8.0

type SetParameterValidatorResponse struct {
	// Error is a function error generated during validation of the Value.
	Error *FuncError
}

SetParameterValidatorResponse is a response to a SetParameterValidatorRequest.

type SetReturn

type SetReturn struct {
	// ElementType is the type for all elements of the set. This field must be
	// set.
	//
	// Element types that contain a dynamic type (i.e. types.Dynamic) are not supported.
	// If underlying dynamic values are required, replace this return definition with
	// DynamicReturn instead.
	ElementType attr.Type

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.SetType]. When setting data, the
	// [basetypes.SetValuable] implementation associated with this custom
	// type must be used in place of [types.Set].
	CustomType basetypes.SetTypable
}

SetReturn represents a function return that is an unordered collection of a single element type. Either the ElementType or CustomType field must be set.

When setting the value for this return:

  • If CustomType is set, use its associated value type.
  • Otherwise, use types.Set or a Go slice value type compatible with the element type.

func (SetReturn) GetType

func (r SetReturn) GetType() attr.Type

GetType returns the return data type.

func (SetReturn) NewResultData

func (r SetReturn) NewResultData(ctx context.Context) (ResultData, *FuncError)

NewResultData returns a new result data based on the type.

func (SetReturn) ValidateImplementation added in v1.7.0

ValidateImplementation contains logic for validating the provider-defined implementation of the Return to prevent unexpected errors or panics. This logic runs during the GetProviderSchema RPC and should never include false positives.

type StringParameter

type StringParameter struct {
	// AllowNullValue when enabled denotes that a null argument value can be
	// passed to the function. When disabled, Terraform returns an error if the
	// argument value is null.
	AllowNullValue bool

	// AllowUnknownValues when enabled denotes that an unknown argument value
	// can be passed to the function. When disabled, Terraform skips the
	// function call entirely and assumes an unknown value result from the
	// function.
	AllowUnknownValues bool

	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.StringType]. When retrieving data, the
	// [basetypes.StringValuable] implementation associated with this custom
	// type must be used in place of [types.String].
	CustomType basetypes.StringTypable

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this parameter is,
	// what it is for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description string

	// MarkdownDescription is used in various tooling, like the
	// documentation generator, to give practitioners more information
	// about what this parameter is, what it is for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Name is a short usage name for the parameter, such as "data". This name
	// is used in documentation, such as generating a function signature,
	// however its usage may be extended in the future.
	//
	// If no name is provided, this will default to "param" with a suffix of the
	// position the parameter is in the function definition. ("param1", "param2", etc.)
	// If the parameter is variadic, the default name will be "varparam".
	//
	// This must be a valid Terraform identifier, such as starting with an
	// alphabetical character and followed by alphanumeric or underscore
	// characters.
	Name string

	// Validators is a list of string validators that should be applied to the
	// parameter.
	Validators []StringParameterValidator
}

StringParameter represents a function parameter that is a string.

When retrieving the argument value for this parameter:

  • If CustomType is set, use its associated value type.
  • If AllowUnknownValues is enabled, you must use the types.String value type.
  • If AllowNullValue is enabled, you must use types.String or *string value types.
  • Otherwise, use types.String or *string, or string value types.

Terraform configurations set this parameter's argument data using expressions that return a string or directly via double quote ("value") syntax.

func (StringParameter) GetAllowNullValue

func (p StringParameter) GetAllowNullValue() bool

GetAllowNullValue returns if the parameter accepts a null value.

func (StringParameter) GetAllowUnknownValues

func (p StringParameter) GetAllowUnknownValues() bool

GetAllowUnknownValues returns if the parameter accepts an unknown value.

func (StringParameter) GetDescription

func (p StringParameter) GetDescription() string

GetDescription returns the parameter plaintext description.

func (StringParameter) GetMarkdownDescription

func (p StringParameter) GetMarkdownDescription() string

GetMarkdownDescription returns the parameter Markdown description.

func (StringParameter) GetName

func (p StringParameter) GetName() string

GetName returns the parameter name.

func (StringParameter) GetType

func (p StringParameter) GetType() attr.Type

GetType returns the parameter data type.

func (StringParameter) GetValidators added in v1.8.0

func (p StringParameter) GetValidators() []StringParameterValidator

GetValidators returns the string validators for the parameter.

type StringParameterValidator added in v1.8.0

type StringParameterValidator interface {

	// ValidateParameterString performs the validation.
	ValidateParameterString(context.Context, StringParameterValidatorRequest, *StringParameterValidatorResponse)
}

StringParameterValidator is a function validator for types.String parameters.

type StringParameterValidatorRequest added in v1.8.0

type StringParameterValidatorRequest struct {
	// ArgumentPosition contains the position of the argument for validation.
	// Use this position for any response diagnostics.
	ArgumentPosition int64

	// Value contains the value of the argument for validation.
	Value types.String
}

StringParameterValidatorRequest is a request for types.String schema validation.

type StringParameterValidatorResponse added in v1.8.0

type StringParameterValidatorResponse struct {
	// Error is a function error generated during validation of the Value.
	Error *FuncError
}

StringParameterValidatorResponse is a response to a StringParameterValidatorRequest.

type StringReturn

type StringReturn struct {
	// CustomType enables the use of a custom data type in place of the
	// default [basetypes.StringType]. When setting data, the
	// [basetypes.StringValuable] implementation associated with this custom
	// type must be used in place of [types.String].
	CustomType basetypes.StringTypable
}

StringReturn represents a function return that is a string.

When setting the value for this return:

- If CustomType is set, use its associated value type. - Otherwise, use types.String, *string, or string.

func (StringReturn) GetType

func (r StringReturn) GetType() attr.Type

GetType returns the return data type.

func (StringReturn) NewResultData

func (r StringReturn) NewResultData(ctx context.Context) (ResultData, *FuncError)

NewResultData returns a new result data based on the type.

type ValidateParameterRequest added in v1.8.0

type ValidateParameterRequest struct {
	// Position is the zero-ordered position of the parameter being validated.
	Position int64
}

ValidateParameterRequest represents a request for the attr.Value to call its validation logic. An instance of this request struct is supplied as an argument to the attr.Value type ValidateParameter method.

type ValidateParameterResponse added in v1.8.0

type ValidateParameterResponse struct {
	// Error is a function error generated during validation of the attr.Value.
	Error *FuncError
}

ValidateParameterResponse represents a response to a ValidateParameterRequest. An instance of this response struct is supplied as an argument to the ValidateParameter method.

type ValidateableParameter added in v1.8.0

type ValidateableParameter interface {
	// ValidateParameter returns any error generated during validation
	// of the parameter. It is generally used to check the data format and ensure
	// that it complies with the requirements of the attr.Value.
	ValidateParameter(context.Context, ValidateParameterRequest, *ValidateParameterResponse)
}

ValidateableParameter defines an interface for validating a parameter value.

Jump to

Keyboard shortcuts

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