Documentation ¶
Overview ¶
Package tfsdk contains core framework functionality for schema data.
Index ¶
- Constants
- Variables
- func ConvertValue(ctx context.Context, val attr.Value, typ attr.Type) (attr.Value, diag.Diagnostics)
- func ListNestedAttributes(attributes map[string]Attribute) fwschema.NestedAttributesdeprecated
- func MapNestedAttributes(attributes map[string]Attribute) fwschema.NestedAttributesdeprecated
- func SetNestedAttributes(attributes map[string]Attribute) fwschema.NestedAttributesdeprecated
- func SingleNestedAttributes(attributes map[string]Attribute) fwschema.NestedAttributesdeprecated
- func ValueAs(ctx context.Context, val attr.Value, target interface{}) diag.Diagnostics
- func ValueFrom(ctx context.Context, val interface{}, targetType attr.Type, target interface{}) diag.Diagnostics
- type Attributedeprecated
- func (a Attribute) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)
- func (a Attribute) Equal(o fwschema.Attribute) bool
- func (a Attribute) GetDeprecationMessage() string
- func (a Attribute) GetDescription() string
- func (a Attribute) GetMarkdownDescription() string
- func (a Attribute) GetNestedObject() fwschema.NestedAttributeObject
- func (a Attribute) GetNestingMode() fwschema.NestingMode
- func (a Attribute) GetPlanModifiers() AttributePlanModifiers
- func (a Attribute) GetType() attr.Type
- func (a Attribute) GetValidators() []AttributeValidator
- func (a Attribute) IsComputed() bool
- func (a Attribute) IsOptional() bool
- func (a Attribute) IsRequired() bool
- func (a Attribute) IsSensitive() bool
- type AttributePlanModifier
- type AttributePlanModifiers
- type AttributeValidator
- type Blockdeprecated
- func (b Block) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)
- func (b Block) Equal(o fwschema.Block) bool
- func (b Block) GetDeprecationMessage() string
- func (b Block) GetDescription() string
- func (b Block) GetMarkdownDescription() string
- func (b Block) GetMaxItems() int64
- func (b Block) GetMinItems() int64
- func (b Block) GetNestedObject() fwschema.NestedBlockObject
- func (b Block) GetNestingMode() fwschema.BlockNestingMode
- func (b Block) GetPlanModifiers() AttributePlanModifiers
- func (b Block) GetValidators() []AttributeValidator
- func (b Block) Type() attr.Type
- type Config
- type ModifyAttributePlanRequest
- type ModifyAttributePlanResponse
- type Plan
- func (p Plan) Get(ctx context.Context, target interface{}) diag.Diagnostics
- func (p Plan) GetAttribute(ctx context.Context, path path.Path, target interface{}) diag.Diagnostics
- func (p Plan) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
- func (p *Plan) Set(ctx context.Context, val interface{}) diag.Diagnostics
- func (p *Plan) SetAttribute(ctx context.Context, path path.Path, val interface{}) diag.Diagnostics
- type Schemadeprecated
- func (s Schema) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)
- func (s Schema) AttributeAtPath(ctx context.Context, p path.Path) (fwschema.Attribute, diag.Diagnostics)
- func (s Schema) AttributeAtTerraformPath(ctx context.Context, p *tftypes.AttributePath) (fwschema.Attribute, error)
- func (s Schema) GetAttributes() map[string]fwschema.Attribute
- func (s Schema) GetBlocks() map[string]fwschema.Block
- func (s Schema) GetDeprecationMessage() string
- func (s Schema) GetDescription() string
- func (s Schema) GetMarkdownDescription() string
- func (s Schema) GetVersion() int64
- func (s Schema) Type() attr.Type
- func (s Schema) TypeAtPath(ctx context.Context, p path.Path) (attr.Type, diag.Diagnostics)
- func (s Schema) TypeAtTerraformPath(ctx context.Context, p *tftypes.AttributePath) (attr.Type, error)
- type State
- func (s State) Get(ctx context.Context, target interface{}) diag.Diagnostics
- func (s State) GetAttribute(ctx context.Context, path path.Path, target interface{}) diag.Diagnostics
- func (s State) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
- func (s *State) RemoveResource(ctx context.Context)
- func (s *State) Set(ctx context.Context, val interface{}) diag.Diagnostics
- func (s *State) SetAttribute(ctx context.Context, path path.Path, val interface{}) diag.Diagnostics
- type ValidateAttributeRequest
- type ValidateAttributeResponse
Constants ¶
const ( BlockNestingModeList = fwschema.BlockNestingModeList BlockNestingModeSet = fwschema.BlockNestingModeSet BlockNestingModeSingle = fwschema.BlockNestingModeSingle )
Variables ¶
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, attribute, or block of a complex type, not a nested // attribute. // // Deprecated: This error value was intended for internal usage and will // be removed in a future version. If you have a use case for this, // please create a GitHub issue. ErrPathInsideAtomicAttribute = fwschema.ErrPathInsideAtomicAttribute // ErrPathIsBlock is used with AttributeAtPath is called on a path is a // block, not an attribute. Use blockAtPath on the path instead. // // Deprecated: This error value was intended for internal usage and will // be removed in a future version. If you have a use case for this, // please create a GitHub issue. ErrPathIsBlock = fwschema.ErrPathIsBlock )
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 ListNestedAttributes
deprecated
added in
v0.3.0
func ListNestedAttributes(attributes map[string]Attribute) fwschema.NestedAttributes
ListNestedAttributes nests `attributes` under another attribute, allowing multiple instances of that group of attributes to appear in the configuration.
Deprecated: Use datasource/schema.ListNestedAttribute, provider/schema.ListNestedAttribute, or resource/schema.ListNestedAttribute instead. This can be switched by using the datasource/schema.Schema, provider/schema.Schema, or resource/schema.Schema types.
func MapNestedAttributes
deprecated
added in
v0.3.0
func MapNestedAttributes(attributes map[string]Attribute) fwschema.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.
Deprecated: Use datasource/schema.MapNestedAttribute, provider/schema.MapNestedAttribute, or resource/schema.MapNestedAttribute instead. This can be switched by using the datasource/schema.Schema, provider/schema.Schema, or resource/schema.Schema types.
func SetNestedAttributes
deprecated
added in
v0.3.0
func SetNestedAttributes(attributes map[string]Attribute) fwschema.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.
Deprecated: Use datasource/schema.SetNestedAttribute, provider/schema.SetNestedAttribute, or resource/schema.SetNestedAttribute instead. This can be switched by using the datasource/schema.Schema, provider/schema.Schema, or resource/schema.Schema types.
func SingleNestedAttributes
deprecated
added in
v0.3.0
func SingleNestedAttributes(attributes map[string]Attribute) fwschema.NestedAttributes
SingleNestedAttributes nests `attributes` under another attribute, only allowing one instance of that group of attributes to appear in the configuration.
Deprecated: Use datasource/schema.SingleNestedAttribute, provider/schema.SingleNestedAttribute, or resource/schema.SingleNestedAttribute instead. This can be switched by using the datasource/schema.Schema, provider/schema.Schema, or resource/schema.Schema types.
func ValueAs ¶ added in v0.3.0
ValueAs takes the attr.Value `val` and populates the Go value `target` with its content.
This is achieved using reflection rules provided by the internal/reflect package.
func ValueFrom ¶ added in v0.9.0
func ValueFrom(ctx context.Context, val interface{}, targetType attr.Type, target interface{}) diag.Diagnostics
ValueFrom takes the Go value `val` and populates `target` with an attr.Value, based on the type definition provided in `targetType`.
This is achieved using reflection rules provided by the internal/reflect package.
Types ¶
type Attribute
deprecated
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 fwschema.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. // // When defining an attribute that has Optional set to true, // and uses PlanModifiers to set a "default value" when none is provided, // Computed must also be set to true. This is necessary because default // values are, in effect, set by the provider (i.e. computed). 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. // // When defining an Optional Attribute that has a "default value" // plan modifier, Computed must also be set to true. Otherwise, // Terraform will return an error like: // // planned value ... for a non-computed attribute // 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 warning diagnostic details to display when // practitioner configurations use this Attribute. The warning diagnostic // summary is automatically set to "Attribute Deprecated" along with // configuration source file and line information. // // Set this field to a practitioner actionable message such as: // // - "Configure other_attribute instead. This attribute will be removed // in the next major version of the provider." // - "Remove this attribute's configuration as it no longer is used and // the attribute will be removed in the next major version of the // provider." // // In Terraform 1.2.7 and later, this warning diagnostic is displayed any // time a practitioner attempts to configure a value for this attribute and // certain scenarios where this attribute is referenced. // // In Terraform 1.2.6 and earlier, this warning diagnostic is only // displayed when the Attribute is Required or Optional, and if the // practitioner configuration sets the value to a known or unknown value // (which may eventually be null). It has no effect when the Attribute is // Computed-only (read-only; not Required or Optional). // // Across any Terraform version, there are no warnings raised for // practitioner configuration values set directly to null, as there is no // way for the framework to differentiate between an unset and null // configuration due to how Terraform sends configuration information // across the protocol. // // Additional information about deprecation enhancements for read-only // attributes can be found in: // // - https://github.com/hashicorp/terraform/issues/7569 // DeprecationMessage string // Validators define value validation functionality for the attribute. All // elements of the slice of AttributeValidator are run, regardless of any // previous error diagnostics. // // Many common use case validators can be found in the // github.com/hashicorp/terraform-plugin-framework-validators Go module. // // If the Type field points to a custom type that implements the // xattr.TypeWithValidate interface, the validators defined in this field // are run in addition to the validation defined by the type. 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 or // Block 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. // // When providing PlanModifiers, it's necessary to set Computed to true. PlanModifiers AttributePlanModifiers }
Attribute defines the constraints and behaviors of a single value field in a schema. Attributes are the fields that show up in Terraform state files and can be used in configuration files.
Deprecated: Use datasource/schema.Attribute, provider/schema.Attribute, or resource/schema.Attribute instead. This can be switched by using the datasource/schema.Schema, provider/schema.Schema, or resource/schema.Schema types.
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
Equal returns true if `a` and `o` should be considered Equal.
func (Attribute) GetDeprecationMessage ¶ added in v0.11.0
GetDeprecationMessage satisfies the fwschema.Attribute interface.
func (Attribute) GetDescription ¶ added in v0.11.0
GetDescription satisfies the fwschema.Attribute interface.
func (Attribute) GetMarkdownDescription ¶ added in v0.11.0
GetMarkdownDescription satisfies the fwschema.Attribute interface.
func (Attribute) GetNestedObject ¶ added in v0.17.0
func (a Attribute) GetNestedObject() fwschema.NestedAttributeObject
GetNestedObject returns a generated NestedAttributeObject if the Attribute represents nested attributes, otherwise nil.
func (Attribute) GetNestingMode ¶ added in v0.17.0
func (a Attribute) GetNestingMode() fwschema.NestingMode
GetNestingMode returns the Attributes nesting mode, if set. Otherwise, returns NestingModeUnset.
func (Attribute) GetPlanModifiers ¶ added in v0.11.0
func (a Attribute) GetPlanModifiers() AttributePlanModifiers
GetPlanModifiers satisfies the fwxschema.AttributeWithPlanModifiers interface.
func (Attribute) GetValidators ¶ added in v0.11.0
func (a Attribute) GetValidators() []AttributeValidator
GetValidators satisfies the fwxschema.AttributeWithValidators interface.
func (Attribute) IsComputed ¶ added in v0.11.0
IsComputed satisfies the fwschema.Attribute interface.
func (Attribute) IsOptional ¶ added in v0.11.0
IsOptional satisfies the fwschema.Attribute interface.
func (Attribute) IsRequired ¶ added in v0.11.0
IsRequired satisfies the fwschema.Attribute interface.
func (Attribute) IsSensitive ¶ added in v0.11.0
IsSensitive satisfies the fwschema.Attribute interface.
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.
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 Block
deprecated
added in
v0.5.0
type Block struct { // Attributes are value fields inside the block. This map of attributes // behaves exactly like the map of attributes on the Schema type. Attributes map[string]Attribute // Blocks can have their own nested blocks. This nested map of blocks // behaves exactly like the map of blocks on the Schema type. Blocks map[string]Block // DeprecationMessage defines warning diagnostic details to display to // practitioners configuring this Block. The warning diagnostic summary // is automatically set to "Block Deprecated" along with configuration // source file and line information. // // This warning diagnostic is only displayed during Terraform's validation // phase when this field is a non-empty string and if the practitioner // configuration attempts to set the block value to a known or unknown // value (which may eventually be null). // // Set this field to a practitioner actionable message such as: // // - "Configure other_attribute instead. This block will be removed // in the next major version of the provider." // - "Remove this block's configuration as it no longer is used and // the block will be removed in the next major version of the // provider." // DeprecationMessage string // 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 // MaxItems is the maximum number of blocks that can be present in a // practitioner configuration. MaxItems int64 // MinItems is the minimum number of blocks that must be present in a // practitioner configuration. Setting to 1 or above effectively marks // this configuration as required. MinItems int64 // NestingMode indicates the block kind. This field must be set or a // runtime error will be raised by the framework when fetching the schema. NestingMode fwschema.BlockNestingMode // PlanModifiers defines a sequence of modifiers for this block at // plan time. Block-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 or // Block, but will not prevent execution of PlanModifiers on any // other Attribute or Block 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 // Validators defines validation functionality for the block. Validators []AttributeValidator }
Block defines the constraints and behaviors of a single structural field in a schema.
The NestingMode field must be set or a runtime error will be raised by the framework when fetching the schema.
Deprecated: Use datasource/schema.Block, provider/schema.Block, or resource/schema.Block instead. This can be switched by using the datasource/schema.Schema, provider/schema.Schema, or resource/schema.Schema types.
func (Block) ApplyTerraform5AttributePathStep ¶ added in v0.5.0
func (b Block) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)
ApplyTerraform5AttributePathStep allows Blocks to be walked using tftypes.Walk and tftypes.Transform.
func (Block) GetDeprecationMessage ¶ added in v0.11.0
GetDeprecationMessage satisfies the fwschema.Block interface.
func (Block) GetDescription ¶ added in v0.11.0
GetDescription satisfies the fwschema.Block interface.
func (Block) GetMarkdownDescription ¶ added in v0.11.0
GetMarkdownDescription satisfies the fwschema.Block interface.
func (Block) GetMaxItems ¶ added in v0.11.0
GetMaxItems satisfies the fwschema.Block interface.
func (Block) GetMinItems ¶ added in v0.11.0
GetMinItems satisfies the fwschema.Block interface.
func (Block) GetNestedObject ¶ added in v0.17.0
func (b Block) GetNestedObject() fwschema.NestedBlockObject
GetNestedObject returns a generated NestedBlockObject from the Attributes and Blocks field values.
func (Block) GetNestingMode ¶ added in v0.11.0
func (b Block) GetNestingMode() fwschema.BlockNestingMode
GetNestingMode satisfies the fwschema.Block interface.
func (Block) GetPlanModifiers ¶ added in v0.11.0
func (b Block) GetPlanModifiers() AttributePlanModifiers
GetPlanModifiers satisfies the fwxschema.BlockWithPlanModifiers interface.
func (Block) GetValidators ¶ added in v0.11.0
func (b Block) GetValidators() []AttributeValidator
GetValidators satisfies the fwxschema.BlockWithValidators interface.
type Config ¶
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 path.Path, target interface{}) diag.Diagnostics
GetAttribute retrieves the attribute or block found at `path` and populates the `target` with the value. This method is intended for top level schema attributes or blocks. Use `types` package methods or custom types to step into collections.
Attributes or elements under null or unknown collections return null values, however this behavior is not protected by compatibility promises.
func (Config) PathMatches ¶ added in v0.10.0
func (c Config) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
PathMatches returns all matching path.Paths from the given path.Expression.
If a parent path is null or unknown, which would prevent a full expression from matching, the parent path is returned rather than no match to prevent false positives.
type ModifyAttributePlanRequest ¶ added in v0.3.0
type ModifyAttributePlanRequest struct { // AttributePath is the path of the attribute. Use this path for any // response diagnostics. AttributePath path.Path // AttributePathExpression is the expression matching the exact path of the // attribute. AttributePathExpression path.Expression // 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 // 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 // ModifyAttributePlanResponse.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 // ModifyAttributePlanResponse.Private to update or remove a value. Private *privatestate.ProviderData }
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 // Private is the private state resource data following the ModifyAttributePlan operation. // This field is pre-populated from ModifyAttributePlanRequest.Private and // can be modified during the resource's ModifyAttributePlan 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 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).
type Plan ¶
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 path.Path, target interface{}) diag.Diagnostics
GetAttribute retrieves the attribute or block found at `path` and populates the `target` with the value. This method is intended for top level schema attributes or blocks. Use `types` package methods or custom types to step into collections.
Attributes or elements under null or unknown collections return null values, however this behavior is not protected by compatibility promises.
func (Plan) PathMatches ¶ added in v0.10.0
func (p Plan) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
PathMatches returns all matching path.Paths from the given path.Expression.
If a parent path is null or unknown, which would prevent a full expression from matching, the parent path is returned rather than no match to prevent false positives.
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 ¶
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.
The value must not be an untyped nil. Use a typed nil or types package null value function instead. For example with a types.StringType attribute, use (*string)(nil) or types.StringNull().
Lists can only have the next element added according to the current length.
type Schema
deprecated
added in
v0.3.0
type Schema struct { // Attributes are value 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. Names must // not collide with any Blocks names. // // In practitioner configurations, an equals sign (=) is required to set // the value. See also: // https://www.terraform.io/docs/language/syntax/configuration.html // // Attributes are strongly preferred over Blocks. Attributes map[string]Attribute // Blocks are structural fields inside the resource, provider, or data // source that the schema is defining. The map key should be the name // of the block, and the body defines how it behaves. Names must // only contain lowercase letters, numbers, and underscores. Names must // not collide with any Attributes names. // // Blocks are by definition, structural, meaning they are implicitly // required in values. // // In practitioner configurations, an equals sign (=) cannot be used to // set the value. Blocks are instead repeated as necessary, or require // the use of dynamic block expressions. See also: // https://www.terraform.io/docs/language/syntax/configuration.html // https://www.terraform.io/docs/language/expressions/dynamic-blocks.html // // Attributes are preferred over Blocks. Blocks should typically be used // for configuration compatibility with previously existing schemas from // an older Terraform Plugin SDK. Efforts should be made to convert from // Blocks to Attributes as a breaking change for practitioners. Blocks map[string]Block // 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.
Deprecated: Use datasource/schema.Schema, provider/schema.Schema, or resource/schema.Schema instead. This can be switched by using the datasource.DataSource, provider.Provider, or resource.Resource interface Schema method.
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(ctx context.Context, p path.Path) (fwschema.Attribute, diag.Diagnostics)
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) AttributeAtTerraformPath ¶ added in v0.11.0
func (s Schema) AttributeAtTerraformPath(ctx context.Context, p *tftypes.AttributePath) (fwschema.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) GetAttributes ¶ added in v0.11.0
GetAttributes satisfies the fwschema.Schema interface.
func (Schema) GetDeprecationMessage ¶ added in v0.11.0
GetDeprecationMessage satisfies the fwschema.Schema interface.
func (Schema) GetDescription ¶ added in v0.11.0
GetDescription satisfies the fwschema.Schema interface.
func (Schema) GetMarkdownDescription ¶ added in v0.11.0
GetMarkdownDescription satisfies the fwschema.Schema interface.
func (Schema) GetVersion ¶ added in v0.11.0
GetVersion satisfies the fwschema.Schema interface.
func (Schema) TypeAtPath ¶ added in v0.11.0
TypeAtPath returns the framework type at the given schema path.
func (Schema) TypeAtTerraformPath ¶ added in v0.11.0
func (s Schema) TypeAtTerraformPath(ctx context.Context, p *tftypes.AttributePath) (attr.Type, error)
TypeAtTerraformPath returns the framework type at the given tftypes path.
type State ¶
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 path.Path, target interface{}) diag.Diagnostics
GetAttribute retrieves the attribute or block found at `path` and populates the `target` with the value. This method is intended for top level schema attributes or blocks. Use `types` package methods or custom types to step into collections.
Attributes or elements under null or unknown collections return null values, however this behavior is not protected by compatibility promises.
func (State) PathMatches ¶ added in v0.10.0
func (s State) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
PathMatches returns all matching path.Paths from the given path.Expression.
If a parent path is null or unknown, which would prevent a full expression from matching, the parent path is returned rather than no match to prevent false positives.
func (*State) RemoveResource ¶
RemoveResource removes the entire resource from state.
If a Resource type Delete method is completed without error, this is automatically called on the DeleteResourceResponse.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 ¶
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.
The value must not be an untyped nil. Use a typed nil or types package null value function instead. For example with a types.StringType attribute, use (*string)(nil) or types.StringNull().
Lists can only have the next element added according to the current length.
type ValidateAttributeRequest ¶ added in v0.3.0
type ValidateAttributeRequest struct { // AttributePath contains the path of the attribute. Use this path for any // response diagnostics. AttributePath path.Path // AttributePathExpression contains the expression matching the exact path // of the attribute. AttributePathExpression path.Expression // 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 attribute validation.
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.