Documentation ¶
Index ¶
- Constants
- Variables
- func GetResourceMapResourceNames(cl *ast.CompositeLit) []ast.Expr
- func GetSchemaMapAttributeNames(cl *ast.CompositeLit) []ast.Expr
- func GetSchemaMapSchemas(cl *ast.CompositeLit) []*ast.CompositeLit
- func IsFunc(e ast.Expr, info *types.Info, funcName string) bool
- func IsFuncTypeCustomizeDiffFunc(node ast.Node, info *types.Info) bool
- func IsFuncTypeStateUpgradeFunc(node ast.Node, info *types.Info) bool
- func IsMapStringResource(cl *ast.CompositeLit, info *types.Info) bool
- func IsMapStringSchema(cl *ast.CompositeLit, info *types.Info) bool
- func IsNamedType(t *types.Named, typeName string) bool
- func IsReceiverMethod(e ast.Expr, info *types.Info, receiverName string, methodName string) bool
- func IsTypeCustomizeDiffFunc(t types.Type) bool
- func IsTypeProvider(t types.Type) bool
- func IsTypeResource(t types.Type) bool
- func IsTypeResourceData(t types.Type) bool
- func IsTypeResourceDiff(t types.Type) bool
- func IsTypeSchema(t types.Type) bool
- func IsTypeSet(t types.Type) bool
- func IsTypeStateUpgradeFunc(t types.Type) bool
- func IsValueType(e ast.Expr, info *types.Info) bool
- func PackagePathVersion(moduleVersion int) string
- func ParseAttributeReference(reference string) ([]string, error)
- func ValueType(e ast.Expr, info *types.Info) valueType
- type CRUDFuncInfo
- type CustomizeDiffFuncInfo
- type ResourceInfo
- type SchemaInfo
- type SchemaValidateFuncInfo
- type StateUpgradeFuncInfo
Constants ¶
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_]+)*$` )
const ( FuncNameImportStatePassthrough = `ImportStatePassthrough` FuncNameNoop = `Noop` )
const ( PackageModule = terraformtype.ModuleTerraformPluginSdk PackageModulePath = `helper/schema` PackageName = `schema` PackagePath = PackageModule + `/` + PackageModulePath )
const ( ProviderFieldConfigureFunc = `ConfigureFunc` ProviderFieldDataSourcesMap = `DataSourcesMap` ProviderFieldMetaReset = `MetaReset` ProviderFieldResourcesMap = `ResourcesMap` ProviderFieldSchema = `Schema` ProviderFieldTerraformVersion = `TerraformVersion` TypeNameProvider = `Provider` )
const ( ResourceFieldCreate = `Create` ResourceFieldCustomizeDiff = `CustomizeDiff` ResourceFieldDelete = `Delete` ResourceFieldDeprecationMessage = `DeprecationMessage` ResourceFieldDescription = `Description` ResourceFieldExists = `Exists` ResourceFieldImporter = `Importer` ResourceFieldMigrateState = `MigrateState` ResourceFieldRead = `Read` ResourceFieldSchema = `Schema` ResourceFieldSchemaVersion = `SchemaVersion` ResourceFieldStateUpgraders = `StateUpgraders` ResourceFieldTimeouts = `Timeouts` ResourceFieldUpdate = `Update` TypeNameResource = `Resource` )
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` )
const (
TypeNameCustomizeDiffFunc = `CustomizeDiffFunc`
)
const (
TypeNameResourceData = `ResourceData`
)
const (
TypeNameResourceDiff = `ResourceDiff`
)
const (
TypeNameStateUpgradeFunc = `StateUpgradeFunc`
)
Variables ¶
var ( AttributeNameRegexp = regexp.MustCompile(AttributeNameRegexpPattern) AttributeReferenceRegexp = regexp.MustCompile(AttributeReferenceRegexpPattern) )
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 IsFuncTypeCustomizeDiffFunc ¶ added in v0.13.0
IsFuncTypeCustomizeDiffFunc returns true if the FuncType matches expected parameters and results types
func IsFuncTypeStateUpgradeFunc ¶ added in v0.13.0
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 ¶
IsNamedType returns if the type name matches and is from the package
func IsReceiverMethod ¶
IsReceiverMethod returns if the receiver method call is in the package
func IsTypeCustomizeDiffFunc ¶ added in v0.13.0
IsTypeCustomizeDiffFunc returns if the type is CustomizeDiffFunc from the customdiff package
func IsTypeProvider ¶ added in v0.14.0
IsTypeProvider returns if the type is Provider from the schema package
func IsTypeResource ¶
IsTypeResource returns if the type is Resource from the helper/schema package
func IsTypeResourceData ¶
IsTypeResourceData returns if the type is ResourceData from the helper/schema package
func IsTypeResourceDiff ¶ added in v0.13.0
IsTypeResourceDiff returns if the type is ResourceDiff from the schema package
func IsTypeSchema ¶
IsTypeSchema returns if the type is Schema from the helper/schema package
func IsTypeSet ¶
IsTypeSet returns if the type is Set from the helper/schema package Use IsTypeSchemaFieldType for verifying Type: schema.TypeSet ValueType
func IsTypeStateUpgradeFunc ¶ added in v0.13.0
IsTypeStateUpgradeFunc returns if the type is StateUpgradeFunc from the schema package
func IsValueType ¶
IsValueType returns if the Schema field Type matches
func PackagePathVersion ¶ added in v0.15.0
PackagePathVersion returns the import path for a module version
func ParseAttributeReference ¶ added in v0.12.0
ParseAttributeReference validates and returns the split representation of schema attribute reference. Attribute references are used in Schema fields such as AtLeastOneOf, ConflictsWith, and ExactlyOneOf.
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 CreateFunc, ReadFunc, UpdateFunc, and DeleteFunc 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 ¶ added in v0.13.0
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 ¶ added in v0.13.0
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 ¶ added in v0.13.0
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 ¶ added in v0.13.0
func NewStateUpgradeFuncInfo(node ast.Node, info *types.Info) *StateUpgradeFuncInfo
NewStateUpgradeFuncInfo instantiates a StateUpgradeFuncInfo