schema

package
v0.0.0-...-8e250b1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var BoolFromTemplate string
View Source
var BoolToTemplate string
View Source
var BoolTypeEqualTemplate string
View Source
var BoolTypeStringTemplate string
View Source
var BoolTypeTypableTemplate string
View Source
var BoolTypeTypeTemplate string
View Source
var BoolTypeValueFromBoolTemplate string
View Source
var BoolTypeValueFromTerraformTemplate string
View Source
var BoolTypeValueTypeTemplate string
View Source
var BoolValueEqualTemplate string
View Source
var BoolValueTypeTemplate string
View Source
var BoolValueValuableTemplate string
View Source
var BoolValueValueTemplate string
View Source
var Float64FromTemplate string
View Source
var Float64ToTemplate string
View Source
var Float64TypeEqualTemplate string
View Source
var Float64TypeStringTemplate string
View Source
var Float64TypeTypableTemplate string
View Source
var Float64TypeTypeTemplate string
View Source
var Float64TypeValueFromFloat64Template string
View Source
var Float64TypeValueFromTerraformTemplate string
View Source
var Float64TypeValueTypeTemplate string
View Source
var Float64ValueEqualTemplate string
View Source
var Float64ValueTypeTemplate string
View Source
var Float64ValueValuableTemplate string
View Source
var Float64ValueValueTemplate string
View Source
var Int64FromTemplate string
View Source
var Int64ToTemplate string
View Source
var Int64TypeEqualTemplate string
View Source
var Int64TypeStringTemplate string
View Source
var Int64TypeTypableTemplate string
View Source
var Int64TypeTypeTemplate string
View Source
var Int64TypeValueFromInt64Template string
View Source
var Int64TypeValueFromTerraformTemplate string
View Source
var Int64TypeValueTypeTemplate string
View Source
var Int64ValueEqualTemplate string
View Source
var Int64ValueTypeTemplate string
View Source
var Int64ValueValuableTemplate string
View Source
var Int64ValueValueTemplate string
View Source
var ListFromTemplate string
View Source
var ListToTemplate string
View Source
var ListTypeEqualTemplate string
View Source
var ListTypeStringTemplate string
View Source
var ListTypeTypableTemplate string
View Source
var ListTypeTypeTemplate string
View Source
var ListTypeValueFromListTemplate string
View Source
var ListTypeValueFromTerraformTemplate string
View Source
var ListTypeValueTypeTemplate string
View Source
var ListValueEqualTemplate string
View Source
var ListValueTypeTemplate string
View Source
var ListValueValuableTemplate string
View Source
var ListValueValueTemplate string
View Source
var MapFromTemplate string
View Source
var MapToTemplate string
View Source
var MapTypeEqualTemplate string
View Source
var MapTypeStringTemplate string
View Source
var MapTypeTypableTemplate string
View Source
var MapTypeTypeTemplate string
View Source
var MapTypeValueFromMapTemplate string
View Source
var MapTypeValueFromTerraformTemplate string
View Source
var MapTypeValueTypeTemplate string
View Source
var MapValueEqualTemplate string
View Source
var MapValueTypeTemplate string
View Source
var MapValueValuableTemplate string
View Source
var MapValueValueTemplate string
View Source
var NestedObjectFromTemplate string
View Source
var NestedObjectToTemplate string
View Source
var NestedObjectTypeEqualTemplate string
View Source
var NestedObjectTypeStringTemplate string
View Source
var NestedObjectTypeTypableTemplate string
View Source
var NestedObjectTypeTypeTemplate string
View Source
var NestedObjectTypeValueFromObjectTemplate string
View Source
var NestedObjectTypeValueFromTerraformTemplate string
View Source
var NestedObjectTypeValueMustTemplate string
View Source
var NestedObjectTypeValueNullTemplate string
View Source
var NestedObjectTypeValueTemplate string
View Source
var NestedObjectTypeValueTypeTemplate string
View Source
var NestedObjectTypeValueUnknownTemplate string
View Source
var NestedObjectValueAttributeTypesTemplate string
View Source
var NestedObjectValueEqualTemplate string
View Source
var NestedObjectValueIsNullTemplate string
View Source
var NestedObjectValueIsUnknownTemplate string
View Source
var NestedObjectValueStringTemplate string
View Source
var NestedObjectValueToObjectValueTemplate string
View Source
var NestedObjectValueToTerraformValueTemplate string
View Source
var NestedObjectValueTypeTemplate string
View Source
var NestedObjectValueValuableTemplate string
View Source
var NestedObjectValueValueTemplate string
View Source
var NumberFromTemplate string
View Source
var NumberToTemplate string
View Source
var NumberTypeEqualTemplate string
View Source
var NumberTypeStringTemplate string
View Source
var NumberTypeTypableTemplate string
View Source
var NumberTypeTypeTemplate string
View Source
var NumberTypeValueFromNumberTemplate string
View Source
var NumberTypeValueFromTerraformTemplate string
View Source
var NumberTypeValueTypeTemplate string
View Source
var NumberValueEqualTemplate string
View Source
var NumberValueTypeTemplate string
View Source
var NumberValueValuableTemplate string
View Source
var NumberValueValueTemplate string
View Source
var ObjectFromTemplate string
View Source
var ObjectToTemplate string
View Source
var ObjectTypeEqualTemplate string
View Source
var ObjectTypeStringTemplate string
View Source
var ObjectTypeTypableTemplate string
View Source
var ObjectTypeTypeTemplate string
View Source
var ObjectTypeValueFromObjectTemplate string
View Source
var ObjectTypeValueFromTerraformTemplate string
View Source
var ObjectTypeValueTypeTemplate string
View Source
var ObjectValueAttributeTypesTemplate string
View Source
var ObjectValueEqualTemplate string
View Source
var ObjectValueTypeTemplate string
View Source
var ObjectValueValuableTemplate string
View Source
var ObjectValueValueTemplate string
View Source
var SchemaGoTemplate string
View Source
var SetFromTemplate string
View Source
var SetToTemplate string
View Source
var SetTypeEqualTemplate string
View Source
var SetTypeStringTemplate string
View Source
var SetTypeTypableTemplate string
View Source
var SetTypeTypeTemplate string
View Source
var SetTypeValueFromSetTemplate string
View Source
var SetTypeValueFromTerraformTemplate string
View Source
var SetTypeValueTypeTemplate string
View Source
var SetValueEqualTemplate string
View Source
var SetValueTypeTemplate string
View Source
var SetValueValuableTemplate string
View Source
var SetValueValueTemplate string
View Source
var StringFromTemplate string
View Source
var StringToTemplate string
View Source
var StringTypeEqualTemplate string
View Source
var StringTypeStringTemplate string
View Source
var StringTypeTypableTemplate string
View Source
var StringTypeTypeTemplate string
View Source
var StringTypeValueFromStringTemplate string
View Source
var StringTypeValueFromTerraformTemplate string
View Source
var StringTypeValueTypeTemplate string
View Source
var StringValueEqualTemplate string
View Source
var StringValueTypeTemplate string
View Source
var StringValueValuableTemplate string
View Source
var StringValueValueTemplate string

