schema

package
v0.0.0-...-9d70a79 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Pattern for schema attribute names
	AttributeNameRegexpPattern = `^[a-z0-9_]+$`

	// Pattern for schema references to attributes, such as ConflictsWith values
	AttributeReferenceRegexpPattern = `^[a-z0-9_]+(\.[a-z0-9_]+)*$`
)
View Source
const (
	FuncNameImportStatePassthrough = `ImportStatePassthrough`
	FuncNameNoop                   = `Noop`
)
View Source
const (
	PackageModule     = terraformtype.ModuleTerraformPluginSdk
	PackageModulePath = `helper/schema`
	PackageName       = `schema`
	PackagePath       = PackageModule + `/` + PackageModulePath
)
View Source
const (
	ProviderFieldConfigureFunc    = `ConfigureFunc`
	ProviderFieldDataSourcesMap   = `DataSourcesMap`
	ProviderFieldMetaReset        = `MetaReset`
	ProviderFieldResourcesMap     = `ResourcesMap`
	ProviderFieldSchema           = `Schema`
	ProviderFieldTerraformVersion = `TerraformVersion`

	TypeNameProvider = `Provider`
)
View Source
const (
	ResourceFieldCreate               = `Create`
	ResourceFieldCreateContext        = `CreateContext`
	ResourceFieldCreateWithoutTimeout = `CreateWithoutTimeout`
	ResourceFieldCustomizeDiff        = `CustomizeDiff`
	ResourceFieldDelete               = `Delete`
	ResourceFieldDeleteContext        = `DeleteContext`
	ResourceFieldDeleteWithoutTimeout = `DeleteWithoutTimeout`
	ResourceFieldDeprecationMessage   = `DeprecationMessage`
	ResourceFieldDescription          = `Description`
	ResourceFieldExists               = `Exists`
	ResourceFieldImporter             = `Importer`
	ResourceFieldMigrateState         = `MigrateState`
	ResourceFieldRead                 = `Read`
	ResourceFieldReadContext          = `ReadContext`
	ResourceFieldReadWithoutTimeout   = `ReadWithoutTimeout`
	ResourceFieldSchema               = `Schema`
	ResourceFieldSchemaVersion        = `SchemaVersion`
	ResourceFieldStateUpgraders       = `StateUpgraders`
	ResourceFieldTimeouts             = `Timeouts`
	ResourceFieldUpdate               = `Update`
	ResourceFieldUpdateContext        = `UpdateContext`
	ResourceFieldUpdateWithoutTimeout = `UpdateWithoutTimeout`

	TypeNameResource = `Resource`
)
View Source
const (
	ResourceTimeoutTypeCreateField  = `Create`
	ResourceTimeoutTypeDefaultField = `Default`
	ResourceTimeoutTypeDeleteField  = `Delete`
	ResourceTimeoutTypeReadField    = `Read`
	ResourceTimeoutTypeUpdateField  = `Update`
)
View Source
const (
	SchemaFieldAtLeastOneOf     = `AtLeastOneOf`
	SchemaFieldComputed         = `Computed`
	SchemaFieldComputedWhen     = `ComputedWhen`
	SchemaFieldConfigMode       = `ConfigMode`
	SchemaFieldConflictsWith    = `ConflictsWith`
	SchemaFieldDefault          = `Default`
	SchemaFieldDefaultFunc      = `DefaultFunc`
	SchemaFieldDeprecated       = `Deprecated`
	SchemaFieldDescription      = `Description`
	SchemaFieldDiffSuppressFunc = `DiffSuppressFunc`
	SchemaFieldElem             = `Elem`
	SchemaFieldExactlyOneOf     = `ExactlyOneOf`
	SchemaFieldForceNew         = `ForceNew`
	SchemaFieldInputDefault     = `InputDefault`
	SchemaFieldMaxItems         = `MaxItems`
	SchemaFieldMinItems         = `MinItems`
	SchemaFieldOptional         = `Optional`
	SchemaFieldPromoteSingle    = `PromoteSingle`
	SchemaFieldRemoved          = `Removed`
	SchemaFieldRequired         = `Required`
	SchemaFieldSensitive        = `Sensitive`
	SchemaFieldSet              = `Set`
	SchemaFieldStateFunc        = `StateFunc`
	SchemaFieldType             = `Type`
	SchemaFieldValidateFunc     = `ValidateFunc`

	SchemaValueTypeBool   = `TypeBool`
	SchemaValueTypeFloat  = `TypeFloat`
	SchemaValueTypeInt    = `TypeInt`
	SchemaValueTypeList   = `TypeList`
	SchemaValueTypeMap    = `TypeMap`
	SchemaValueTypeSet    = `TypeSet`
	SchemaValueTypeString = `TypeString`

	TypeNameSchema    = `Schema`
	TypeNameSet       = `Set`
	TypeNameValueType = `ValueType`
)
View Source
const (
	TypeNameCustomizeDiffFunc = `CustomizeDiffFunc`
)
View Source
const (
	TypeNameResourceData = `ResourceData`
)
View Source
const (
	TypeNameResourceDiff = `ResourceDiff`
)
View Source
const (
	TypeNameStateUpgradeFunc = `StateUpgradeFunc`
)

