planmodifier

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MPL-2.0 Imports: 6 Imported by: 331

Documentation

Overview

Package planmodifier contains schema plan modifier interfaces and request/response implementations. These plan modifier interfaces are used by resource/schema and internally in the framework. Refer to the typed plan modifier packages, such as stringplanmodifier, for framework-defined plan modifiers that can be used in provider-defined schemas.

Each attr.Type has a corresponding {TYPE} interface which implements concretely typed PlanModify{TYPE} methods, such as StringPlanModifier and PlanModifyString.

The framework has to choose between plan modifier developers handling a concrete framework value type, such as types.Bool, or the framework interface for custom value basetypes, such as basetypes.BoolValuable.

In the framework type model, the developer can immediately use the value. If the value was associated with a custom type and using the custom value type is desired, the developer must use the type's ValueFrom{TYPE} method.

In the custom type model, the developer must always convert to a concrete type before using the value unless checking for null or unknown. Since any custom type may be passed due to the schema, it is possible, if not likely, that unknown concrete types will be passed to the plan modifier.

The framework chooses to pass the framework value type. This prevents the potential for unexpected runtime panics and simplifies development for easier use cases where the framework type is sufficient. More advanced developers can choose to call the type's ValueFrom{TYPE} method to get the desired custom type in a plan modifier.

PlanModifers that are not type dependent need to implement all interfaces, but can use shared logic to reduce implementation code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool interface {
	Describer

	// PlanModifyBool should perform the modification.
	PlanModifyBool(context.Context, BoolRequest, *BoolResponse)
}

Bool is a schema plan modifier for types.Bool attributes.

type BoolRequest

type BoolRequest struct {
	// Path contains the path of the attribute for modification. Use this path
	// for any response diagnostics.
	Path path.Path

	// PathExpression contains the expression matching the exact path
	// of the attribute for modification.
	PathExpression path.Expression

	// Config contains the entire configuration of the resource.
	Config tfsdk.Config

	// ConfigValue contains the value of the attribute for modification from the configuration.
	ConfigValue types.Bool

	// Plan contains the entire proposed new state of the resource.
	Plan tfsdk.Plan

	// PlanValue contains the value of the attribute for modification from the proposed new state.
	PlanValue types.Bool

	// State contains the entire prior state of the resource.
	State tfsdk.State

	// StateValue contains the value of the attribute for modification from the prior state.
	StateValue types.Bool

	// Private is provider-defined resource private state data which was previously
	// stored with the resource state. This data is opaque to Terraform and does
	// not affect plan output. Any existing data is copied to
	// BoolResponse.Private to prevent accidental private state data loss.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	//
	// Use the GetKey method to read data. Use the SetKey method on
	// BoolResponse.Private to update or remove a value.
	Private *privatestate.ProviderData
}

BoolRequest is a request for types.Bool schema plan modification.

type BoolResponse

