Documentation ¶
Overview ¶
Package typeexpr extends HCL with a convention for describing HCL types within configuration files.
The type syntax is processed statically from a hcl.Expression, so it cannot use any of the usual language operators. This is similar to type expressions in statically-typed programming languages.
variable "example" { type = list(string) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Type ¶
func Type(expr hcl.Expression) (cty.Type, hcl.Diagnostics)
Type attempts to process the given expression as a type expression and, if successful, returns the resulting type. If unsuccessful, error diagnostics are returned.
func TypeConstraint ¶
func TypeConstraint(expr hcl.Expression) (cty.Type, hcl.Diagnostics)
TypeConstraint attempts to parse the given expression as a type constraint and, if successful, returns the resulting type. If unsuccessful, error diagnostics are returned.
A type constraint has the same structure as a type, but it additionally allows the keyword "any" to represent cty.DynamicPseudoType, which is often used as a wildcard in type checking and type conversion operations.
func TypeString ¶
TypeString returns a string rendering of the given type as it would be expected to appear in the HCL native syntax.
This is primarily intended for showing types to the user in an application that uses typexpr, where the user can be assumed to be familiar with the type expression syntax. In applications that do not use typeexpr these results may be confusing to the user and so type.FriendlyName may be preferable, even though it's less precise.
TypeString produces reasonable results only for types like what would be produced by the Type and TypeConstraint functions. In particular, it cannot support capsule types.
Types ¶
This section is empty.