tfsdk

package
Version: v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: MPL-2.0 Imports: 13 Imported by: 131

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPathInsideAtomicAttribute is used with AttributeAtPath is called
	// on a path that doesn't have a schema associated with it, because
	// it's an element or attribute of a complex type, not a nested
	// attribute.
	ErrPathInsideAtomicAttribute = errors.New("path leads to element or attribute of a schema.Attribute that has no schema associated with it")
)

Functions

func ConvertValue added in v0.4.0

func ConvertValue(ctx context.Context, val attr.Value, typ attr.Type) (attr.Value, diag.Diagnostics)

ConvertValue creates a new attr.Value of the attr.Type `typ`, using the data in `val`, which can be of any attr.Type so long as its TerraformType method returns a tftypes.Type that `typ`'s ValueFromTerraform method can accept.

func NewProtocol6Server added in v0.2.0

func NewProtocol6Server(p Provider) tfprotov6.ProviderServer

NewProtocol6Server returns a tfprotov6.ProviderServer implementation based on the passed Provider implementation.

func ResourceImportStateNotImplemented added in v0.4.0

func ResourceImportStateNotImplemented(ctx context.Context, details string, resp *ImportResourceStateResponse)

ResourceImportStateNotImplemented is a helper function to return an error diagnostic about the resource not supporting import. The details defaults to a generic message to contact the provider developer, but can be customized to provide specific information or recommendations.

func ResourceImportStatePassthroughID added in v0.4.0

func ResourceImportStatePassthroughID(ctx context.Context, path *tftypes.AttributePath, req ImportResourceStateRequest, resp *ImportResourceStateResponse)

ResourceImportStatePassthroughID is a helper function to set the import identifier to a given state attribute path. The attribute must accept a string value.

func Serve

func Serve(ctx context.Context, factory func() Provider, opts ServeOpts) error

Serve serves a provider, blocking until the context is canceled.

func ValueAs added in v0.3.0

func ValueAs(ctx context.Context, val attr.Value, target interface{}) diag.Diagnostics

ValueAs populates the Go value passed as `target` with the contents of `val`, using the reflection rules defined for `Get` and `GetAttribute`.

Types

type Attribute added in v0.3.0

type Attribute struct {
	// Type indicates what kind of attribute this is. You'll most likely
	// want to use one of the types in the types package.
	//
	// If Type is set, Attributes cannot be.
	Type attr.Type

	// Attributes can have their own, nested attributes. This nested map of
	// attributes behaves exactly like the map of attributes on the Schema
	// type.
	//
	// If Attributes is set, Type cannot be.
	Attributes NestedAttributes

	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this attribute is,
	// what it's 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 attribute is, what it's for, and how it should be
	// used. It should be formatted using Markdown.
	MarkdownDescription string

	// Required indicates whether the practitioner must enter a value for
	// this attribute or not. Required and Optional cannot both be true,
	// and Required and Computed cannot both be true.
	Required bool

	// Optional indicates whether the practitioner can choose not to enter
	// a value for this attribute or not. Optional and Required cannot both
	// be true.
	Optional bool

	// Computed indicates whether the provider may return its own value for
	// this attribute or not. Required and Computed cannot both be true. If
	// Required and Optional are both false, Computed must be true, and the
	// attribute will be considered "read only" for the practitioner, with
	// only the provider able to set its value.
	Computed bool

	// Sensitive indicates whether the value of this attribute should be
	// considered sensitive data. Setting it to true will obscure the value
	// in CLI output. Sensitive does not impact how values are stored, and
	// practitioners are encouraged to store their state as if the entire
	// file is sensitive.
	Sensitive bool

	// DeprecationMessage defines a message to display to practitioners
	// using this attribute, warning them that it is deprecated and
	// instructing them on what upgrade steps to take.
	DeprecationMessage string

	// Validators defines validation functionality for the attribute.
	Validators []AttributeValidator

	// PlanModifiers defines a sequence of modifiers for this attribute at
	// plan time. Attribute-level plan modifications occur before any
	// resource-level plan modifications.
	//
	// Any errors will prevent further execution of this sequence
	// of modifiers and modifiers associated with any nested Attribute, but will not
	// prevent execution of PlanModifiers on any other Attribute in the Schema.
	//
	// Plan modification only applies to resources, not data sources or
	// providers. Setting PlanModifiers on a data source or provider attribute
	// will have no effect.
	PlanModifiers AttributePlanModifiers
}

Attribute defines the constraints and behaviors of a single field in a schema. Attributes are the fields that show up in Terraform state files and can be used in configuration files.

func (Attribute) ApplyTerraform5AttributePathStep added in v0.3.0

func (a Attribute) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)

ApplyTerraform5AttributePathStep transparently calls ApplyTerraform5AttributePathStep on a.Type or a.Attributes, whichever is non-nil. It allows Attributes to be walked using tftypes.Walk and tftypes.Transform.

func (Attribute) Equal added in v0.3.0

func (a Attribute) Equal(o Attribute) bool

Equal returns true if `a` and `o` should be considered Equal.

type AttributePlanModifier added in v0.3.0

type AttributePlanModifier interface {
	// Description is used in various tooling, like the language server, to
	// give practitioners more information about what this modifier is,
	// what it's for, and how it should be used. It should be written as
	// plain text, with no special formatting.
	Description(context.Context) string

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

	// Modify is called when the provider has an opportunity to modify
	// the plan: once during the plan phase when Terraform is determining
	// the diff that should be shown to the user for approval, and once
	// during the apply phase with any unknown values from configuration
	// filled in with their final values.
	//
	// The Modify function has access to the config, state, and plan for
	// both the attribute in question and the entire resource, but it can
	// only modify the value of the one attribute.
	//
	// Any returned errors will stop further execution of plan modifications
	// for this Attribute and any nested Attribute. Other Attribute at the same
	// or higher levels of the Schema will still execute any plan modifications
	// to ensure all warnings and errors across all root Attribute are
	// captured.
	//
	// Please see the documentation for ResourceWithModifyPlan#ModifyPlan
	// for further details.
	Modify(context.Context, ModifyAttributePlanRequest, *ModifyAttributePlanResponse)
}

AttributePlanModifier represents a modifier for an attribute at plan time. An AttributePlanModifier can only modify the planned value for the attribute on which it is defined. For plan-time modifications that modify the values of several attributes at once, please instead use the ResourceWithModifyPlan interface by defining a ModifyPlan function on the resource.

func RequiresReplace added in v0.3.0

func RequiresReplace() AttributePlanModifier

RequiresReplace returns an AttributePlanModifier specifying the attribute as requiring replacement. This behaviour is identical to the ForceNew behaviour in terraform-plugin-sdk.