Functions

func AttrTypesString

func AttrTypesString(attrTypes specschema.ObjectAttributeTypes) (string, error)

func ElementTypeGoType

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

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

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

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

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

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

type AttrType interface {
	AttrType(FrameworkIdentifier) (string, error)
}

type AttrTypesToFuncs

type AttrTypesToFuncs struct {
	AttrValue string
	ToFunc    string
}

type AttrValue

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

type CollectionFields struct {
	ElementType   string
	GoType        string
	TypeValueFrom string
}

type CollectionType

type CollectionType interface {
	CollectionType() (map[string]string, error)
}

type CustomBoolType

type CustomBoolType struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomBoolType

func NewCustomBoolType(name string) CustomBoolType

func (CustomBoolType) Render

func (c CustomBoolType) Render() ([]byte, error)

type CustomBoolValue

type CustomBoolValue struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomBoolValue

func NewCustomBoolValue(name string) CustomBoolValue

func (CustomBoolValue) Render

func (c CustomBoolValue) Render() ([]byte, error)

type CustomFloat64Type

type CustomFloat64Type struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomFloat64Type

func NewCustomFloat64Type(name string) CustomFloat64Type

func (CustomFloat64Type) Render

func (c CustomFloat64Type) Render() ([]byte, error)

type CustomFloat64Value

type CustomFloat64Value struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomFloat64Value

func NewCustomFloat64Value(name string) CustomFloat64Value

func (CustomFloat64Value) Render

func (c CustomFloat64Value) Render() ([]byte, error)

type CustomInt64Type

type CustomInt64Type struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomInt64Type

func NewCustomInt64Type(name string) CustomInt64Type

func (CustomInt64Type) Render

func (c CustomInt64Type) Render() ([]byte, error)

type CustomInt64Value

type CustomInt64Value struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomInt64Value

func NewCustomInt64Value(name string) CustomInt64Value

func (CustomInt64Value) Render

func (c CustomInt64Value) Render() ([]byte, error)

type CustomListType

