11package tf
22
33import (
4- "context"
5-
6- "github.com/hashicorp/terraform-plugin-go/tfprotov6"
7- "github.com/hashicorp/terraform-plugin-go/tftypes"
4+ "github.com/hashicorp/terraform-plugin-framework/attribute"
85)
96
107const (
11- NestingModeSingle NestingMode = 0
12- NestingModeList NestingMode = 1
13- NestingModeSet NestingMode = 2
14- NestingModeMap NestingMode = 3
8+ NestingModeSingle attribute. NestingMode = 0
9+ NestingModeList attribute. NestingMode = 1
10+ NestingModeSet attribute. NestingMode = 2
11+ NestingModeMap attribute. NestingMode = 3
1512)
1613
1714// Schema is used to define the shape of practitioner-provider information,
@@ -39,7 +36,7 @@ type Attribute struct {
3936 // want to use one of the types in the types package.
4037 //
4138 // If Type is set, Attributes cannot be.
42- Type AttributeType
39+ Type attribute. AttributeType
4340
4441 // Attributes can have their own, nested attributes. This nested map of
4542 // attributes behaves exactly like the map of attributes on the Schema
@@ -54,7 +51,7 @@ type Attribute struct {
5451 // AttributesNestingMode controls the various ways these sub-groups of
5552 // attributes can behave. It can only be used with Attributes, and must
5653 // not be set if Type is set.
57- AttributesNestingMode NestingMode
54+ AttributesNestingMode attribute. NestingMode
5855
5956 // Description is used in various tooling, like the documentation
6057 // generator and the language server, to give practitioners more
@@ -66,7 +63,7 @@ type Attribute struct {
6663 // Description uses. It should be Markdown or PlainText.
6764 //
6865 // TODO: come up with a better interface for this, this is weird.
69- DescriptionKind StringKind
66+ DescriptionKind attribute. StringKind
7067
7168 // Required indicates whether the practitioner must enter a value for
7269 // this attribute or not. Required and Optional cannot both be true,
@@ -97,53 +94,3 @@ type Attribute struct {
9794 // instructing them on what upgrade steps to take.
9895 DeprecationMessage string
9996}
100-
101- // AttributeType defines an interface for describing a kind of attribute.
102- // AttributeTypes are collections of constraints and behaviors such that they
103- // can be reused on multiple attributes easily.
104- type AttributeType interface {
105- // TerraformType returns the tftypes.Type that should be used to
106- // represent this type. This constrains what user input will be
107- // accepted and what kind of data can be set in state. The framework
108- // will use this to translate the AttributeType to something Terraform
109- // can understand.
110- TerraformType (context.Context ) tftypes.Type
111-
112- // Validate returns any warnings or errors about the value that is
113- // being used to populate the AttributeType. It is generally used to
114- // check the data format and ensure that it complies with the
115- // requirements of the AttributeType.
116- //
117- // TODO: don't use tfprotov6.Diagnostic, use our type
118- Validate (context.Context , tftypes.Value ) []* tfprotov6.Diagnostic
119-
120- // Description returns a practitioner-friendly explanation of the type
121- // and the constraints of the data it accepts and returns. It will be
122- // combined with the Description associated with the Attribute.
123- Description (context.Context , StringKind ) string
124-
125- // ValueFromTerraform returns an AttributeValue given a tftypes.Value.
126- // This is meant to convert the tftypes.Value into a more convenient Go
127- // type for the provider to consume the data with.
128- ValueFromTerraform (context.Context , tftypes.Value ) (AttributeValue , error )
129- }
130-
131- // StringKind represents a kind of string formatting.
132- type StringKind uint8
133-
134- // NestingMode represents a specific way a group of attributes can be nested.
135- type NestingMode uint8
136-
137- // AttributeValue defines an interface for describing data associated with an
138- // attribute. AttributeValues allow provider developers to specify data in a
139- // convenient format, and have it transparently be converted to formats
140- // Terraform understands.
141- type AttributeValue interface {
142- // ToTerraformValue returns the data contained in the AttributeValue as
143- // a Go type that tftypes.NewValue will accept.
144- ToTerraformValue (context.Context ) (interface {}, error )
145-
146- // Equal must return true if the AttributeValue is considered
147- // semantically equal to the AttributeValue passed as an argument.
148- Equal (AttributeValue ) bool
149- }
0 commit comments