Variables

Functions

func GetResourceMapResourceNames

func GetResourceMapResourceNames(cl *ast.CompositeLit) []ast.Expr

GetResourceMapResourceNames returns all resource names held in a map[string]*schema.Resource

func GetSchemaMapAttributeNames

func GetSchemaMapAttributeNames(cl *ast.CompositeLit) []ast.Expr

GetSchemaMapAttributeNames returns all attribute names held in a map[string]*schema.Schema

func GetSchemaMapSchemas

func GetSchemaMapSchemas(cl *ast.CompositeLit) []*ast.CompositeLit

GetSchemaMapSchemas returns all Schema held in a map[string]*schema.Schema

func IsFunc

func IsFunc(e ast.Expr, info *types.Info, funcName string) bool

IsFunc returns if the function call is in the package

func IsFuncTypeCRUDFunc

func IsFuncTypeCRUDFunc(node ast.Node, info *types.Info) bool

IsFuncTypeCRUDFunc returns true if the FuncType matches expected parameters and results types

func IsFuncTypeCustomizeDiffFunc

func IsFuncTypeCustomizeDiffFunc(node ast.Node, info *types.Info) bool

IsFuncTypeCustomizeDiffFunc returns true if the FuncType matches expected parameters and results types

func IsFuncTypeStateUpgradeFunc

func IsFuncTypeStateUpgradeFunc(node ast.Node, info *types.Info) bool

IsFuncTypeStateUpgradeFunc returns true if the FuncType matches expected parameters and results types

func IsMapStringResource

func IsMapStringResource(cl *ast.CompositeLit, info *types.Info) bool

IsMapStringResource returns if the type is map[string]*Resource from the helper/schema package

func IsMapStringSchema

func IsMapStringSchema(cl *ast.CompositeLit, info *types.Info) bool

IsMapStringSchema returns if the type is map[string]*Schema from the helper/schema package

func IsNamedType

func IsNamedType(t *types.Named, typeName string) bool

IsNamedType returns if the type name matches and is from the package

func IsReceiverMethod

func IsReceiverMethod(e ast.Expr, info *types.Info, receiverName string, methodName string) bool

IsReceiverMethod returns if the receiver method call is in the package

func IsTypeCustomizeDiffFunc

func IsTypeCustomizeDiffFunc(t types.Type) bool

IsTypeCustomizeDiffFunc returns if the type is CustomizeDiffFunc from the customdiff package

func IsTypeProvider

func IsTypeProvider(t types.Type) bool

IsTypeProvider returns if the type is Provider from the schema package

func IsTypeResource

func IsTypeResource(t types.Type) bool

IsTypeResource returns if the type is Resource from the helper/schema package

func IsTypeResourceData

func IsTypeResourceData(t types.Type) bool

IsTypeResourceData returns if the type is ResourceData from the helper/schema package

func IsTypeResourceDiff

func IsTypeResourceDiff(t types.Type) bool

IsTypeResourceDiff returns if the type is ResourceDiff from the schema package

func IsTypeSchema

func IsTypeSchema(t types.Type) bool

IsTypeSchema returns if the type is Schema from the helper/schema package

func IsTypeSet

func IsTypeSet(t types.Type) bool

IsTypeSet returns if the type is Set from the helper/schema package Use IsTypeSchemaFieldType for verifying Type: schema.TypeSet ValueType

func IsTypeStateUpgradeFunc

func IsTypeStateUpgradeFunc(t types.Type) bool

IsTypeStateUpgradeFunc returns if the type is StateUpgradeFunc from the schema package

func IsValueType

func IsValueType(e ast.Expr, info *types.Info) bool

IsValueType returns if the Schema field Type matches

func PackagePathVersion

func PackagePathVersion(moduleVersion int) string

PackagePathVersion returns the import path for a module version

func ParseAttributeReference

func ParseAttributeReference(reference string) ([]string, error)

ParseAttributeReference validates and returns the split representation of schema attribute reference. Attribute references are used in Schema fields such as AtLeastOneOf, ConflictsWith, and ExactlyOneOf.

func ValueType

func ValueType(e ast.Expr, info *types.Info) valueType

ValueType returns the schema value type

Types

type CRUDFuncInfo

type CRUDFuncInfo struct {
	AstFuncDecl *ast.FuncDecl
	AstFuncLit  *ast.FuncLit
	Body        *ast.BlockStmt
	Node        ast.Node
	Pos         token.Pos
	Type        *ast.FuncType
	TypesInfo   *types.Info
}