func RequiresReplaceIf added in v0.3.0

func RequiresReplaceIf(f RequiresReplaceIfFunc, description, markdownDescription string) AttributePlanModifier

RequiresReplaceIf returns an AttributePlanModifier that runs the conditional function f: if it returns true, it specifies the attribute as requiring replacement.

type AttributePlanModifiers added in v0.3.0

type AttributePlanModifiers []AttributePlanModifier

AttributePlanModifiers represents a sequence of AttributePlanModifiers, in order.

type AttributeValidator added in v0.3.0

type AttributeValidator interface {
	// Description describes the validation in plain text formatting.
	//
	// This information may be automatically added to schema plain text
	// descriptions by external tooling.
	Description(context.Context) string

	// MarkdownDescription describes the validation in Markdown formatting.
	//
	// This information may be automatically added to schema Markdown
	// descriptions by external tooling.
	MarkdownDescription(context.Context) string

	// Validate performs the validation.
	Validate(context.Context, ValidateAttributeRequest, *ValidateAttributeResponse)
}

AttributeValidator describes reusable Attribute validation functionality.

type Config

type Config struct {
	Raw    tftypes.Value
	Schema Schema
}

Config represents a Terraform config.

func (Config) Get

func (c Config) Get(ctx context.Context, target interface{}) diag.Diagnostics

Get populates the struct passed as `target` with the entire config.

func (Config) GetAttribute

func (c Config) GetAttribute(ctx context.Context, path *tftypes.AttributePath) (attr.Value, diag.Diagnostics)

GetAttribute retrieves the attribute found at `path` and returns it as an attr.Value. Consumers should assert the type of the returned value with the desired attr.Type.

type ConfigureProviderRequest

type ConfigureProviderRequest struct {
	// TerraformVersion is the version of Terraform executing the request.
	// This is supplied for logging, analytics, and User-Agent purposes
	// only. Providers should not try to gate provider behavior on
	// Terraform versions.
	TerraformVersion string

	// Config is the configuration the user supplied for the provider. This
	// information should usually be persisted to the underlying type
	// that's implementing the Provider interface, for use in later
	// resource CRUD operations.
	Config Config
}

ConfigureProviderRequest represents a request containing the values the user specified for the provider configuration block, along with other runtime information from Terraform or the Plugin SDK. An instance of this request struct is supplied as an argument to the provider's Configure function.

type ConfigureProviderResponse

type ConfigureProviderResponse struct {
	// Diagnostics report errors or warnings related to configuring the
	// provider. An empty slice indicates success, with no warnings or
	// errors generated.
	Diagnostics diag.Diagnostics
}

ConfigureProviderResponse represents a response to a ConfigureProviderRequest. An instance of this response struct is supplied as an argument to the provider's Configure function, in which the provider should set values on the ConfigureProviderResponse as appropriate.

func (*ConfigureProviderResponse) AddAttributeError