type CustomListType struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomListType

func NewCustomListType(name string) CustomListType

func (CustomListType) Render

func (c CustomListType) Render() ([]byte, error)

type CustomListValue

type CustomListValue struct {
	Name        FrameworkIdentifier
	ElementType string
	// contains filtered or unexported fields
}

func NewCustomListValue

func NewCustomListValue(name, elemType string) CustomListValue

func (CustomListValue) Render

func (c CustomListValue) Render() ([]byte, error)

type CustomMapType

type CustomMapType struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomMapType

func NewCustomMapType(name string) CustomMapType

func (CustomMapType) Render

func (c CustomMapType) Render() ([]byte, error)

type CustomMapValue

type CustomMapValue struct {
	Name        FrameworkIdentifier
	ElementType string
	// contains filtered or unexported fields
}

func NewCustomMapValue

func NewCustomMapValue(name, elemType string) CustomMapValue

func (CustomMapValue) Render

func (c CustomMapValue) Render() ([]byte, error)

type CustomNestedObjectType

type CustomNestedObjectType struct {
	Name       FrameworkIdentifier
	AttrValues map[FrameworkIdentifier]string
	// contains filtered or unexported fields
}

func NewCustomNestedObjectType

func NewCustomNestedObjectType(name string, attrValues map[string]string) CustomNestedObjectType

func (CustomNestedObjectType) Render

func (c CustomNestedObjectType) Render() ([]byte, error)

type CustomNestedObjectValue

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

func NewCustomNestedObjectValue(name string, attributeTypes, attrTypes, attrValues map[string]string, collectionTypes map[string]map[string]string) CustomNestedObjectValue

func (CustomNestedObjectValue) Render

func (c CustomNestedObjectValue) Render() ([]byte, error)

type CustomNumberType

type CustomNumberType struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomNumberType

func NewCustomNumberType(name string) CustomNumberType

func (CustomNumberType) Render

func (c CustomNumberType) Render() ([]byte, error)

type CustomNumberValue

type CustomNumberValue struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomNumberValue

func NewCustomNumberValue(name string) CustomNumberValue

func (CustomNumberValue) Render

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

type CustomSetType struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomSetType

func NewCustomSetType(name string) CustomSetType

func (CustomSetType) Render

func (c CustomSetType) Render() ([]byte, error)

type CustomSetValue

type CustomSetValue struct {
	Name        FrameworkIdentifier
	ElementType string
	// contains filtered or unexported fields
}

func NewCustomSetValue

func NewCustomSetValue(name, elemType string) CustomSetValue

func (CustomSetValue) Render

func (c CustomSetValue) Render() ([]byte, error)

type CustomStringType

type CustomStringType struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomStringType

func NewCustomStringType(name string) CustomStringType

func (CustomStringType) Render

func (c CustomStringType) Render() ([]byte, error)

type CustomStringValue

type CustomStringValue struct {
	Name FrameworkIdentifier
	// contains filtered or unexported fields
}

func NewCustomStringValue

func NewCustomStringValue(name string) CustomStringValue

func (CustomStringValue) Render

func (c CustomStringValue) Render() ([]byte, error)

type CustomTypeAndValue

type CustomTypeAndValue interface {
	CustomTypeAndValue(name string) ([]byte, error)
}

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

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

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

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

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

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

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

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

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) Models

func (g GeneratorSchema) Models(name string) ([]model.Model, error)

func (GeneratorSchema) Schema

func (g GeneratorSchema) Schema(name, packageName, generatorType string) ([]byte, error)

func (GeneratorSchema) ToFromFunctions

func (g GeneratorSchema) ToFromFunctions(ctx context.Context, logger *slog.Logger) ([]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) Models