CRUDFuncInfo represents all gathered CreateContext, ReadContext, UpdateContext, and DeleteContext data for easier access Since Create, Delete, Read, and Update functions all have the same function signature, we cannot differentiate them in AST (except by potentially by function declaration naming heuristics later on).

func NewCRUDFuncInfo

func NewCRUDFuncInfo(node ast.Node, info *types.Info) *CRUDFuncInfo

NewCRUDFuncInfo instantiates a CRUDFuncInfo

type CustomizeDiffFuncInfo

type CustomizeDiffFuncInfo struct {
	AstFuncDecl *ast.FuncDecl
	AstFuncLit  *ast.FuncLit
	Body        *ast.BlockStmt
	Node        ast.Node
	Pos         token.Pos
	Type        *ast.FuncType
	TypesInfo   *types.Info
}

CustomizeDiffFuncInfo represents all gathered CustomizeDiffFunc data for easier access

func NewCustomizeDiffFuncInfo

func NewCustomizeDiffFuncInfo(node ast.Node, info *types.Info) *CustomizeDiffFuncInfo

NewCustomizeDiffFuncInfo instantiates a CustomizeDiffFuncInfo

type ResourceInfo

type ResourceInfo struct {
	AstCompositeLit *ast.CompositeLit
	Fields          map[string]*ast.KeyValueExpr
	Resource        *resourceType
	TypesInfo       *types.Info
}

ResourceInfo represents all gathered Resource data for easier access

func NewResourceInfo

func NewResourceInfo(cl *ast.CompositeLit, info *types.Info) *ResourceInfo

NewResourceInfo instantiates a ResourceInfo

func (*ResourceInfo) DeclaresField

func (info *ResourceInfo) DeclaresField(fieldName string) bool

DeclaresField returns true if the field name is present in the AST

func (*ResourceInfo) IsDataSource

func (info *ResourceInfo) IsDataSource() bool

IsDataSource returns true if the Resource type matches a Terraform Data Source declaration

func (*ResourceInfo) IsResource

func (info *ResourceInfo) IsResource() bool

IsResource returns true if the Resource type matches a Terraform Resource declaration

type SchemaInfo

type SchemaInfo struct {
	AstCompositeLit *ast.CompositeLit
	Fields          map[string]*ast.KeyValueExpr
	Schema          *schemaType
	SchemaValueType string
	TypesInfo       *types.Info
}

SchemaInfo represents all gathered Schema data for easier access

func NewSchemaInfo

func NewSchemaInfo(cl *ast.CompositeLit, info *types.Info) *SchemaInfo

NewSchemaInfo instantiates a SchemaInfo

func (*SchemaInfo) DeclaresBoolFieldWithZeroValue

func (info *SchemaInfo) DeclaresBoolFieldWithZeroValue(fieldName string) bool

DeclaresBoolFieldWithZeroValue returns true if the field name is present and is false

func (*SchemaInfo) DeclaresField

func (info *SchemaInfo) DeclaresField(fieldName string) bool

DeclaresField returns true if the field name is present in the AST

func (*SchemaInfo) IsOneOfTypes

func (info *SchemaInfo) IsOneOfTypes(valueTypes ...string) bool

IsOneOfTypes returns true if one of the given input is equal to the Type

func (*SchemaInfo) IsType

func (info *SchemaInfo) IsType(valueType string) bool

IsType returns true if the given input is equal to the Type

type SchemaValidateFuncInfo

type SchemaValidateFuncInfo struct {
	AstFuncDecl *ast.FuncDecl
	AstFuncLit  *ast.FuncLit
	Body        *ast.BlockStmt
	Node        ast.Node
	Pos         token.Pos
	Type        *ast.FuncType
	TypesInfo   *types.Info
}

SchemaValidateFuncInfo represents all gathered SchemaValidateFunc data for easier access

func NewSchemaValidateFuncInfo

func NewSchemaValidateFuncInfo(node ast.Node, info *types.Info) *SchemaValidateFuncInfo

NewSchemaValidateFuncInfo instantiates a SchemaValidateFuncInfo

type StateUpgradeFuncInfo

type StateUpgradeFuncInfo struct {
	AstFuncDecl *ast.FuncDecl
	AstFuncLit  *ast.FuncLit
	Body        *ast.BlockStmt
	Node        ast.Node
	Pos         token.Pos
	Type        *ast.FuncType
	TypesInfo   *types.Info
}

StateUpgradeFuncInfo represents all gathered StateUpgradeFunc data for easier access

func NewStateUpgradeFuncInfo

func NewStateUpgradeFuncInfo(node ast.Node, info *types.Info) *StateUpgradeFuncInfo

NewStateUpgradeFuncInfo instantiates a StateUpgradeFuncInfo

Jump to

Keyboard shortcuts

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