func (r *ConfigureProviderResponse) AddAttributeError(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeError appends an error diagnostic to the response and labels it with a specific attribute.

func (*ConfigureProviderResponse) AddAttributeWarning

func (r *ConfigureProviderResponse) AddAttributeWarning(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeWarning appends a warning diagnostic to the response and labels it with a specific attribute.

func (*ConfigureProviderResponse) AddError

func (r *ConfigureProviderResponse) AddError(summary, detail string)

AddError appends an error diagnostic to the response. If the error concerns a particular attribute, AddAttributeError should be used instead.

func (*ConfigureProviderResponse) AddWarning

func (r *ConfigureProviderResponse) AddWarning(summary, detail string)

AddWarning appends a warning diagnostic to the response. If the warning concerns a particular attribute, AddAttributeWarning should be used instead.

type CreateResourceRequest

type CreateResourceRequest struct {
	// Config is the configuration the user supplied for the resource.
	//
	// This configuration may contain unknown values if a user uses
	// interpolation or other functionality that would prevent Terraform
	// from knowing the value at request time.
	Config Config

	// Plan is the planned state for the resource.
	Plan Plan

	// ProviderMeta is metadata from the provider_meta block of the module.
	ProviderMeta Config
}

CreateResourceRequest represents a request for the provider to create a resource. An instance of this request struct is supplied as an argument to the resource's Create function.

type CreateResourceResponse

type CreateResourceResponse struct {
	// State is the state of the resource following the Create operation.
	// This field is pre-populated from CreateResourceRequest.Plan and
	// should be set during the resource's Create operation.
	State State

	// Diagnostics report errors or warnings related to creating the
	// resource. An empty slice indicates a successful operation with no
	// warnings or errors generated.
	Diagnostics diag.Diagnostics
}

CreateResourceResponse represents a response to a CreateResourceRequest. An instance of this response struct is supplied as an argument to the resource's Create function, in which the provider should set values on the CreateResourceResponse as appropriate.

func (*CreateResourceResponse) AddAttributeError

func (r *CreateResourceResponse) AddAttributeError(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeError appends an error diagnostic to the response and labels it with a specific attribute.

func (*CreateResourceResponse) AddAttributeWarning

func (r *CreateResourceResponse) AddAttributeWarning(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeWarning appends a warning diagnostic to the response and labels it with a specific attribute.

func (*CreateResourceResponse) AddError

func (r *CreateResourceResponse) AddError(summary, detail string)

AddError appends an error diagnostic to the response. If the error concerns a particular attribute, AddAttributeError should be used instead.

func (*CreateResourceResponse) AddWarning

func (r *CreateResourceResponse) AddWarning(summary, detail string)

AddWarning appends a warning diagnostic to the response. If the warning concerns a particular attribute, AddAttributeWarning should be used instead.

type DataSource

type DataSource interface {
	// Read is called when the provider must read data source values in
	// order to update state. Config values should be read from the
	// ReadDataSourceRequest and new state values set on the
	// ReadDataSourceResponse.
	Read(context.Context, ReadDataSourceRequest, *ReadDataSourceResponse)
}

DataSource represents a data source instance. This is the core interface that all data sources must implement.

type DataSourceConfigValidator added in v0.3.0

type DataSourceConfigValidator interface {
	// Description describes the validation in plain text formatting.
	//
	// This information may be automatically added to data source plain text
	// descriptions by external tooling.
	Description(context.Context) string

	// MarkdownDescription describes the validation in Markdown formatting.
	//
	// This information may be automatically added to data source Markdown
	// descriptions by external tooling.
	MarkdownDescription(context.Context) string

	// Validate performs the validation.
	Validate(context.Context, ValidateDataSourceConfigRequest, *ValidateDataSourceConfigResponse)
}

DataSourceConfigValidator describes reusable data source configuration validation functionality.

type DataSourceType

type DataSourceType interface {
	// GetSchema returns the schema for this data source.
	GetSchema(context.Context) (Schema, diag.Diagnostics)

	// NewDataSource instantiates a new DataSource of this DataSourceType.
	NewDataSource(context.Context, Provider) (DataSource, diag.Diagnostics)
}

A DataSourceType is a type of data source. For each type of data source this provider supports, it should define a type implementing DataSourceType and return an instance of it in the map returned by Provider.GetDataSources.

type DataSourceWithConfigValidators added in v0.3.0

type DataSourceWithConfigValidators interface {
	DataSource

	// ConfigValidators returns a list of DataSourceConfigValidators. Each DataSourceConfigValidator's Validate method will be called when validating the data source.
	ConfigValidators(context.Context) []DataSourceConfigValidator
}

DataSourceWithConfigValidators is an interface type that extends DataSource to include declarative validations.

Declaring validation using this methodology simplifies implmentation of reusable functionality. These also include descriptions, which can be used for automating documentation.

Validation will include ConfigValidators and ValidateConfig, if both are implemented, in addition to any Attribute or Type validation.

type DataSourceWithValidateConfig added in v0.3.0

type DataSourceWithValidateConfig interface {
	DataSource

	// ValidateConfig performs the validation.
	ValidateConfig(context.Context, ValidateDataSourceConfigRequest, *ValidateDataSourceConfigResponse)
}

DataSourceWithValidateConfig is an interface type that extends DataSource to include imperative validation.

Declaring validation using this methodology simplifies one-off functionality that typically applies to a single data source. Any documentation of this functionality must be manually added into schema descriptions.

Validation will include ConfigValidators and ValidateConfig, if both are implemented, in addition to any Attribute or Type validation.

type DeleteResourceRequest

type DeleteResourceRequest struct {
	// State is the current state of the resource prior to the Delete
	// operation.
	State State

	// ProviderMeta is metadata from the provider_meta block of the module.
	ProviderMeta Config
}

DeleteResourceRequest represents a request for the provider to delete a resource. An instance of this request struct is supplied as an argument to the resource's Delete function.

type DeleteResourceResponse

type DeleteResourceResponse struct {
	// State is the state of the resource following the Delete operation.
	// This field is pre-populated from UpdateResourceRequest.Plan and
	// should be set during the resource's Update operation.
	State State

	// Diagnostics report errors or warnings related to deleting the
	// resource. An empty slice indicates a successful operation with no
	// warnings or errors generated.
	Diagnostics diag.Diagnostics
}

DeleteResourceResponse represents a response to a DeleteResourceRequest. An instance of this response struct is supplied as an argument to the resource's Delete function, in which the provider should set values on the DeleteResourceResponse as appropriate.

func (*DeleteResourceResponse) AddAttributeError

func (r *DeleteResourceResponse) AddAttributeError(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeError appends an error diagnostic to the response and labels it with a specific attribute.

func (*DeleteResourceResponse) AddAttributeWarning

func (r *DeleteResourceResponse) AddAttributeWarning(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeWarning appends a warning diagnostic to the response and labels it with a specific attribute.

func (*DeleteResourceResponse) AddError

func (r *DeleteResourceResponse) AddError(summary, detail string)

AddError appends an error diagnostic to the response. If the error concerns a particular attribute, AddAttributeError should be used instead.

func (*DeleteResourceResponse) AddWarning

func (r *DeleteResourceResponse) AddWarning(summary, detail string)

AddWarning appends a warning diagnostic to the response. If the warning concerns a particular attribute, AddAttributeWarning should be used instead.

type ImportResourceStateRequest added in v0.4.0

type ImportResourceStateRequest struct {
	// ID represents the import identifier supplied by the practitioner when
	// calling the import command. In many cases, this may align with the
	// unique identifier for the resource, which can optionally be stored
	// as an Attribute. However, this identifier can also be treated as
	// its own type of value and parsed during import. This value
	// is not stored in the state unless the provider explicitly stores it.
	ID string
}

ImportResourceStateRequest represents a request for the provider to import a resource. An instance of this request struct is supplied as an argument to the Resource's ImportState method.

type ImportResourceStateResponse added in v0.4.0

type ImportResourceStateResponse struct {
	// Diagnostics report errors or warnings related to importing the
	// resource. An empty slice indicates a successful operation with no
	// warnings or errors generated.
	Diagnostics diag.Diagnostics

	// State is the state of the resource following the import operation.
	// It must contain enough information so Terraform can successfully
	// refresh the resource, e.g. call the Resource Read method.
	State State
}

ImportResourceStateResponse represents a response to a ImportResourceStateRequest. An instance of this response struct is supplied as an argument to the Resource's ImportState method, in which the provider should set values on the ImportResourceStateResponse as appropriate.

type ListNestedAttributesOptions added in v0.3.0

type ListNestedAttributesOptions struct {
	MinItems int
	MaxItems int
}

ListNestedAttributesOptions captures additional, optional parameters for ListNestedAttributes.

type MapNestedAttributesOptions added in v0.3.0

type MapNestedAttributesOptions struct {
	MinItems int
	MaxItems int
}

MapNestedAttributesOptions captures additional, optional parameters for MapNestedAttributes.

type ModifyAttributePlanRequest added in v0.3.0

type ModifyAttributePlanRequest struct {
	// AttributePath is the path of the attribute.
	AttributePath *tftypes.AttributePath

	// Config is the configuration the user supplied for the resource.
	Config Config

	// State is the current state of the resource.
	State State

	// Plan is the planned new state for the resource.
	Plan Plan

	// AttributeConfig is the configuration the user supplied for the attribute.
	AttributeConfig attr.Value

	// AttributeState is the current state of the attribute.
	AttributeState attr.Value

	// AttributePlan is the planned new state for the attribute.
	AttributePlan attr.Value

	// ProviderMeta is metadata from the provider_meta block of the module.
	ProviderMeta Config
}

ModifyAttributePlanRequest represents a request for the provider to modify an attribute value, or mark it as requiring replacement, at plan time. An instance of this request struct is supplied as an argument to the Modify function of an attribute's plan modifier(s).

type ModifyAttributePlanResponse added in v0.3.0

type ModifyAttributePlanResponse struct {
	// AttributePlan is the planned new state for the attribute.
	AttributePlan attr.Value

	// RequiresReplace indicates whether a change in the attribute
	// requires replacement of the whole resource.
	RequiresReplace bool

	// Diagnostics report errors or warnings related to determining the
	// planned state of the requested resource. Returning an empty slice
	// indicates a successful validation with no warnings or errors
	// generated.
	Diagnostics diag.Diagnostics
}

ModifyAttributePlanResponse represents a response to a ModifyAttributePlanRequest. An instance of this response struct is supplied as an argument to the Modify function of an attribute's plan modifier(s).

func (*ModifyAttributePlanResponse) AddAttributeError added in v0.3.0

func (r *ModifyAttributePlanResponse) AddAttributeError(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeError appends an error diagnostic to the response and labels it with a specific attribute.

func (*ModifyAttributePlanResponse) AddAttributeWarning added in v0.3.0

func (r *ModifyAttributePlanResponse) AddAttributeWarning(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeWarning appends a warning diagnostic to the response and labels it with a specific attribute.

func (*ModifyAttributePlanResponse) AddError added in v0.3.0

func (r *ModifyAttributePlanResponse) AddError(summary, detail string)

AddError appends an error diagnostic to the response. If the error concerns a particular attribute, AddAttributeError should be used instead.

func (*ModifyAttributePlanResponse) AddWarning added in v0.3.0

func (r *ModifyAttributePlanResponse) AddWarning(summary, detail string)

AddWarning appends a warning diagnostic to the response. If the warning concerns a particular attribute, AddAttributeWarning should be used instead.

type ModifyResourcePlanRequest added in v0.3.0

type ModifyResourcePlanRequest struct {
	// Config is the configuration the user supplied for the resource.
	//
	// This configuration may contain unknown values if a user uses
	// interpolation or other functionality that would prevent Terraform
	// from knowing the value at request time.
	Config Config

	// State is the current state of the resource.
	State State

	// Plan is the planned new state for the resource.
	Plan Plan

	// ProviderMeta is metadata from the provider_meta block of the module.
	ProviderMeta Config
}

ModifyResourcePlanRequest represents a request for the provider to modify the planned new state that Terraform has generated for the resource.

type ModifyResourcePlanResponse added in v0.3.0

type ModifyResourcePlanResponse struct {
	// Plan is the planned new state for the resource.
	Plan Plan

	// RequiresReplace is a list of tftypes.AttributePaths that require the
	// resource to be replaced. They should point to the specific field
	// that changed that requires the resource to be destroyed and
	// recreated.
	RequiresReplace []*tftypes.AttributePath

	// Diagnostics report errors or warnings related to determining the
	// planned state of the requested resource. Returning an empty slice
	// indicates a successful plan modification with no warnings or errors
	// generated.
	Diagnostics diag.Diagnostics
}

ModifyResourcePlanResponse represents a response to a ModifyResourcePlanRequest. An instance of this response struct is supplied as an argument to the resource's ModifyPlan function, in which the provider should modify the Plan and populate the RequiresReplace field as appropriate.

func (*ModifyResourcePlanResponse) AddAttributeError added in v0.3.0

func (r *ModifyResourcePlanResponse) AddAttributeError(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeError appends an error diagnostic to the response and labels it with a specific attribute.

func (*ModifyResourcePlanResponse) AddAttributeWarning added in v0.3.0

func (r *ModifyResourcePlanResponse) AddAttributeWarning(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeWarning appends a warning diagnostic to the response and labels it with a specific attribute.

func (*ModifyResourcePlanResponse) AddError added in v0.3.0

func (r *ModifyResourcePlanResponse) AddError(summary, detail string)

AddError appends an error diagnostic to the response. If the error concerns a particular attribute, AddAttributeError should be used instead.

func (*ModifyResourcePlanResponse) AddWarning added in v0.3.0

func (r *ModifyResourcePlanResponse) AddWarning(summary, detail string)

AddWarning appends a warning diagnostic to the response. If the warning concerns a particular attribute, AddAttributeWarning should be used instead.

type ModifySchemaPlanRequest added in v0.3.0

type ModifySchemaPlanRequest struct {
	// Config is the configuration the user supplied for the resource.
	Config Config

	// State is the current state of the resource.
	State State

	// Plan is the planned new state for the resource.
	Plan Plan

	// ProviderMeta is metadata from the provider_meta block of the module.
	ProviderMeta Config
}

ModifySchemaPlanRequest represents a request for a schema to run all attribute plan modification functions.

type ModifySchemaPlanResponse added in v0.3.0

type ModifySchemaPlanResponse struct {
	// Plan is the planned new state for the resource.
	Plan Plan

	// RequiresReplace is a list of tftypes.AttributePaths that require the
	// resource to be replaced. They should point to the specific field
	// that changed that requires the resource to be destroyed and
	// recreated.
	RequiresReplace []*tftypes.AttributePath

	// Diagnostics report errors or warnings related to running all attribute
	// plan modifiers. Returning an empty slice indicates a successful
	// plan modification with no warnings or errors generated.
	Diagnostics diag.Diagnostics
}

ModifySchemaPlanResponse represents a response to a ModifySchemaPlanRequest.

type NestedAttributes added in v0.3.0

type NestedAttributes interface {
	tftypes.AttributePathStepper
	AttributeType() attr.Type
	GetNestingMode() NestingMode
	GetAttributes() map[string]Attribute
	GetMinItems() int64
	GetMaxItems() int64
	Equal(NestedAttributes) bool
	// contains filtered or unexported methods
}

NestedAttributes surfaces a group of attributes to nest beneath another attribute, and how that nesting should behave. Nesting can have the following modes:

* SingleNestedAttributes are nested attributes that represent a struct or object; there should only be one instance of them nested beneath that specific attribute.

* ListNestedAttributes are nested attributes that represent a list of structs or objects; there can be multiple instances of them beneath that specific attribute.

* SetNestedAttributes are nested attributes that represent a set of structs or objects; there can be multiple instances of them beneath that specific attribute. Unlike ListNestedAttributes, these nested attributes must have unique values.

* MapNestedAttributes are nested attributes that represent a string-indexed map of structs or objects; there can be multiple instances of them beneath that specific attribute. Unlike ListNestedAttributes, these nested attributes must be associated with a unique key. Unlike SetNestedAttributes, the key must be explicitly set by the user.

func ListNestedAttributes added in v0.3.0

func ListNestedAttributes(attributes map[string]Attribute, opts ListNestedAttributesOptions) NestedAttributes

ListNestedAttributes nests `attributes` under another attribute, allowing multiple instances of that group of attributes to appear in the configuration. Minimum and maximum numbers of times the group can appear in the configuration can be set using `opts`.

func MapNestedAttributes added in v0.3.0

func MapNestedAttributes(attributes map[string]Attribute, opts MapNestedAttributesOptions) NestedAttributes

MapNestedAttributes nests `attributes` under another attribute, allowing multiple instances of that group of attributes to appear in the configuration. Each group will need to be associated with a unique string by the user. Minimum and maximum numbers of times the group can appear in the configuration can be set using `opts`.

func SetNestedAttributes added in v0.3.0

func SetNestedAttributes(attributes map[string]Attribute, opts SetNestedAttributesOptions) NestedAttributes

SetNestedAttributes nests `attributes` under another attribute, allowing multiple instances of that group of attributes to appear in the configuration, while requiring each group of values be unique. Minimum and maximum numbers of times the group can appear in the configuration can be set using `opts`.

func SingleNestedAttributes added in v0.3.0

func SingleNestedAttributes(attributes map[string]Attribute) NestedAttributes

SingleNestedAttributes nests `attributes` under another attribute, only allowing one instance of that group of attributes to appear in the configuration.

type NestingMode added in v0.3.0

type NestingMode uint8

NestingMode is an enum type of the ways nested attributes can be nested. They can be a list, a set, or a map (with string keys), or they can be nested directly, like an object.

const (
	// NestingModeUnknown is an invalid nesting mode, used to catch when a
	// nesting mode is expected and not set.
	NestingModeUnknown NestingMode = 0

	// NestingModeSingle is for attributes that represent a struct or
	// object, a single instance of those attributes directly nested under
	// another attribute.
	NestingModeSingle NestingMode = 1

	// NestingModeList is for attributes that represent a list of objects,
	// with multiple instances of those attributes nested inside a list
	// under another attribute.
	NestingModeList NestingMode = 2

	// NestingModeSet is for attributes that represent a set of objects,
	// with multiple, unique instances of those attributes nested inside a
	// set under another attribute.
	NestingModeSet NestingMode = 3

	// NestingModeMap is for attributes that represent a map of objects,
	// with multiple instances of those attributes, each associated with a
	// unique string key, nested inside a map under another attribute.
	NestingModeMap NestingMode = 4
)

type Plan

type Plan struct {
	Raw    tftypes.Value
	Schema Schema
}

Plan represents a Terraform plan.

func (Plan) Get

func (p Plan) Get(ctx context.Context, target interface{}) diag.Diagnostics

Get populates the struct passed as `target` with the entire plan.

func (Plan) GetAttribute

func (p Plan) GetAttribute(ctx context.Context, path *tftypes.AttributePath) (attr.Value, diag.Diagnostics)

GetAttribute retrieves the attribute found at `path` and returns it as an attr.Value. Consumers should assert the type of the returned value with the desired attr.Type.

func (*Plan) Set

func (p *Plan) Set(ctx context.Context, val interface{}) diag.Diagnostics

Set populates the entire plan using the supplied Go value. The value `val` should be a struct whose values have one of the attr.Value types. Each field must be tagged with the corresponding schema field.

func (*Plan) SetAttribute

func (p *Plan) SetAttribute(ctx context.Context, path *tftypes.AttributePath, val interface{}) diag.Diagnostics

SetAttribute sets the attribute at `path` using the supplied Go value.

The attribute path and value must be valid with the current schema. If the attribute path already has a value, it will be overwritten. If the attribute path does not have a value, it will be added, including any parent attribute paths as necessary.

Lists can only have the next element added according to the current length.

type Provider

type Provider interface {
	// GetSchema returns the schema for this provider's configuration. If
	// this provider has no configuration, return an empty schema.Schema.
	GetSchema(context.Context) (Schema, diag.Diagnostics)

	// Configure is called at the beginning of the provider lifecycle, when
	// Terraform sends to the provider the values the user specified in the
	// provider configuration block. These are supplied in the
	// ConfigureProviderRequest argument.
	// Values from provider configuration are often used to initialise an
	// API client, which should be stored on the struct implementing the
	// Provider interface.
	Configure(context.Context, ConfigureProviderRequest, *ConfigureProviderResponse)

	// GetResources returns a map of the resource types this provider
	// supports.
	GetResources(context.Context) (map[string]ResourceType, diag.Diagnostics)

	// GetDataSources returns a map of the data source types this provider
	// supports.
	GetDataSources(context.Context) (map[string]DataSourceType, diag.Diagnostics)
}

Provider is the core interface that all Terraform providers must implement.

type ProviderConfigValidator added in v0.3.0

type ProviderConfigValidator interface {
	// Description describes the validation in plain text formatting.
	//
	// This information may be automatically added to provider plain text
	// descriptions by external tooling.
	Description(context.Context) string

	// MarkdownDescription describes the validation in Markdown formatting.
	//
	// This information may be automatically added to provider Markdown
	// descriptions by external tooling.
	MarkdownDescription(context.Context) string

	// Validate performs the validation.
	Validate(context.Context, ValidateProviderConfigRequest, *ValidateProviderConfigResponse)
}

ProviderConfigValidator describes reusable Provider configuration validation functionality.

type ProviderWithConfigValidators added in v0.3.0

type ProviderWithConfigValidators interface {
	Provider

	// ConfigValidators returns a list of functions which will all be performed during validation.
	ConfigValidators(context.Context) []ProviderConfigValidator
}

ProviderWithConfigValidators is an interface type that extends Provider to include declarative validations.

Declaring validation using this methodology simplifies implementation of reusable functionality. These also include descriptions, which can be used for automating documentation.

Validation will include ConfigValidators and ValidateConfig, if both are implemented, in addition to any Attribute or Type validation.

type ProviderWithProviderMeta

type ProviderWithProviderMeta interface {
	Provider
	// GetMetaSchema returns the provider meta schema.
	GetMetaSchema(context.Context) (Schema, diag.Diagnostics)
}

ProviderWithProviderMeta is a provider with a provider meta schema. This functionality is currently experimental and subject to change or break without warning; it should only be used by providers that are collaborating on its use with the Terraform team.

type ProviderWithValidateConfig added in v0.3.0

type ProviderWithValidateConfig interface {
	Provider

	// ValidateConfig performs the validation.
	ValidateConfig(context.Context, ValidateProviderConfigRequest, *ValidateProviderConfigResponse)
}

ProviderWithValidateConfig is an interface type that extends Provider to include imperative validation.

Declaring validation using this methodology simplifies one-off functionality that typically applies to a single provider. Any documentation of this functionality must be manually added into schema descriptions.

Validation will include ConfigValidators and ValidateConfig, if both are implemented, in addition to any Attribute or Type validation.

type ReadDataSourceRequest

type ReadDataSourceRequest struct {
	// Config is the configuration the user supplied for the data source.
	//
	// This configuration may contain unknown values if a user uses
	// interpolation or other functionality that would prevent Terraform
	// from knowing the value at request time.
	Config Config

	// ProviderMeta is metadata from the provider_meta block of the module.
	ProviderMeta Config
}

ReadDataSourceRequest represents a request for the provider to read a data source, i.e., update values in state according to the real state of the data source. An instance of this request struct is supplied as an argument to the data source's Read function.

type ReadDataSourceResponse

type ReadDataSourceResponse struct {
	// State is the state of the data source following the Read operation.
	// This field should be set during the resource's Read operation.
	State State

	// Diagnostics report errors or warnings related to reading the data
	// source. An empty slice indicates a successful operation with no
	// warnings or errors generated.
	Diagnostics diag.Diagnostics
}

ReadDataSourceResponse represents a response to a ReadDataSourceRequest. An instance of this response struct is supplied as an argument to the data source's Read function, in which the provider should set values on the ReadDataSourceResponse as appropriate.

func (*ReadDataSourceResponse) AddAttributeError added in v0.3.0

func (r *ReadDataSourceResponse) AddAttributeError(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeError appends an error diagnostic to the response and labels it with a specific attribute.

func (*ReadDataSourceResponse) AddAttributeWarning added in v0.3.0

func (r *ReadDataSourceResponse) AddAttributeWarning(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeWarning appends a warning diagnostic to the response and labels it with a specific attribute.

func (*ReadDataSourceResponse) AddError added in v0.3.0

func (r *ReadDataSourceResponse) AddError(summary, detail string)

AddError appends an error diagnostic to the response. If the error concerns a particular attribute, AddAttributeError should be used instead.

func (*ReadDataSourceResponse) AddWarning added in v0.3.0

func (r *ReadDataSourceResponse) AddWarning(summary, detail string)

AddWarning appends a warning diagnostic to the response. If the warning concerns a particular attribute, AddAttributeWarning should be used instead.

type ReadResourceRequest

type ReadResourceRequest struct {
	// State is the current state of the resource prior to the Read
	// operation.
	State State

	// ProviderMeta is metadata from the provider_meta block of the module.
	ProviderMeta Config
}

ReadResourceRequest represents a request for the provider to read a resource, i.e., update values in state according to the real state of the resource. An instance of this request struct is supplied as an argument to the resource's Read function.

type ReadResourceResponse

type ReadResourceResponse struct {
	// State is the state of the resource following the Read operation.
	// This field is pre-populated from ReadResourceRequest.State and
	// should be set during the resource's Read operation.
	State State

	// Diagnostics report errors or warnings related to reading the
	// resource. An empty slice indicates a successful operation with no
	// warnings or errors generated.
	Diagnostics diag.Diagnostics
}

ReadResourceResponse represents a response to a ReadResourceRequest. An instance of this response struct is supplied as an argument to the resource's Read function, in which the provider should set values on the ReadResourceResponse as appropriate.

func (*ReadResourceResponse) AddAttributeError

func (r *ReadResourceResponse) AddAttributeError(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeError appends an error diagnostic to the response and labels it with a specific attribute.

func (*ReadResourceResponse) AddAttributeWarning

func (r *ReadResourceResponse) AddAttributeWarning(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeWarning appends a warning diagnostic to the response and labels it with a specific attribute.

func (*ReadResourceResponse) AddError

func (r *ReadResourceResponse) AddError(summary, detail string)

AddError appends an error diagnostic to the response. If the error concerns a particular attribute, AddAttributeError should be used instead.

func (*ReadResourceResponse) AddWarning

func (r *ReadResourceResponse) AddWarning(summary, detail string)

AddWarning appends a warning diagnostic to the response. If the warning concerns a particular attribute, AddAttributeWarning should be used instead.

type RequiresReplaceIfFunc added in v0.3.0

type RequiresReplaceIfFunc func(ctx context.Context, state, config attr.Value, path *tftypes.AttributePath) (bool, diag.Diagnostics)

RequiresReplaceIfFunc is a conditional function used in the RequiresReplaceIf plan modifier to determine whether the attribute requires replacement.

type RequiresReplaceIfModifier added in v0.3.0

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

RequiresReplaceIfModifier is an AttributePlanModifier that sets RequiresReplace on the attribute if the conditional function returns true.

func (RequiresReplaceIfModifier) Description added in v0.3.0

func (r RequiresReplaceIfModifier) Description(ctx context.Context) string

Description returns a human-readable description of the plan modifier.

func (RequiresReplaceIfModifier) MarkdownDescription added in v0.3.0

func (r RequiresReplaceIfModifier) MarkdownDescription(ctx context.Context) string

MarkdownDescription returns a markdown description of the plan modifier.

func (RequiresReplaceIfModifier) Modify added in v0.3.0

Modify sets RequiresReplace on the response to true if the conditional RequiresReplaceIfFunc returns true.

type RequiresReplaceModifier added in v0.3.0

type RequiresReplaceModifier struct{}

RequiresReplaceModifier is an AttributePlanModifier that sets RequiresReplace on the attribute.

func (RequiresReplaceModifier) Description added in v0.3.0

func (r RequiresReplaceModifier) Description(ctx context.Context) string

Description returns a human-readable description of the plan modifier.

func (RequiresReplaceModifier) MarkdownDescription added in v0.3.0

func (r RequiresReplaceModifier) MarkdownDescription(ctx context.Context) string

MarkdownDescription returns a markdown description of the plan modifier.

func (RequiresReplaceModifier) Modify added in v0.3.0

Modify sets RequiresReplace on the response to true.

type Resource

type Resource interface {
	// Create is called when the provider must create a new resource. Config
	// and planned state values should be read from the
	// CreateResourceRequest and new state values set on the
	// CreateResourceResponse.
	Create(context.Context, CreateResourceRequest, *CreateResourceResponse)

	// Read is called when the provider must read resource values in order
	// to update state. Planned state values should be read from the
	// ReadResourceRequest and new state values set on the
	// ReadResourceResponse.
	Read(context.Context, ReadResourceRequest, *ReadResourceResponse)

	// Update is called to update the state of the resource. Config, planned
	// state, and prior state values should be read from the
	// UpdateResourceRequest and new state values set on the
	// UpdateResourceResponse.
	Update(context.Context, UpdateResourceRequest, *UpdateResourceResponse)

	// Delete is called when the provider must delete the resource. Config
	// values may be read from the DeleteResourceRequest.
	Delete(context.Context, DeleteResourceRequest, *DeleteResourceResponse)

	// ImportState is called when the provider must import the resource.
	//
	// If import is not supported, it is recommended to use the
	// ResourceImportStateNotImplemented() call in this method.
	//
	// If setting an attribute with the import identifier, it is recommended
	// to use the ResourceImportStatePassthroughID() call in this method.
	ImportState(context.Context, ImportResourceStateRequest, *ImportResourceStateResponse)
}

Resource represents a resource instance. This is the core interface that all resources must implement.

type ResourceConfigValidator added in v0.3.0

type ResourceConfigValidator interface {
	// Description describes the validation in plain text formatting.
	//
	// This information may be automatically added to resource plain text
	// descriptions by external tooling.
	Description(context.Context) string

	// MarkdownDescription describes the validation in Markdown formatting.
	//
	// This information may be automatically added to resource Markdown
	// descriptions by external tooling.
	MarkdownDescription(context.Context) string

	// Validate performs the validation.
	Validate(context.Context, ValidateResourceConfigRequest, *ValidateResourceConfigResponse)
}

ResourceConfigValidator describes reusable Resource configuration validation functionality.

type ResourceType

type ResourceType interface {
	// GetSchema returns the schema for this resource.
	GetSchema(context.Context) (Schema, diag.Diagnostics)

	// NewResource instantiates a new Resource of this ResourceType.
	NewResource(context.Context, Provider) (Resource, diag.Diagnostics)
}

A ResourceType is a type of resource. For each type of resource this provider supports, it should define a type implementing ResourceType and return an instance of it in the map returned by Provider.GetResources.

type ResourceWithConfigValidators added in v0.3.0

type ResourceWithConfigValidators interface {
	Resource

	// ConfigValidators returns a list of functions which will all be performed during validation.
	ConfigValidators(context.Context) []ResourceConfigValidator
}

ResourceWithConfigValidators is an interface type that extends Resource to include declarative validations.

Declaring validation using this methodology simplifies implmentation of reusable functionality. These also include descriptions, which can be used for automating documentation.

Validation will include ConfigValidators and ValidateConfig, if both are implemented, in addition to any Attribute or Type validation.

type ResourceWithModifyPlan added in v0.3.0

type ResourceWithModifyPlan interface {
	Resource

	// ModifyPlan is called when the provider has an opportunity to modify
	// the plan: once during the plan phase when Terraform is determining
	// the diff that should be shown to the user for approval, and once
	// during the apply phase with any unknown values from configuration
	// filled in with their final values.
	//
	// The planned new state is represented by
	// ModifyResourcePlanResponse.Plan. It must meet the following
	// constraints:
	// 1. Any non-Computed attribute set in config must preserve the exact
	// config value or return the corresponding attribute value from the
	// prior state (ModifyResourcePlanRequest.State).
	// 2. Any attribute with a known value must not have its value changed
	// in subsequent calls to ModifyPlan or Create/Read/Update.
	// 3. Any attribute with an unknown value may either remain unknown
	// or take on any value of the expected type.
	//
	// Any errors will prevent further resource-level plan modifications.
	ModifyPlan(context.Context, ModifyResourcePlanRequest, *ModifyResourcePlanResponse)
}

ResourceWithModifyPlan represents a resource instance with a ModifyPlan function.

type ResourceWithValidateConfig added in v0.3.0

type ResourceWithValidateConfig interface {
	Resource

	// ValidateConfig performs the validation.
	ValidateConfig(context.Context, ValidateResourceConfigRequest, *ValidateResourceConfigResponse)
}

ResourceWithValidateConfig is an interface type that extends Resource to include imperative validation.

Declaring validation using this methodology simplifies one-off functionality that typically applies to a single resource. Any documentation of this functionality must be manually added into schema descriptions.

Validation will include ConfigValidators and ValidateConfig, if both are implemented, in addition to any Attribute or Type validation.

type Schema added in v0.3.0

type Schema struct {
	// Attributes are the fields inside the resource, provider, or data
	// source that the schema is defining. The map key should be the name
	// of the attribute, and the body defines how it behaves. Names must
	// only contain lowercase letters, numbers, and underscores.
	Attributes map[string]Attribute

	// Version indicates the current version of the schema. Schemas are
	// versioned to help with automatic upgrade process. This is not
	// typically required unless there is a change in the schema, such as
	// changing an attribute type, that needs manual upgrade handling.
	// Versions should only be incremented by one each release.
	Version int64

	DeprecationMessage  string
	Description         string
	MarkdownDescription string
}

Schema is used to define the shape of practitioner-provider information, like resources, data sources, and providers. Think of it as a type definition, but for Terraform.

func (Schema) ApplyTerraform5AttributePathStep added in v0.3.0

func (s Schema) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)

ApplyTerraform5AttributePathStep applies the given AttributePathStep to the schema.

func (Schema) AttributeAtPath added in v0.3.0

func (s Schema) AttributeAtPath(path *tftypes.AttributePath) (Attribute, error)

AttributeAtPath returns the Attribute at the passed path. If the path points to an element or attribute of a complex type, rather than to an Attribute, it will return an ErrPathInsideAtomicAttribute error.

func (Schema) AttributeType added in v0.3.0

func (s Schema) AttributeType() attr.Type

AttributeType returns a types.ObjectType composed from the schema types.

func (Schema) AttributeTypeAtPath added in v0.3.0

func (s Schema) AttributeTypeAtPath(path *tftypes.AttributePath) (attr.Type, error)

AttributeTypeAtPath returns the attr.Type of the attribute at the given path.

func (Schema) TerraformType added in v0.3.0

func (s Schema) TerraformType(ctx context.Context) tftypes.Type

TerraformType returns a tftypes.Type that can represent the schema.

type ServeOpts

type ServeOpts struct {
	// Name is the name of the provider, in full address form. For example:
	// registry.terraform.io/hashicorp/random.
	Name string
}

ServeOpts are options for serving the provider.

type SetNestedAttributesOptions added in v0.3.0

type SetNestedAttributesOptions struct {
	MinItems int
	MaxItems int
}

SetNestedAttributesOptions captures additional, optional parameters for SetNestedAttributes.

type State

type State struct {
	Raw    tftypes.Value
	Schema Schema
}

State represents a Terraform state.

func (State) Get

func (s State) Get(ctx context.Context, target interface{}) diag.Diagnostics

Get populates the struct passed as `target` with the entire state.

func (State) GetAttribute

func (s State) GetAttribute(ctx context.Context, path *tftypes.AttributePath) (attr.Value, diag.Diagnostics)

GetAttribute retrieves the attribute found at `path` and returns it as an attr.Value. Consumers should assert the type of the returned value with the desired attr.Type.

func (*State) RemoveResource

func (s *State) RemoveResource(ctx context.Context)

RemoveResource removes the entire resource from state.

func (*State) Set

func (s *State) Set(ctx context.Context, val interface{}) diag.Diagnostics

Set populates the entire state using the supplied Go value. The value `val` should be a struct whose values have one of the attr.Value types. Each field must be tagged with the corresponding schema field.

func (*State) SetAttribute

func (s *State) SetAttribute(ctx context.Context, path *tftypes.AttributePath, val interface{}) diag.Diagnostics

SetAttribute sets the attribute at `path` using the supplied Go value.

The attribute path and value must be valid with the current schema. If the attribute path already has a value, it will be overwritten. If the attribute path does not have a value, it will be added, including any parent attribute paths as necessary.

Lists can only have the next element added according to the current length.

type UpdateResourceRequest

type UpdateResourceRequest struct {
	// Config is the configuration the user supplied for the resource.
	//
	// This configuration may contain unknown values if a user uses
	// interpolation or other functionality that would prevent Terraform
	// from knowing the value at request time.
	Config Config

	// Plan is the planned state for the resource.
	Plan Plan

	// State is the current state of the resource prior to the Update
	// operation.
	State State

	// ProviderMeta is metadata from the provider_meta block of the module.
	ProviderMeta Config
}

UpdateResourceRequest represents a request for the provider to update a resource. An instance of this request struct is supplied as an argument to the resource's Update function.

type UpdateResourceResponse

type UpdateResourceResponse struct {
	// State is the state of the resource following the Update operation.
	// This field is pre-populated from UpdateResourceRequest.Plan and
	// should be set during the resource's Update operation.
	State State

	// Diagnostics report errors or warnings related to updating the
	// resource. An empty slice indicates a successful operation with no
	// warnings or errors generated.
	Diagnostics diag.Diagnostics
}

UpdateResourceResponse represents a response to an UpdateResourceRequest. An instance of this response struct is supplied as an argument to the resource's Update function, in which the provider should set values on the UpdateResourceResponse as appropriate.

func (*UpdateResourceResponse) AddAttributeError

func (r *UpdateResourceResponse) AddAttributeError(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeError appends an error diagnostic to the response and labels it with a specific attribute.

func (*UpdateResourceResponse) AddAttributeWarning

func (r *UpdateResourceResponse) AddAttributeWarning(attributePath *tftypes.AttributePath, summary, detail string)

AddAttributeWarning appends a warning diagnostic to the response and labels it with a specific attribute.

func (*UpdateResourceResponse) AddError

func (r *UpdateResourceResponse) AddError(summary, detail string)

AddError appends an error diagnostic to the response. If the error concerns a particular attribute, AddAttributeError should be used instead.

func (*UpdateResourceResponse) AddWarning

func (r *UpdateResourceResponse) AddWarning(summary, detail string)

AddWarning appends a warning diagnostic to the response. If the warning concerns a particular attribute, AddAttributeWarning should be used instead.

type ValidateAttributeRequest added in v0.3.0

type ValidateAttributeRequest struct {
	// AttributePath contains the path of the attribute.
	AttributePath *tftypes.AttributePath

	// AttributeConfig contains the value of the attribute in the configuration.
	AttributeConfig attr.Value

	// Config contains the entire configuration of the data source, provider, or resource.
	Config Config
}

ValidateAttributeRequest repesents a request for

type ValidateAttributeResponse added in v0.3.0

type ValidateAttributeResponse struct {
	// Diagnostics report errors or warnings related to validating the data
	// source configuration. An empty slice indicates success, with no warnings
	// or errors generated.
	Diagnostics diag.Diagnostics
}

ValidateAttributeResponse represents a response to a ValidateAttributeRequest. An instance of this response struct is automatically passed through to each AttributeValidator.

type ValidateDataSourceConfigRequest added in v0.3.0

type ValidateDataSourceConfigRequest struct {
	// Config is the configuration the user supplied for the data source.
	//
	// This configuration may contain unknown values if a user uses
	// interpolation or other functionality that would prevent Terraform
	// from knowing the value at request time.
	Config Config
}

ValidateDataSourceConfigRequest represents a request to validate the configuration of a data source. An instance of this request struct is supplied as an argument to the DataSource ValidateConfig receiver method or automatically passed through to each ConfigValidator.

type ValidateDataSourceConfigResponse added in v0.3.0

type ValidateDataSourceConfigResponse struct {
	// Diagnostics report errors or warnings related to validating the data
	// source configuration. An empty slice indicates success, with no warnings
	// or errors generated.
	Diagnostics diag.Diagnostics
}

ValidateDataSourceConfigResponse represents a response to a ValidateDataSourceConfigRequest. An instance of this response struct is supplied as an argument to the DataSource ValidateConfig receiver method or automatically passed through to each ConfigValidator.

type ValidateProviderConfigRequest added in v0.3.0

type ValidateProviderConfigRequest struct {
	// Config is the configuration the user supplied for the provider.
	//
	// This configuration may contain unknown values if a user uses
	// interpolation or other functionality that would prevent Terraform
	// from knowing the value at request time.
	Config Config
}

ValidateProviderConfigRequest represents a request to validate the configuration of a provider. An instance of this request struct is supplied as an argument to the Provider ValidateConfig receiver method or automatically passed through to each ConfigValidator.

type ValidateProviderConfigResponse added in v0.3.0

type ValidateProviderConfigResponse struct {
	// Diagnostics report errors or warnings related to validating the provider
	// configuration. An empty slice indicates success, with no warnings or
	// errors generated.
	Diagnostics diag.Diagnostics
}

ValidateProviderConfigResponse represents a response to a ValidateProviderConfigRequest. An instance of this response struct is supplied as an argument to the Provider ValidateConfig receiver method or automatically passed through to each ConfigValidator.

type ValidateResourceConfigRequest added in v0.3.0

type ValidateResourceConfigRequest struct {
	// Config is the configuration the user supplied for the resource.
	//
	// This configuration may contain unknown values if a user uses
	// interpolation or other functionality that would prevent Terraform
	// from knowing the value at request time.
	Config Config
}

ValidateResourceConfigRequest represents a request to validate the configuration of a resource. An instance of this request struct is supplied as an argument to the Resource ValidateConfig receiver method or automatically passed through to each ConfigValidator.

type ValidateResourceConfigResponse added in v0.3.0

type ValidateResourceConfigResponse struct {
	// Diagnostics report errors or warnings related to validating the resource
	// configuration. An empty slice indicates success, with no warnings or
	// errors generated.
	Diagnostics diag.Diagnostics
}

ValidateResourceConfigResponse represents a response to a ValidateResourceConfigRequest. An instance of this response struct is supplied as an argument to the Resource ValidateConfig receiver method or automatically passed through to each ConfigValidator.

type ValidateSchemaRequest added in v0.3.0

type ValidateSchemaRequest struct {
	// Config contains the entire configuration of the data source, provider, or resource.
	//
	// This configuration may contain unknown values if a user uses
	// interpolation or other functionality that would prevent Terraform
	// from knowing the value at request time.
	Config Config
}

ValidateSchemaRequest repesents a request for validating a Schema.

type ValidateSchemaResponse added in v0.3.0

type ValidateSchemaResponse struct {
	// Diagnostics report errors or warnings related to validating the schema.
	// An empty slice indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics
}

ValidateSchemaResponse represents a response to a ValidateSchemaRequest.

Jump to

Keyboard shortcuts

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