type BoolResponse struct {
	// PlanValue is the planned new state for the attribute.
	PlanValue types.Bool

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

	// Private is the private state resource data following the PlanModifyBool operation.
	// This field is pre-populated from BoolRequest.Private and
	// can be modified during the resource's PlanModifyBool operation.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	Private *privatestate.ProviderData

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

BoolResponse is a response to a BoolRequest.

type Describer

type Describer interface {
	// Description should describe the plan modifier in plain text formatting.
	// This information is used by provider logging and provider tooling such
	// as documentation generation.
	//
	// The description should:
	//  - Begin with a lowercase or other character suitable for the middle of
	//    a sentence.
	//  - End without punctuation.
	Description(context.Context) string

	// MarkdownDescription should describe the plan modifier in Markdown
	// formatting. This information is used by provider logging and provider
	// tooling such as documentation generation.
	//
	// The description should:
	//  - Begin with a lowercase or other character suitable for the middle of
	//    a sentence.
	//  - End without punctuation.
	MarkdownDescription(context.Context) string
}

Describer is the common documentation interface for extensible schema plan modifier functionality.

type Float64

type Float64 interface {
	Describer

	// PlanModifyFloat64 should perform the modification.
	PlanModifyFloat64(context.Context, Float64Request, *Float64Response)
}

Float64 is a schema validator for types.Float64 attributes.

type Float64Request

type Float64Request struct {
	// Path contains the path of the attribute for modification. Use this path
	// for any response diagnostics.
	Path path.Path

	// PathExpression contains the expression matching the exact path
	// of the attribute for modification.
	PathExpression path.Expression

	// Config contains the entire configuration of the resource.
	Config tfsdk.Config

	// ConfigValue contains the value of the attribute for modification from the configuration.
	ConfigValue types.Float64

	// Plan contains the entire proposed new state of the resource.
	Plan tfsdk.Plan

	// PlanValue contains the value of the attribute for modification from the proposed new state.
	PlanValue types.Float64

	// State contains the entire prior state of the resource.
	State tfsdk.State

	// StateValue contains the value of the attribute for modification from the prior state.
	StateValue types.Float64

	// Private is provider-defined resource private state data which was previously
	// stored with the resource state. This data is opaque to Terraform and does
	// not affect plan output. Any existing data is copied to
	// Float64Response.Private to prevent accidental private state data loss.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	//
	// Use the GetKey method to read data. Use the SetKey method on
	// Float64Response.Private to update or remove a value.
	Private *privatestate.ProviderData
}

Float64Request is a request for types.Float64 schema plan modification.

type Float64Response

type Float64Response struct {
	// PlanValue is the planned new state for the attribute.
	PlanValue types.Float64

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

	// Private is the private state resource data following the PlanModifyFloat64 operation.
	// This field is pre-populated from Float64Request.Private and
	// can be modified during the resource's PlanModifyFloat64 operation.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	Private *privatestate.ProviderData

	// 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
}

Float64Response is a response to a Float64Request.

type Int64

type Int64 interface {
	Describer

	// PlanModifyInt64 should perform the modification.
	PlanModifyInt64(context.Context, Int64Request, *Int64Response)
}

Int64 is a schema validator for types.Int64 attributes.

type Int64Request

type Int64Request struct {
	// Path contains the path of the attribute for modification. Use this path
	// for any response diagnostics.
	Path path.Path

	// PathExpression contains the expression matching the exact path
	// of the attribute for modification.
	PathExpression path.Expression

	// Config contains the entire configuration of the resource.
	Config tfsdk.Config

	// ConfigValue contains the value of the attribute for modification from the configuration.
	ConfigValue types.Int64

	// Plan contains the entire proposed new state of the resource.
	Plan tfsdk.Plan

	// PlanValue contains the value of the attribute for modification from the proposed new state.
	PlanValue types.Int64

	// State contains the entire prior state of the resource.
	State tfsdk.State

	// StateValue contains the value of the attribute for modification from the prior state.
	StateValue types.Int64

	// Private is provider-defined resource private state data which was previously
	// stored with the resource state. This data is opaque to Terraform and does
	// not affect plan output. Any existing data is copied to
	// Int64Response.Private to prevent accidental private state data loss.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	//
	// Use the GetKey method to read data. Use the SetKey method on
	// Int64Response.Private to update or remove a value.
	Private *privatestate.ProviderData
}

Int64Request is a request for types.Int64 schema plan modification.

type Int64Response

type Int64Response struct {
	// PlanValue is the planned new state for the attribute.
	PlanValue types.Int64

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

	// Private is the private state resource data following the PlanModifyInt64 operation.
	// This field is pre-populated from Int64Request.Private and
	// can be modified during the resource's PlanModifyInt64 operation.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	Private *privatestate.ProviderData

	// 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
}

Int64Response is a response to a Int64Request.

type List

type List interface {
	Describer

	// PlanModifyList should perform the modification.
	PlanModifyList(context.Context, ListRequest, *ListResponse)
}

List is a schema validator for types.List attributes.

type ListRequest

type ListRequest struct {
	// Path contains the path of the attribute for modification. Use this path
	// for any response diagnostics.
	Path path.Path

	// PathExpression contains the expression matching the exact path
	// of the attribute for modification.
	PathExpression path.Expression

	// Config contains the entire configuration of the resource.
	Config tfsdk.Config

	// ConfigValue contains the value of the attribute for modification from the configuration.
	ConfigValue types.List

	// Plan contains the entire proposed new state of the resource.
	Plan tfsdk.Plan

	// PlanValue contains the value of the attribute for modification from the proposed new state.
	PlanValue types.List

	// State contains the entire prior state of the resource.
	State tfsdk.State

	// StateValue contains the value of the attribute for modification from the prior state.
	StateValue types.List

	// Private is provider-defined resource private state data which was previously
	// stored with the resource state. This data is opaque to Terraform and does
	// not affect plan output. Any existing data is copied to
	// ListResponse.Private to prevent accidental private state data loss.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	//
	// Use the GetKey method to read data. Use the SetKey method on
	// ListResponse.Private to update or remove a value.
	Private *privatestate.ProviderData
}

ListRequest is a request for types.List schema plan modification.

type ListResponse

type ListResponse struct {
	// PlanValue is the planned new state for the attribute.
	PlanValue types.List

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

	// Private is the private state resource data following the PlanModifyList operation.
	// This field is pre-populated from ListRequest.Private and
	// can be modified during the resource's PlanModifyList operation.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	Private *privatestate.ProviderData

	// 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
}

ListResponse is a response to a ListRequest.

type Map

type Map interface {
	Describer

	// PlanModifyMap should perform the modification.
	PlanModifyMap(context.Context, MapRequest, *MapResponse)
}

Map is a schema validator for types.Map attributes.

type MapRequest

type MapRequest struct {
	// Path contains the path of the attribute for modification. Use this path
	// for any response diagnostics.
	Path path.Path

	// PathExpression contains the expression matching the exact path
	// of the attribute for modification.
	PathExpression path.Expression

	// Config contains the entire configuration of the resource.
	Config tfsdk.Config

	// ConfigValue contains the value of the attribute for modification from the configuration.
	ConfigValue types.Map

	// Plan contains the entire proposed new state of the resource.
	Plan tfsdk.Plan

	// PlanValue contains the value of the attribute for modification from the proposed new state.
	PlanValue types.Map

	// State contains the entire prior state of the resource.
	State tfsdk.State

	// StateValue contains the value of the attribute for modification from the prior state.
	StateValue types.Map

	// Private is provider-defined resource private state data which was previously
	// stored with the resource state. This data is opaque to Terraform and does
	// not affect plan output. Any existing data is copied to
	// MapResponse.Private to prevent accidental private state data loss.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	//
	// Use the GetKey method to read data. Use the SetKey method on
	// MapResponse.Private to update or remove a value.
	Private *privatestate.ProviderData
}

MapRequest is a request for types.Map schema plan modification.

type MapResponse

type MapResponse struct {
	// PlanValue is the planned new state for the attribute.
	PlanValue types.Map

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

	// Private is the private state resource data following the PlanModifyMap operation.
	// This field is pre-populated from MapRequest.Private and
	// can be modified during the resource's PlanModifyMap operation.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	Private *privatestate.ProviderData

	// 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
}

MapResponse is a response to a MapRequest.

type Number

type Number interface {
	Describer

	// PlanModifyNumber should perform the modification.
	PlanModifyNumber(context.Context, NumberRequest, *NumberResponse)
}

Number is a schema validator for types.Number attributes.

type NumberRequest

type NumberRequest struct {
	// Path contains the path of the attribute for modification. Use this path
	// for any response diagnostics.
	Path path.Path

	// PathExpression contains the expression matching the exact path
	// of the attribute for modification.
	PathExpression path.Expression

	// Config contains the entire configuration of the resource.
	Config tfsdk.Config

	// ConfigValue contains the value of the attribute for modification from the configuration.
	ConfigValue types.Number

	// Plan contains the entire proposed new state of the resource.
	Plan tfsdk.Plan

	// PlanValue contains the value of the attribute for modification from the proposed new state.
	PlanValue types.Number

	// State contains the entire prior state of the resource.
	State tfsdk.State

	// StateValue contains the value of the attribute for modification from the prior state.
	StateValue types.Number

	// Private is provider-defined resource private state data which was previously
	// stored with the resource state. This data is opaque to Terraform and does
	// not affect plan output. Any existing data is copied to
	// NumberResponse.Private to prevent accidental private state data loss.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	//
	// Use the GetKey method to read data. Use the SetKey method on
	// NumberResponse.Private to update or remove a value.
	Private *privatestate.ProviderData
}

NumberRequest is a request for types.Number schema plan modification.

type NumberResponse

type NumberResponse struct {
	// PlanValue is the planned new state for the attribute.
	PlanValue types.Number

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

	// Private is the private state resource data following the PlanModifyNumber operation.
	// This field is pre-populated from NumberRequest.Private and
	// can be modified during the resource's PlanModifyNumber operation.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	Private *privatestate.ProviderData

	// 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
}

NumberResponse is a response to a NumberRequest.

type Object

type Object interface {
	Describer

	// PlanModifyObject should perform the modification.
	PlanModifyObject(context.Context, ObjectRequest, *ObjectResponse)
}

Object is a schema validator for types.Object attributes.

type ObjectRequest

type ObjectRequest struct {
	// Path contains the path of the attribute for modification. Use this path
	// for any response diagnostics.
	Path path.Path

	// PathExpression contains the expression matching the exact path
	// of the attribute for modification.
	PathExpression path.Expression

	// Config contains the entire configuration of the resource.
	Config tfsdk.Config

	// ConfigValue contains the value of the attribute for modification from the configuration.
	ConfigValue types.Object

	// Plan contains the entire proposed new state of the resource.
	Plan tfsdk.Plan

	// PlanValue contains the value of the attribute for modification from the proposed new state.
	PlanValue types.Object

	// State contains the entire prior state of the resource.
	State tfsdk.State

	// StateValue contains the value of the attribute for modification from the prior state.
	StateValue types.Object

	// Private is provider-defined resource private state data which was previously
	// stored with the resource state. This data is opaque to Terraform and does
	// not affect plan output. Any existing data is copied to
	// ObjectResponse.Private to prevent accidental private state data loss.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	//
	// Use the GetKey method to read data. Use the SetKey method on
	// ObjectResponse.Private to update or remove a value.
	Private *privatestate.ProviderData
}

ObjectRequest is a request for types.Object schema plan modification.

type ObjectResponse

type ObjectResponse struct {
	// PlanValue is the planned new state for the attribute.
	PlanValue types.Object

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

	// Private is the private state resource data following the PlanModifyObject operation.
	// This field is pre-populated from ObjectRequest.Private and
	// can be modified during the resource's PlanModifyObject operation.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	Private *privatestate.ProviderData

	// 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
}

ObjectResponse is a response to a ObjectRequest.

type Set

type Set interface {
	Describer

	// PlanModifySet should perform the modification.
	PlanModifySet(context.Context, SetRequest, *SetResponse)
}

Set is a schema validator for types.Set attributes.

type SetRequest

type SetRequest struct {
	// Path contains the path of the attribute for modification. Use this path
	// for any response diagnostics.
	Path path.Path

	// PathExpression contains the expression matching the exact path
	// of the attribute for modification.
	PathExpression path.Expression

	// Config contains the entire configuration of the resource.
	Config tfsdk.Config

	// ConfigValue contains the value of the attribute for modification from the configuration.
	ConfigValue types.Set

	// Plan contains the entire proposed new state of the resource.
	Plan tfsdk.Plan

	// PlanValue contains the value of the attribute for modification from the proposed new state.
	PlanValue types.Set

	// State contains the entire prior state of the resource.
	State tfsdk.State

	// StateValue contains the value of the attribute for modification from the prior state.
	StateValue types.Set

	// Private is provider-defined resource private state data which was previously
	// stored with the resource state. This data is opaque to Terraform and does
	// not affect plan output. Any existing data is copied to
	// SetResponse.Private to prevent accidental private state data loss.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	//
	// Use the GetKey method to read data. Use the SetKey method on
	// SetResponse.Private to update or remove a value.
	Private *privatestate.ProviderData
}

SetRequest is a request for types.Set schema plan modification.

type SetResponse

type SetResponse struct {
	// PlanValue is the planned new state for the attribute.
	PlanValue types.Set

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

	// Private is the private state resource data following the PlanModifySet operation.
	// This field is pre-populated from SetRequest.Private and
	// can be modified during the resource's PlanModifySet operation.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	Private *privatestate.ProviderData

	// 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
}

SetResponse is a response to a SetRequest.

type String

type String interface {
	Describer

	// PlanModifyString should perform the modification.
	PlanModifyString(context.Context, StringRequest, *StringResponse)
}

String is a schema validator for types.String attributes.

type StringRequest

type StringRequest struct {
	// Path contains the path of the attribute for modification. Use this path
	// for any response diagnostics.
	Path path.Path

	// PathExpression contains the expression matching the exact path
	// of the attribute for modification.
	PathExpression path.Expression

	// Config contains the entire configuration of the resource.
	Config tfsdk.Config

	// ConfigValue contains the value of the attribute for modification from the configuration.
	ConfigValue types.String

	// Plan contains the entire proposed new state of the resource.
	Plan tfsdk.Plan

	// PlanValue contains the value of the attribute for modification from the proposed new state.
	PlanValue types.String

	// State contains the entire prior state of the resource.
	State tfsdk.State

	// StateValue contains the value of the attribute for modification from the prior state.
	StateValue types.String

	// Private is provider-defined resource private state data which was previously
	// stored with the resource state. This data is opaque to Terraform and does
	// not affect plan output. Any existing data is copied to
	// StringResponse.Private to prevent accidental private state data loss.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	//
	// Use the GetKey method to read data. Use the SetKey method on
	// StringResponse.Private to update or remove a value.
	Private *privatestate.ProviderData
}

StringRequest is a request for types.String schema plan modification.

type StringResponse

type StringResponse struct {
	// PlanValue is the planned new state for the attribute.
	PlanValue types.String

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

	// Private is the private state resource data following the PlanModifyString operation.
	// This field is pre-populated from StringRequest.Private and
	// can be modified during the resource's PlanModifyString operation.
	//
	// The private state data is always the original data when the schema-based plan
	// modification began or, is updated as the logic traverses deeper into underlying
	// attributes.
	Private *privatestate.ProviderData

	// 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
}

StringResponse is a response to a StringRequest.

Jump to

Keyboard shortcuts

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