func (g GeneratorSchemas) Models() (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(ctx context.Context, logger *slog.Logger) (map[string][]byte, error)

type Imports

type Imports struct {
	// contains filtered or unexported fields
}

func AssociatedExternalTypeImports

func AssociatedExternalTypeImports() *Imports

func AttrImports

func AttrImports() *Imports

func NewImports

func NewImports() *Imports

func (*Imports) Add

func (i *Imports) Add(c ...code.Import)

func (*Imports) All

func (i *Imports) All() []code.Import

func (*Imports) Append

func (i *Imports) Append(imps ...*Imports)

type ObjectField

type ObjectField struct {
	FromFunc string
	GoType   string
	Type     string
	ToFunc   string
}

type To

type To interface {
	To() (ToFromConversion, error)
}

type ToFrom

type ToFrom interface {
	ToFromFunctions(name string) ([]byte, error)
}

type ToFromBool

type ToFromBool struct {
	Name         FrameworkIdentifier
	AssocExtType *AssocExtType
	// contains filtered or unexported fields
}

func NewToFromBool

func NewToFromBool(name string, assocExtType *AssocExtType) ToFromBool

func (ToFromBool) Render

func (o ToFromBool) Render() ([]byte, error)

type ToFromConversion

type ToFromConversion struct {
	Default        string
	AssocExtType   *AssocExtType
	CollectionType CollectionFields
	ObjectType     map[FrameworkIdentifier]ObjectField
}

type ToFromFloat64

type ToFromFloat64 struct {
	Name         FrameworkIdentifier
	AssocExtType *AssocExtType
	// contains filtered or unexported fields
}

func NewToFromFloat64

func NewToFromFloat64(name string, assocExtType *AssocExtType) ToFromFloat64

func (ToFromFloat64) Render

func (o ToFromFloat64) Render() ([]byte, error)

type ToFromInt64

type ToFromInt64 struct {
	Name         FrameworkIdentifier
	AssocExtType *AssocExtType
	// contains filtered or unexported fields
}

func NewToFromInt64

func NewToFromInt64(name string, assocExtType *AssocExtType) ToFromInt64

func (ToFromInt64) Render

func (o ToFromInt64) Render() ([]byte, error)

type ToFromList

type ToFromList struct {
	Name             FrameworkIdentifier
	AssocExtType     *AssocExtType
	ElementTypeType  string
	ElementTypeValue string
	ElementFrom      string
	// contains filtered or unexported fields
}

func NewToFromList

func NewToFromList(name string, assocExtType *AssocExtType, elemTypeType, elemTypeValue, elemFrom string) ToFromList

func (ToFromList) Render

func (o ToFromList) Render() ([]byte, error)

type ToFromMap

type ToFromMap struct {
	Name             FrameworkIdentifier
	AssocExtType     *AssocExtType
	ElementTypeType  string
	ElementTypeValue string
	ElementFrom      string
	// contains filtered or unexported fields
}

func NewToFromMap

func NewToFromMap(name string, assocExtType *AssocExtType, elemTypeType, elemTypeValue, elemFrom string) ToFromMap

func (ToFromMap) Render

func (o ToFromMap) Render() ([]byte, error)

type ToFromNestedObject

type ToFromNestedObject struct {
	Name         FrameworkIdentifier
	AssocExtType *AssocExtType
	ToFuncs      map[FrameworkIdentifier]ToFromConversion
	FromFuncs    map[FrameworkIdentifier]ToFromConversion
	// contains filtered or unexported fields
}

func NewToFromNestedObject

func NewToFromNestedObject(name string, assocExtType *AssocExtType, toFuncs, fromFuncs map[string]ToFromConversion) ToFromNestedObject

func (ToFromNestedObject) Render

func (o ToFromNestedObject) Render() ([]byte, error)

type ToFromNumber

type ToFromNumber struct {
	Name         FrameworkIdentifier
	AssocExtType *AssocExtType
	// contains filtered or unexported fields
}

func NewToFromNumber

func NewToFromNumber(name string, assocExtType *AssocExtType) ToFromNumber

func (ToFromNumber) Render

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

type ToFromSet struct {
	Name             FrameworkIdentifier
	AssocExtType     *AssocExtType
	ElementTypeType  string
	ElementTypeValue string
	ElementFrom      string
	// contains filtered or unexported fields
}

func NewToFromSet

func NewToFromSet(name string, assocExtType *AssocExtType, elemTypeType, elemTypeValue, elemFrom string) ToFromSet

func (ToFromSet) Render

func (o ToFromSet) Render() ([]byte, error)

type ToFromString

type ToFromString struct {
	Name         FrameworkIdentifier
	AssocExtType *AssocExtType
	// contains filtered or unexported fields
}

func NewToFromString

func NewToFromString(name string, assocExtType *AssocExtType) ToFromString

func (ToFromString) Render

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

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

func NewUnimplementedError(err error, path ...string) *UnimplementedError

NewUnimplementedError returns an UnimplementedError populated with the supplied error and path.

func (*UnimplementedError) Error

func (e *UnimplementedError) Error() string

Error returns the underlying error string.

func (*UnimplementedError) NestedUnimplementedError

func (e *UnimplementedError) NestedUnimplementedError(parentPath string) *UnimplementedError

NestedUnimplementedError returns an UnimplementedError with a path that includes the supplied parentPath.

func (*UnimplementedError) Path

func (e *UnimplementedError) Path() string

Path returns a dot-separated path.

Jump to

Keyboard shortcuts

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