Documentation
¶
Index ¶
- Constants
- Variables
- func AttrTypesString(attrTypes specschema.ObjectAttributeTypes) (string, error)
- func ElementTypeString(elementType specschema.ElementType) (string, error)
- func GetAttrTypes(attrTypes specschema.ObjectAttributeTypes) string
- func GetElementType(e specschema.ElementType) string
- type AssocExtType
- type Attributes
- type Attrs
- type Blocks
- type CustomObjectType
- type CustomObjectValue
- type CustomTypeAndValue
- type Elements
- type FrameworkIdentifier
- type GeneratorAttribute
- type GeneratorAttributeAssocExtType
- type GeneratorAttributes
- func (g GeneratorAttributes) AttrTypes() (map[string]string, error)
- func (g GeneratorAttributes) AttrValues() (map[string]string, error)
- func (g GeneratorAttributes) AttributeTypes() (map[string]string, error)
- func (g GeneratorAttributes) FromFuncs() map[string]string
- func (g GeneratorAttributes) Schema() (string, error)
- func (g GeneratorAttributes) SortedKeys() []string
- func (g GeneratorAttributes) ToFuncs() map[string]string
- type GeneratorBlock
- type GeneratorBlockAssocExtType
- type GeneratorBlocks
- func (g GeneratorBlocks) AttrTypes() (map[string]string, error)
- func (g GeneratorBlocks) AttrValues() (map[string]string, error)
- func (g GeneratorBlocks) BlockTypes() (map[string]string, error)
- func (g GeneratorBlocks) FromFuncs() map[string]string
- func (g GeneratorBlocks) Schema() (string, error)
- func (g GeneratorBlocks) SortedKeys() []string
- func (g GeneratorBlocks) ToFuncs() map[string]string
- type GeneratorSchema
- func (g GeneratorSchema) CustomTypeValueBytes() ([]byte, error)
- func (g GeneratorSchema) Imports() (string, error)
- func (g GeneratorSchema) Models(name string) ([]model.Model, error)
- func (g GeneratorSchema) Schema(name, packageName, generatorType string) ([]byte, error)
- func (g GeneratorSchema) ToFromFunctions() ([]byte, error)
- type GeneratorSchemas
- type Imports
- func AttrImports() *Imports
- func CustomDefaultImports(c *specschema.CustomDefault) *Imports
- func CustomPlanModifierImports(c *specschema.CustomPlanModifier) *Imports
- func CustomTypeImports(c *specschema.CustomType) *Imports
- func CustomValidatorImports(cv *specschema.CustomValidator) *Imports
- func GetAttrTypesImports(customType *specschema.CustomType, attrTypes specschema.ObjectAttributeTypes) *Imports
- func GetElementTypeImports(e specschema.ElementType) *Imports
- func NewImports() *Imports
- type ToFrom
- type ToFromObject
- type Type
Constants ¶
const ( AttrImport = "github.com/hashicorp/terraform-plugin-framework/attr" BaseTypesImport = "github.com/hashicorp/terraform-plugin-framework/types/basetypes" ContextImport = "context" DiagImport = "github.com/hashicorp/terraform-plugin-framework/diag" FmtImport = "fmt" PlanModifierImport = "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" StringsImport = "strings" TfTypesImport = "github.com/hashicorp/terraform-plugin-go/tftypes" TypesImport = "github.com/hashicorp/terraform-plugin-framework/types" ValidatorImport = "github.com/hashicorp/terraform-plugin-framework/schema/validator" )
Variables ¶
var ObjectFromTemplate string
var ObjectToTemplate string
var ObjectTypeEqualTemplate string
var ObjectTypeStringTemplate string
var ObjectTypeTypableTemplate string
var ObjectTypeTypeTemplate string
var ObjectTypeValueFromObjectTemplate string
var ObjectTypeValueFromTerraformTemplate string
var ObjectTypeValueMustTemplate string
var ObjectTypeValueNullTemplate string
var ObjectTypeValueTemplate string
var ObjectTypeValueTypeTemplate string
var ObjectTypeValueUnknownTemplate string
var ObjectValueAttributeTypesTemplate string
var ObjectValueEqualTemplate string
var ObjectValueIsNullTemplate string
var ObjectValueIsUnknownTemplate string
var ObjectValueStringTemplate string
var ObjectValueToObjectValueTemplate string
var ObjectValueToTerraformValueTemplate string
var ObjectValueTypeTemplate string
var ObjectValueValuableTemplate string
var ObjectValueValueTemplate string
var SchemaGoTemplate string
Functions ¶
func AttrTypesString ¶
func AttrTypesString(attrTypes specschema.ObjectAttributeTypes) (string, error)
func ElementTypeString ¶
func ElementTypeString(elementType specschema.ElementType) (string, error)
func GetAttrTypes ¶
func GetAttrTypes(attrTypes specschema.ObjectAttributeTypes) string
GetAttrTypes generates the strings for use within templates for specifying the types to use with object attribute types.
func GetElementType ¶
func GetElementType(e specschema.ElementType) string
GetElementType generates the strings for use within templates for specifying the types to use with collection (i.e., list, map and set) element types.
Types ¶
type AssocExtType ¶
type AssocExtType struct {
*schema.AssociatedExternalType
}
func NewAssocExtType ¶
func NewAssocExtType(assocExtType *schema.AssociatedExternalType) *AssocExtType
func (*AssocExtType) Equal ¶
func (a *AssocExtType) Equal(other *AssocExtType) bool
func (*AssocExtType) Imports ¶
func (a *AssocExtType) Imports() *Imports
func (*AssocExtType) ToPascalCase ¶
func (a *AssocExtType) ToPascalCase() string
func (*AssocExtType) Type ¶
func (a *AssocExtType) Type() string
func (*AssocExtType) TypeReference ¶
func (a *AssocExtType) TypeReference() string
type Attributes ¶
type Attributes interface {
GetAttributes() GeneratorAttributes
}
type Attrs ¶
type Attrs interface {
AttrTypes() specschema.ObjectAttributeTypes
}
type Blocks ¶
type Blocks interface { Attributes GetBlocks() GeneratorBlocks }
type CustomObjectType ¶
type CustomObjectType struct { Name FrameworkIdentifier AttrValues map[FrameworkIdentifier]string // contains filtered or unexported fields }
func NewCustomObjectType ¶
func NewCustomObjectType(name string, attrValues map[string]string) CustomObjectType
func (CustomObjectType) Render ¶
func (c CustomObjectType) Render() ([]byte, error)
type CustomObjectValue ¶
type CustomObjectValue struct { Name FrameworkIdentifier AttributeTypes map[FrameworkIdentifier]string AttrTypes map[FrameworkIdentifier]string AttrValues map[FrameworkIdentifier]string // contains filtered or unexported fields }
func NewCustomObjectValue ¶
func NewCustomObjectValue(name string, attributeTypes, attrTypes, attrValues map[string]string) CustomObjectValue
func (CustomObjectValue) Render ¶
func (c CustomObjectValue) Render() ([]byte, error)
type CustomTypeAndValue ¶
type Elements ¶
type Elements interface {
ElemType() specschema.ElementType
}
type FrameworkIdentifier ¶
type FrameworkIdentifier string
FrameworkIdentifier is a string that implements helpful methods for validating and converting identifier names that are valid in Terraform Plugin Framework
func (FrameworkIdentifier) ToCamelCase ¶
func (identifier FrameworkIdentifier) ToCamelCase() string
ToCamelCase will return a camel case formatted string of the identifier. Example:
- example_resource_thing -> exampleResourceThing
func (FrameworkIdentifier) ToPascalCase ¶
func (identifier FrameworkIdentifier) ToPascalCase() string
ToPascalCase will return a pascal case formatted string of the identifier. Example:
- example_resource_thing -> ExampleResourceThing
func (FrameworkIdentifier) ToString ¶
func (identifier FrameworkIdentifier) ToString() string
ToString returns the FrameworkIdentifier as a string without any formatting. Example:
- example_resource_thing -> example_resource_thing
func (FrameworkIdentifier) Valid ¶
func (identifier FrameworkIdentifier) Valid() bool
Valid will return whether the identifier string is a valid identifier in Terraform Plugin Framework
type GeneratorAttribute ¶
type GeneratorAttribute interface { Equal(GeneratorAttribute) bool GeneratorSchemaType() Type Imports() *Imports ModelField(FrameworkIdentifier) (model.Field, error) Schema(FrameworkIdentifier) (string, error) }
type GeneratorAttributeAssocExtType ¶
type GeneratorAttributeAssocExtType interface { GeneratorAttribute AssocExtType() *AssocExtType }
type GeneratorAttributes ¶
type GeneratorAttributes map[string]GeneratorAttribute
func (GeneratorAttributes) AttrTypes ¶
func (g GeneratorAttributes) AttrTypes() (map[string]string, error)
AttrTypes returns a mapping of attribute names to string representations of the underlying attr.Type.
func (GeneratorAttributes) AttrValues ¶
func (g GeneratorAttributes) AttrValues() (map[string]string, error)
AttrValues returns a mapping of attribute names to string representations of the underlying attr.Value.
func (GeneratorAttributes) AttributeTypes ¶
func (g GeneratorAttributes) AttributeTypes() (map[string]string, error)
AttributeTypes returns a mapping of attribute names to string representations of the attribute type.
func (GeneratorAttributes) FromFuncs ¶
func (g GeneratorAttributes) FromFuncs() map[string]string
FromFuncs returns a mapping of attribute names to string representations of the function that converts a Go value to a framework value.
func (GeneratorAttributes) Schema ¶
func (g GeneratorAttributes) Schema() (string, error)
func (GeneratorAttributes) SortedKeys ¶
func (g GeneratorAttributes) SortedKeys() []string
func (GeneratorAttributes) ToFuncs ¶
func (g GeneratorAttributes) ToFuncs() map[string]string
ToFuncs returns a mapping of attribute names to string representations of the function that converts a framework value to a Go value.
type GeneratorBlock ¶
type GeneratorBlock interface { Equal(GeneratorBlock) bool GeneratorSchemaType() Type Imports() *Imports ModelField(FrameworkIdentifier) (model.Field, error) Schema(FrameworkIdentifier) (string, error) }
type GeneratorBlockAssocExtType ¶
type GeneratorBlockAssocExtType interface { GeneratorBlock AssocExtType() *AssocExtType }
type GeneratorBlocks ¶
type GeneratorBlocks map[string]GeneratorBlock
func (GeneratorBlocks) AttrTypes ¶
func (g GeneratorBlocks) AttrTypes() (map[string]string, error)
AttrTypes returns a mapping of block names to string representations of the underlying attr.Type.
func (GeneratorBlocks) AttrValues ¶
func (g GeneratorBlocks) AttrValues() (map[string]string, error)
AttrValues returns a mapping of block names to string representations of the underlying attr.Value.
func (GeneratorBlocks) BlockTypes ¶
func (g GeneratorBlocks) BlockTypes() (map[string]string, error)
BlockTypes returns a mapping of block names to string representations of the block type.
func (GeneratorBlocks) FromFuncs ¶
func (g GeneratorBlocks) FromFuncs() map[string]string
FromFuncs returns a mapping of block names to string representations of the function that converts a Go value to a framework value.
func (GeneratorBlocks) Schema ¶
func (g GeneratorBlocks) Schema() (string, error)
func (GeneratorBlocks) SortedKeys ¶
func (g GeneratorBlocks) SortedKeys() []string
func (GeneratorBlocks) ToFuncs ¶
func (g GeneratorBlocks) ToFuncs() map[string]string
ToFuncs returns a mapping of block names to string representations of the function that converts a framework value to a Go value.
type GeneratorSchema ¶
type GeneratorSchema struct { Attributes GeneratorAttributes Blocks GeneratorBlocks }
func (GeneratorSchema) CustomTypeValueBytes ¶
func (g GeneratorSchema) CustomTypeValueBytes() ([]byte, error)
CustomTypeValueBytes iterates over all the attributes and blocks to generate code for custom type and value types for use in the schema and data models.
func (GeneratorSchema) Imports ¶
func (g GeneratorSchema) Imports() (string, error)
func (GeneratorSchema) Schema ¶
func (g GeneratorSchema) Schema(name, packageName, generatorType string) ([]byte, error)
func (GeneratorSchema) ToFromFunctions ¶
func (g GeneratorSchema) ToFromFunctions() ([]byte, error)
ToFromFunctions generates code for converting to an associated external type from a framework type, and from an associated external type to a framework type.
type GeneratorSchemas ¶
type GeneratorSchemas struct {
// contains filtered or unexported fields
}
TODO: Field(s) could be added to handle end-user supplying their own templates to allow overriding.
func NewGeneratorSchemas ¶
func NewGeneratorSchemas(schemas map[string]GeneratorSchema) GeneratorSchemas
func (GeneratorSchemas) CustomTypeValue ¶
func (g GeneratorSchemas) CustomTypeValue() (map[string][]byte, error)
func (GeneratorSchemas) Schemas ¶
func (g GeneratorSchemas) Schemas(packageName, generatorType string) (map[string][]byte, error)
func (GeneratorSchemas) ToFromFunctions ¶
func (g GeneratorSchemas) ToFromFunctions() (map[string][]byte, error)
type Imports ¶
type Imports struct {
// contains filtered or unexported fields
}
func AttrImports ¶
func AttrImports() *Imports
func CustomDefaultImports ¶
func CustomDefaultImports(c *specschema.CustomDefault) *Imports
func CustomPlanModifierImports ¶
func CustomPlanModifierImports(c *specschema.CustomPlanModifier) *Imports
func CustomTypeImports ¶
func CustomTypeImports(c *specschema.CustomType) *Imports
func CustomValidatorImports ¶
func CustomValidatorImports(cv *specschema.CustomValidator) *Imports
func GetAttrTypesImports ¶
func GetAttrTypesImports(customType *specschema.CustomType, attrTypes specschema.ObjectAttributeTypes) *Imports
func GetElementTypeImports ¶
func GetElementTypeImports(e specschema.ElementType) *Imports
func NewImports ¶
func NewImports() *Imports
type ToFromObject ¶
type ToFromObject struct { Name FrameworkIdentifier AssocExtType *AssocExtType FromFuncs map[FrameworkIdentifier]string ToFuncs map[FrameworkIdentifier]string // contains filtered or unexported fields }
func NewToFromObject ¶
func NewToFromObject(name string, assocExtType *AssocExtType, toFuncs, fromFuncs map[string]string) ToFromObject
func (ToFromObject) Render ¶
func (o ToFromObject) Render() ([]byte, error)
type Type ¶
type Type int64
const ( InvalidGeneratorSchemaType Type = iota GeneratorBoolAttribute GeneratorFloat64Attribute GeneratorInt64Attribute GeneratorListAttribute GeneratorListNestedAttribute GeneratorListNestedBlock GeneratorMapAttribute GeneratorMapNestedAttribute GeneratorNumberAttribute GeneratorObjectAttribute GeneratorSetAttribute GeneratorSetNestedAttribute GeneratorSetNestedBlock GeneratorSingleNestedAttribute GeneratorSingleNestedBlock GeneratorStringAttribute )