Documentation
¶
Index ¶
- Constants
- Variables
- func AttrTypesString(attrTypes specschema.ObjectAttributeTypes) (string, error)
- func ElementTypeGoType(elementType specschema.ElementType) (string, error)
- func ElementTypeString(elementType specschema.ElementType) (string, error)
- func GetAttrTypes(attrTypes specschema.ObjectAttributeTypes) string
- func GetAttrTypesFromFuncs(a specschema.ObjectAttributeTypes) (map[string]string, error)
- func GetAttrTypesToFuncs(a specschema.ObjectAttributeTypes) (map[string]AttrTypesToFuncs, error)
- func GetElementFromFunc(e specschema.ElementType) (string, error)
- func GetElementType(e specschema.ElementType) string
- func GetElementValueType(e specschema.ElementType) string
- type AssocExtType
- type AttrType
- type AttrTypesToFuncs
- type AttrValue
- type Attributes
- type Attrs
- type Blocks
- type CollectionFields
- type CollectionType
- type CustomBoolType
- type CustomBoolValue
- type CustomFloat64Type
- type CustomFloat64Value
- type CustomInt64Type
- type CustomInt64Value
- type CustomListType
- type CustomListValue
- type CustomMapType
- type CustomMapValue
- type CustomNestedObjectType
- type CustomNestedObjectValue
- type CustomNumberType
- type CustomNumberValue
- type CustomObjectType
- type CustomObjectValue
- type CustomSetType
- type CustomSetValue
- type CustomStringType
- type CustomStringValue
- type CustomTypeAndValue
- type Elements
- type FrameworkIdentifier
- func (identifier FrameworkIdentifier) ToCamelCase() string
- func (identifier FrameworkIdentifier) ToPascalCase() string
- func (identifier FrameworkIdentifier) ToPrefixCamelCase(prefix string) string
- func (identifier FrameworkIdentifier) ToPrefixPascalCase(prefix string) string
- func (identifier FrameworkIdentifier) ToString() string
- func (identifier FrameworkIdentifier) Valid() bool
- type From
- type GeneratorAttribute
- 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) CollectionTypes() (map[string]map[string]string, error)
- func (g GeneratorAttributes) Equal(other GeneratorAttributes) bool
- func (g GeneratorAttributes) FromFuncs() (map[string]ToFromConversion, error)
- func (g GeneratorAttributes) Imports() *Imports
- func (g GeneratorAttributes) Schema() (string, error)
- func (g GeneratorAttributes) SortedKeys() []string
- func (g GeneratorAttributes) ToFuncs() (map[string]ToFromConversion, error)
- type GeneratorBlock
- 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) Equal(other GeneratorBlocks) bool
- func (g GeneratorBlocks) FromFuncs() map[string]string
- func (g GeneratorBlocks) Imports() *Imports
- 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(ctx context.Context, logger *slog.Logger) ([]byte, error)
- type GeneratorSchemas
- func (g GeneratorSchemas) CustomTypeValue() (map[string][]byte, error)
- func (g GeneratorSchemas) Models() (map[string][]byte, error)
- func (g GeneratorSchemas) Schemas(packageName, generatorType string) (map[string][]byte, error)
- func (g GeneratorSchemas) ToFromFunctions(ctx context.Context, logger *slog.Logger) (map[string][]byte, error)
- type Imports
- type ObjectField
- type To
- type ToFrom
- type ToFromBool
- type ToFromConversion
- type ToFromFloat64
- type ToFromInt64
- type ToFromList
- type ToFromMap
- type ToFromNestedObject
- type ToFromNumber
- type ToFromObject
- type ToFromSet
- type ToFromString
- type Type
- type UnimplementedError
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" MathBigImport = "math/big" 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 BoolFromTemplate string
var BoolToTemplate string
var BoolTypeEqualTemplate string
var BoolTypeStringTemplate string
var BoolTypeTypableTemplate string
var BoolTypeTypeTemplate string
var BoolTypeValueFromBoolTemplate string
var BoolTypeValueFromTerraformTemplate string
var BoolTypeValueTypeTemplate string
var BoolValueEqualTemplate string
var BoolValueTypeTemplate string
var BoolValueValuableTemplate string
var BoolValueValueTemplate string
var Float64FromTemplate string
var Float64ToTemplate string
var Float64TypeEqualTemplate string
var Float64TypeStringTemplate string
var Float64TypeTypableTemplate string
var Float64TypeTypeTemplate string
var Float64TypeValueFromFloat64Template string
var Float64TypeValueFromTerraformTemplate string
var Float64TypeValueTypeTemplate string
var Float64ValueEqualTemplate string
var Float64ValueTypeTemplate string
var Float64ValueValuableTemplate string
var Float64ValueValueTemplate string
var Int64FromTemplate string
var Int64ToTemplate string
var Int64TypeEqualTemplate string
var Int64TypeStringTemplate string
var Int64TypeTypableTemplate string
var Int64TypeTypeTemplate string
var Int64TypeValueFromInt64Template string
var Int64TypeValueFromTerraformTemplate string
var Int64TypeValueTypeTemplate string
var Int64ValueEqualTemplate string
var Int64ValueTypeTemplate string
var Int64ValueValuableTemplate string
var Int64ValueValueTemplate string
var ListFromTemplate string
var ListToTemplate string
var ListTypeEqualTemplate string
var ListTypeStringTemplate string
var ListTypeTypableTemplate string
var ListTypeTypeTemplate string
var ListTypeValueFromListTemplate string
var ListTypeValueFromTerraformTemplate string
var ListTypeValueTypeTemplate string
var ListValueEqualTemplate string
var ListValueTypeTemplate string
var ListValueValuableTemplate string
var ListValueValueTemplate string
var MapFromTemplate string
var MapToTemplate string
var MapTypeEqualTemplate string
var MapTypeStringTemplate string
var MapTypeTypableTemplate string
var MapTypeTypeTemplate string
var MapTypeValueFromMapTemplate string
var MapTypeValueFromTerraformTemplate string
var MapTypeValueTypeTemplate string
var MapValueEqualTemplate string
var MapValueTypeTemplate string
var MapValueValuableTemplate string
var MapValueValueTemplate string
var NestedObjectFromTemplate string
var NestedObjectToTemplate string
var NestedObjectTypeEqualTemplate string
var NestedObjectTypeStringTemplate string
var NestedObjectTypeTypableTemplate string
var NestedObjectTypeTypeTemplate string
var NestedObjectTypeValueFromObjectTemplate string
var NestedObjectTypeValueFromTerraformTemplate string
var NestedObjectTypeValueMustTemplate string
var NestedObjectTypeValueNullTemplate string
var NestedObjectTypeValueTemplate string
var NestedObjectTypeValueTypeTemplate string
var NestedObjectTypeValueUnknownTemplate string
var NestedObjectValueAttributeTypesTemplate string
var NestedObjectValueEqualTemplate string
var NestedObjectValueIsNullTemplate string
var NestedObjectValueIsUnknownTemplate string
var NestedObjectValueStringTemplate string
var NestedObjectValueToObjectValueTemplate string
var NestedObjectValueToTerraformValueTemplate string
var NestedObjectValueTypeTemplate string
var NestedObjectValueValuableTemplate string
var NestedObjectValueValueTemplate string
var NumberFromTemplate string
var NumberToTemplate string
var NumberTypeEqualTemplate string
var NumberTypeStringTemplate string
var NumberTypeTypableTemplate string
var NumberTypeTypeTemplate string
var NumberTypeValueFromNumberTemplate string
var NumberTypeValueFromTerraformTemplate string
var NumberTypeValueTypeTemplate string
var NumberValueEqualTemplate string
var NumberValueTypeTemplate string
var NumberValueValuableTemplate string
var NumberValueValueTemplate string
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 ObjectTypeValueTypeTemplate string
var ObjectValueAttributeTypesTemplate string
var ObjectValueEqualTemplate string
var ObjectValueTypeTemplate string
var ObjectValueValuableTemplate string
var ObjectValueValueTemplate string
var SchemaGoTemplate string
var SetFromTemplate string
var SetToTemplate string
var SetTypeEqualTemplate string
var SetTypeStringTemplate string
var SetTypeTypableTemplate string
var SetTypeTypeTemplate string
var SetTypeValueFromSetTemplate string
var SetTypeValueFromTerraformTemplate string
var SetTypeValueTypeTemplate string
var SetValueEqualTemplate string
var SetValueTypeTemplate string
var SetValueValuableTemplate string
var SetValueValueTemplate string
var StringFromTemplate string
var StringToTemplate string
var StringTypeEqualTemplate string
var StringTypeStringTemplate string
var StringTypeTypableTemplate string
var StringTypeTypeTemplate string
var StringTypeValueFromStringTemplate string
var StringTypeValueFromTerraformTemplate string
var StringTypeValueTypeTemplate string
var StringValueEqualTemplate string
var StringValueTypeTemplate string
var StringValueValuableTemplate string
var StringValueValueTemplate string
Functions ¶
func AttrTypesString ¶
func AttrTypesString(attrTypes specschema.ObjectAttributeTypes) (string, error)
func ElementTypeGoType ¶ added in v0.3.0
func ElementTypeGoType(elementType specschema.ElementType) (string, error)
ElementTypeGoType defaults to the defined pointer types on the basis of the supplied elementType. TODO: Provide a mechanism to allow mapping to be configured. For instance elementType.Float64 => float32 TODO: Implement for list, map, object, and set.
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 GetAttrTypesFromFuncs ¶ added in v0.3.0
func GetAttrTypesFromFuncs(a specschema.ObjectAttributeTypes) (map[string]string, error)
GetAttrTypesFromFuncs returns string representations of the function that is used for converting from an API Go type to a framework type. TODO: Handle custom type, and types other than primitives.
func GetAttrTypesToFuncs ¶ added in v0.3.0
func GetAttrTypesToFuncs(a specschema.ObjectAttributeTypes) (map[string]AttrTypesToFuncs, error)
GetAttrTypesToFuncs returns string representations of the function that is used for converting to an API Go type from a framework type. TODO: Handle custom type, and types other than primitives.
func GetElementFromFunc ¶ added in v0.3.0
func GetElementFromFunc(e specschema.ElementType) (string, error)
GetElementFromFunc returns a string representation of the function that is used for converting from an API Go type to a framework type. TODO: Handle custom type, and types other than primitives.
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.
func GetElementValueType ¶ added in v0.3.0
func GetElementValueType(e specschema.ElementType) string
GetElementValueType generates the strings for use within templates for specifying the value 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) ToCamelCase ¶ added in v0.2.0
func (a *AssocExtType) ToCamelCase() string
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 AttrType ¶ added in v0.2.0
type AttrType interface {
AttrType(FrameworkIdentifier) (string, error)
}
type AttrTypesToFuncs ¶ added in v0.3.0
type AttrValue ¶ added in v0.2.0
type AttrValue interface {
AttrValue(FrameworkIdentifier) 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 CollectionFields ¶ added in v0.3.0
type CollectionType ¶ added in v0.3.0
type CustomBoolType ¶ added in v0.2.0
type CustomBoolType struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomBoolType ¶ added in v0.2.0
func NewCustomBoolType(name string) CustomBoolType
func (CustomBoolType) Render ¶ added in v0.2.0
func (c CustomBoolType) Render() ([]byte, error)
type CustomBoolValue ¶ added in v0.2.0
type CustomBoolValue struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomBoolValue ¶ added in v0.2.0
func NewCustomBoolValue(name string) CustomBoolValue
func (CustomBoolValue) Render ¶ added in v0.2.0
func (c CustomBoolValue) Render() ([]byte, error)
type CustomFloat64Type ¶ added in v0.2.0
type CustomFloat64Type struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomFloat64Type ¶ added in v0.2.0
func NewCustomFloat64Type(name string) CustomFloat64Type
func (CustomFloat64Type) Render ¶ added in v0.2.0
func (c CustomFloat64Type) Render() ([]byte, error)
type CustomFloat64Value ¶ added in v0.2.0
type CustomFloat64Value struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomFloat64Value ¶ added in v0.2.0
func NewCustomFloat64Value(name string) CustomFloat64Value
func (CustomFloat64Value) Render ¶ added in v0.2.0
func (c CustomFloat64Value) Render() ([]byte, error)
type CustomInt64Type ¶ added in v0.2.0
type CustomInt64Type struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomInt64Type ¶ added in v0.2.0
func NewCustomInt64Type(name string) CustomInt64Type
func (CustomInt64Type) Render ¶ added in v0.2.0
func (c CustomInt64Type) Render() ([]byte, error)
type CustomInt64Value ¶ added in v0.2.0
type CustomInt64Value struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomInt64Value ¶ added in v0.2.0
func NewCustomInt64Value(name string) CustomInt64Value
func (CustomInt64Value) Render ¶ added in v0.2.0
func (c CustomInt64Value) Render() ([]byte, error)
type CustomListType ¶ added in v0.3.0
type CustomListType struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomListType ¶ added in v0.3.0
func NewCustomListType(name string) CustomListType
func (CustomListType) Render ¶ added in v0.3.0
func (c CustomListType) Render() ([]byte, error)
type CustomListValue ¶ added in v0.3.0
type CustomListValue struct { Name FrameworkIdentifier ElementType string // contains filtered or unexported fields }
func NewCustomListValue ¶ added in v0.3.0
func NewCustomListValue(name, elemType string) CustomListValue
func (CustomListValue) Render ¶ added in v0.3.0
func (c CustomListValue) Render() ([]byte, error)
type CustomMapType ¶ added in v0.3.0
type CustomMapType struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomMapType ¶ added in v0.3.0
func NewCustomMapType(name string) CustomMapType
func (CustomMapType) Render ¶ added in v0.3.0
func (c CustomMapType) Render() ([]byte, error)
type CustomMapValue ¶ added in v0.3.0
type CustomMapValue struct { Name FrameworkIdentifier ElementType string // contains filtered or unexported fields }
func NewCustomMapValue ¶ added in v0.3.0
func NewCustomMapValue(name, elemType string) CustomMapValue
func (CustomMapValue) Render ¶ added in v0.3.0
func (c CustomMapValue) Render() ([]byte, error)
type CustomNestedObjectType ¶ added in v0.3.0
type CustomNestedObjectType struct { Name FrameworkIdentifier AttrValues map[FrameworkIdentifier]string // contains filtered or unexported fields }
func NewCustomNestedObjectType ¶ added in v0.3.0
func NewCustomNestedObjectType(name string, attrValues map[string]string) CustomNestedObjectType
func (CustomNestedObjectType) Render ¶ added in v0.3.0
func (c CustomNestedObjectType) Render() ([]byte, error)
type CustomNestedObjectValue ¶ added in v0.3.0
type CustomNestedObjectValue struct { Name FrameworkIdentifier AttributeTypes map[FrameworkIdentifier]string AttrTypes map[FrameworkIdentifier]string AttrValues map[FrameworkIdentifier]string CollectionTypes map[FrameworkIdentifier]map[string]string // contains filtered or unexported fields }
func NewCustomNestedObjectValue ¶ added in v0.3.0
func (CustomNestedObjectValue) Render ¶ added in v0.3.0
func (c CustomNestedObjectValue) Render() ([]byte, error)
type CustomNumberType ¶ added in v0.2.0
type CustomNumberType struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomNumberType ¶ added in v0.2.0
func NewCustomNumberType(name string) CustomNumberType
func (CustomNumberType) Render ¶ added in v0.2.0
func (c CustomNumberType) Render() ([]byte, error)
type CustomNumberValue ¶ added in v0.2.0
type CustomNumberValue struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomNumberValue ¶ added in v0.2.0
func NewCustomNumberValue(name string) CustomNumberValue
func (CustomNumberValue) Render ¶ added in v0.2.0
func (c CustomNumberValue) Render() ([]byte, error)
type CustomObjectType ¶
type CustomObjectType struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomObjectType ¶
func NewCustomObjectType(name string) CustomObjectType
func (CustomObjectType) Render ¶
func (c CustomObjectType) Render() ([]byte, error)
type CustomObjectValue ¶
type CustomObjectValue struct { Name FrameworkIdentifier AttrTypes string // contains filtered or unexported fields }
func NewCustomObjectValue ¶
func NewCustomObjectValue(name, attrTypes string) CustomObjectValue
func (CustomObjectValue) Render ¶
func (c CustomObjectValue) Render() ([]byte, error)
type CustomSetType ¶ added in v0.3.0
type CustomSetType struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomSetType ¶ added in v0.3.0
func NewCustomSetType(name string) CustomSetType
func (CustomSetType) Render ¶ added in v0.3.0
func (c CustomSetType) Render() ([]byte, error)
type CustomSetValue ¶ added in v0.3.0
type CustomSetValue struct { Name FrameworkIdentifier ElementType string // contains filtered or unexported fields }
func NewCustomSetValue ¶ added in v0.3.0
func NewCustomSetValue(name, elemType string) CustomSetValue
func (CustomSetValue) Render ¶ added in v0.3.0
func (c CustomSetValue) Render() ([]byte, error)
type CustomStringType ¶ added in v0.2.0
type CustomStringType struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomStringType ¶ added in v0.2.0
func NewCustomStringType(name string) CustomStringType
func (CustomStringType) Render ¶ added in v0.2.0
func (c CustomStringType) Render() ([]byte, error)
type CustomStringValue ¶ added in v0.2.0
type CustomStringValue struct { Name FrameworkIdentifier // contains filtered or unexported fields }
func NewCustomStringValue ¶ added in v0.2.0
func NewCustomStringValue(name string) CustomStringValue
func (CustomStringValue) Render ¶ added in v0.2.0
func (c CustomStringValue) 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) ToPrefixCamelCase ¶ added in v0.3.0
func (identifier FrameworkIdentifier) ToPrefixCamelCase(prefix string) string
ToPrefixCamelCase will return a camel case formatted string of the identifier, prefixed with a camel-cased version of the supplied name if the identifier is a generated custom value method name. Example:
- equal(something) -> somethingEqual
- type(something) -> somethingType
func (FrameworkIdentifier) ToPrefixPascalCase ¶ added in v0.3.0
func (identifier FrameworkIdentifier) ToPrefixPascalCase(prefix string) string
ToPrefixPascalCase will return a pascal case formatted string of the identifier, prefixed with a pascal-cased version of the supplied name if the identifier is a generated custom value method name. Example:
- equal(something) -> SomethingEqual
- type(something) -> SomethingType
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 From ¶ added in v0.2.0
type From interface {
From() (ToFromConversion, error)
}
type GeneratorAttribute ¶
type GeneratorAttribute interface { Equal(GeneratorAttribute) bool GeneratorSchemaType() Type Imports() *Imports ModelField(FrameworkIdentifier) (model.Field, error) Schema(FrameworkIdentifier) (string, error) }
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) CollectionTypes ¶ added in v0.3.0
func (g GeneratorAttributes) CollectionTypes() (map[string]map[string]string, error)
CollectionTypes returns a mapping of attribute names to string representations of the element type (e.g., types.BoolType), and type value function (e.g., types.ListValue) for collection types that do not have an associated external type.
func (GeneratorAttributes) Equal ¶ added in v0.4.0
func (g GeneratorAttributes) Equal(other GeneratorAttributes) bool
func (GeneratorAttributes) FromFuncs ¶
func (g GeneratorAttributes) FromFuncs() (map[string]ToFromConversion, error)
FromFuncs returns a mapping of attribute names to string representations of the function that converts a Go value to a framework value.
func (GeneratorAttributes) Imports ¶ added in v0.4.0
func (g GeneratorAttributes) Imports() *Imports
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]ToFromConversion, error)
ToFuncs returns a mapping of attribute names to string representations of the function that converts a framework value to a Go value. If an UnimplementedError is encountered, it is logged and execution continues.
type GeneratorBlock ¶
type GeneratorBlock interface { Equal(GeneratorBlock) bool GeneratorSchemaType() Type Imports() *Imports ModelField(FrameworkIdentifier) (model.Field, error) Schema(FrameworkIdentifier) (string, error) }
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) Equal ¶ added in v0.4.0
func (g GeneratorBlocks) Equal(other GeneratorBlocks) bool
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) Imports ¶ added in v0.4.0
func (g GeneratorBlocks) Imports() *Imports
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 Description *string MarkdownDescription *string DeprecationMessage *string }
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 ¶
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 ¶
type Imports ¶
type Imports struct {
// contains filtered or unexported fields
}
func AssociatedExternalTypeImports ¶ added in v0.2.0
func AssociatedExternalTypeImports() *Imports
func AttrImports ¶
func AttrImports() *Imports
func NewImports ¶
func NewImports() *Imports
type ObjectField ¶ added in v0.3.0
func ObjectFieldFrom ¶ added in v0.3.0
func ObjectFieldFrom(o specschema.ObjectAttributeType) (ObjectField, error)
func ObjectFieldTo ¶ added in v0.3.0
func ObjectFieldTo(o specschema.ObjectAttributeType) (ObjectField, error)
type To ¶ added in v0.2.0
type To interface {
To() (ToFromConversion, error)
}
type ToFromBool ¶ added in v0.2.0
type ToFromBool struct { Name FrameworkIdentifier AssocExtType *AssocExtType // contains filtered or unexported fields }
func NewToFromBool ¶ added in v0.2.0
func NewToFromBool(name string, assocExtType *AssocExtType) ToFromBool
func (ToFromBool) Render ¶ added in v0.2.0
func (o ToFromBool) Render() ([]byte, error)
type ToFromConversion ¶ added in v0.2.0
type ToFromConversion struct { Default string AssocExtType *AssocExtType CollectionType CollectionFields ObjectType map[FrameworkIdentifier]ObjectField }
type ToFromFloat64 ¶ added in v0.2.0
type ToFromFloat64 struct { Name FrameworkIdentifier AssocExtType *AssocExtType // contains filtered or unexported fields }
func NewToFromFloat64 ¶ added in v0.2.0
func NewToFromFloat64(name string, assocExtType *AssocExtType) ToFromFloat64
func (ToFromFloat64) Render ¶ added in v0.2.0
func (o ToFromFloat64) Render() ([]byte, error)
type ToFromInt64 ¶ added in v0.2.0
type ToFromInt64 struct { Name FrameworkIdentifier AssocExtType *AssocExtType // contains filtered or unexported fields }
func NewToFromInt64 ¶ added in v0.2.0
func NewToFromInt64(name string, assocExtType *AssocExtType) ToFromInt64
func (ToFromInt64) Render ¶ added in v0.2.0
func (o ToFromInt64) Render() ([]byte, error)
type ToFromList ¶ added in v0.3.0
type ToFromList struct { Name FrameworkIdentifier AssocExtType *AssocExtType ElementTypeType string ElementTypeValue string ElementFrom string // contains filtered or unexported fields }
func NewToFromList ¶ added in v0.3.0
func NewToFromList(name string, assocExtType *AssocExtType, elemTypeType, elemTypeValue, elemFrom string) ToFromList
func (ToFromList) Render ¶ added in v0.3.0
func (o ToFromList) Render() ([]byte, error)
type ToFromMap ¶ added in v0.3.0
type ToFromMap struct { Name FrameworkIdentifier AssocExtType *AssocExtType ElementTypeType string ElementTypeValue string ElementFrom string // contains filtered or unexported fields }
func NewToFromMap ¶ added in v0.3.0
func NewToFromMap(name string, assocExtType *AssocExtType, elemTypeType, elemTypeValue, elemFrom string) ToFromMap
type ToFromNestedObject ¶ added in v0.3.0
type ToFromNestedObject struct { Name FrameworkIdentifier AssocExtType *AssocExtType ToFuncs map[FrameworkIdentifier]ToFromConversion FromFuncs map[FrameworkIdentifier]ToFromConversion // contains filtered or unexported fields }
func NewToFromNestedObject ¶ added in v0.3.0
func NewToFromNestedObject(name string, assocExtType *AssocExtType, toFuncs, fromFuncs map[string]ToFromConversion) ToFromNestedObject
func (ToFromNestedObject) Render ¶ added in v0.3.0
func (o ToFromNestedObject) Render() ([]byte, error)
type ToFromNumber ¶ added in v0.2.0
type ToFromNumber struct { Name FrameworkIdentifier AssocExtType *AssocExtType // contains filtered or unexported fields }
func NewToFromNumber ¶ added in v0.2.0
func NewToFromNumber(name string, assocExtType *AssocExtType) ToFromNumber
func (ToFromNumber) Render ¶ added in v0.2.0
func (o ToFromNumber) Render() ([]byte, error)
type ToFromObject ¶
type ToFromObject struct { Name FrameworkIdentifier AssocExtType *AssocExtType AttrTypesToFuncs map[FrameworkIdentifier]AttrTypesToFuncs AttrTypesFromFuncs map[FrameworkIdentifier]string // contains filtered or unexported fields }
func NewToFromObject ¶
func NewToFromObject(name string, assocExtType *AssocExtType, attrTypesToFuncs map[string]AttrTypesToFuncs, attrTypesFromFuncs map[string]string) ToFromObject
func (ToFromObject) Render ¶
func (o ToFromObject) Render() ([]byte, error)
type ToFromSet ¶ added in v0.3.0
type ToFromSet struct { Name FrameworkIdentifier AssocExtType *AssocExtType ElementTypeType string ElementTypeValue string ElementFrom string // contains filtered or unexported fields }
func NewToFromSet ¶ added in v0.3.0
func NewToFromSet(name string, assocExtType *AssocExtType, elemTypeType, elemTypeValue, elemFrom string) ToFromSet
type ToFromString ¶ added in v0.2.0
type ToFromString struct { Name FrameworkIdentifier AssocExtType *AssocExtType // contains filtered or unexported fields }
func NewToFromString ¶ added in v0.2.0
func NewToFromString(name string, assocExtType *AssocExtType) ToFromString
func (ToFromString) Render ¶ added in v0.2.0
func (o ToFromString) 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 )
type UnimplementedError ¶ added in v0.3.0
type UnimplementedError struct {
// contains filtered or unexported fields
}
UnimplementedError is used to indicate that the operation being performed is not yet implemented. It is primarily used to permit execution of code generation to continue whilst logging any unimplemented operations.
func NewUnimplementedError ¶ added in v0.3.0
func NewUnimplementedError(err error, path ...string) *UnimplementedError
NewUnimplementedError returns an UnimplementedError populated with the supplied error and path.
func (*UnimplementedError) Error ¶ added in v0.3.0
func (e *UnimplementedError) Error() string
Error returns the underlying error string.
func (*UnimplementedError) NestedUnimplementedError ¶ added in v0.3.0
func (e *UnimplementedError) NestedUnimplementedError(parentPath string) *UnimplementedError
NestedUnimplementedError returns an UnimplementedError with a path that includes the supplied parentPath.
func (*UnimplementedError) Path ¶ added in v0.3.0
func (e *UnimplementedError) Path() string
Path returns a dot-separated path.
Source Files
¶
- associated_external_type.go
- attributes.go
- attrtypes.go
- blocks.go
- custom_bool.go
- custom_float64.go
- custom_int64.go
- custom_list.go
- custom_map.go
- custom_nested_object.go
- custom_number.go
- custom_object.go
- custom_set.go
- custom_string.go
- elements.go
- embed.go
- errors.go
- framework_identifier.go
- import.go
- schema.go
- schemas.go
- to_from_bool.go
- to_from_float64.go
- to_from_int64.go
- to_from_list.go
- to_from_map.go
- to_from_nested_object.go
- to_from_number.go
- to_from_object.go
- to_from_set.go
- to_from_string.go
- types.go