Documentation ¶
Index ¶
- Variables
- func AliasTypeSpec(name, dbType string, opts ...TypeSpecOption) *schemaspec.TypeSpec
- func SizeTypeAttr(required bool) *schemaspec.TypeAttr
- func TypeSpec(name string, opts ...TypeSpecOption) *schemaspec.TypeSpec
- type Config
- type EvalFunc
- type Evaluator
- type Option
- type State
- type TypeRegistry
- func (r *TypeRegistry) Convert(typ schema.Type) (*schemaspec.Type, error)
- func (r *TypeRegistry) PrintType(typ *schemaspec.Type) (string, error)
- func (r *TypeRegistry) Register(specs ...*schemaspec.TypeSpec) error
- func (r *TypeRegistry) Specs() []*schemaspec.TypeSpec
- func (r *TypeRegistry) Type(typ *schemaspec.Type, extra []*schemaspec.Attr) (schema.Type, error)
- type TypeRegistryOption
- func WithFormatter(f func(schema.Type) (string, error)) TypeRegistryOption
- func WithParser(parser func(string) (schema.Type, error)) TypeRegistryOption
- func WithSpecFunc(spec func(schema.Type) (*schemaspec.Type, error)) TypeRegistryOption
- func WithSpecs(specs ...*schemaspec.TypeSpec) TypeRegistryOption
- type TypeSpecOption
Constants ¶
This section is empty.
Variables ¶
var ( // Marshal returns the Atlas HCL encoding of v. Marshal = schemaspec.MarshalerFunc(New().MarshalSpec) )
var ( // Unmarshal parses the Atlas HCL-encoded data and stores the result in the target. Unmarshal = schemaspec.UnmarshalerFunc(New().UnmarshalSpec) )
Functions ¶
func AliasTypeSpec ¶ added in v0.3.8
func AliasTypeSpec(name, dbType string, opts ...TypeSpecOption) *schemaspec.TypeSpec
AliasTypeSpec returns a TypeSpec with the provided name.
func SizeTypeAttr ¶ added in v0.3.8
func SizeTypeAttr(required bool) *schemaspec.TypeAttr
SizeTypeAttr returns a TypeAttr for a size attribute.
func TypeSpec ¶ added in v0.3.8
func TypeSpec(name string, opts ...TypeSpecOption) *schemaspec.TypeSpec
TypeSpec returns a TypeSpec with the provided name.
Types ¶
type Config ¶ added in v0.2.0
type Config struct {
// contains filtered or unexported fields
}
Config configures an unmarshaling.
type EvalFunc ¶ added in v0.3.8
EvalFunc is an adapter that allows the use of an ordinary function as an Evaluator.
type Evaluator ¶ added in v0.3.8
Evaluator evaluates the Atlas DDL document with the given input and stores it in the provided object.
type Option ¶ added in v0.2.0
type Option func(*Config)
Option configures a Config.
func WithScopedEnums ¶ added in v0.3.4
WithScopedEnums configured a list of allowed ENUMs to be used in the given context, block or attribute. For example, the following option allows setting HASH or BTREE to the "using" attribute in "index" block.
WithScopedEnums("table.index.type", "HASH", "BTREE") table "t" { ... index "i" { type = HASH // Allowed. type = INVALID // Not Allowed. } }
func WithTypes ¶ added in v0.2.0
func WithTypes(typeSpecs []*schemaspec.TypeSpec) Option
WithTypes configures the list of given types as identifiers in the unmarshaling context.
type State ¶ added in v0.3.8
type State struct {
// contains filtered or unexported fields
}
State implements schemaspec.Unmarshaler and schemaspec.Marshaler for Atlas HCL syntax and stores a configuration for these operations.
func (*State) MarshalSpec ¶ added in v0.3.8
MarshalSpec implements schemaspec.Marshaler for Atlas HCL documents.
func (*State) UnmarshalSpec ¶ added in v0.3.8
UnmarshalSpec implements schemaspec.Unmarshaler.
type TypeRegistry ¶ added in v0.3.8
type TypeRegistry struct {
// contains filtered or unexported fields
}
TypeRegistry is a collection of *schemaspec.TypeSpec.
func NewRegistry ¶ added in v0.3.8
func NewRegistry(opts ...TypeRegistryOption) *TypeRegistry
NewRegistry creates a new *TypeRegistry, registers the provided types and panics if an error occurs.
func (*TypeRegistry) Convert ¶ added in v0.3.8
func (r *TypeRegistry) Convert(typ schema.Type) (*schemaspec.Type, error)
Convert converts the schema.Type to a *schemaspec.Type.
func (*TypeRegistry) PrintType ¶ added in v0.3.8
func (r *TypeRegistry) PrintType(typ *schemaspec.Type) (string, error)
PrintType returns the string representation of a column type which can be parsed by the driver into a schema.Type.
func (*TypeRegistry) Register ¶ added in v0.3.8
func (r *TypeRegistry) Register(specs ...*schemaspec.TypeSpec) error
Register adds one or more TypeSpec to the registry.
func (*TypeRegistry) Specs ¶ added in v0.3.8
func (r *TypeRegistry) Specs() []*schemaspec.TypeSpec
Specs returns the TypeSpecs in the registry.
func (*TypeRegistry) Type ¶ added in v0.3.8
func (r *TypeRegistry) Type(typ *schemaspec.Type, extra []*schemaspec.Attr) (schema.Type, error)
Type converts a *schemaspec.Type into a schema.Type.
type TypeRegistryOption ¶ added in v0.3.8
type TypeRegistryOption func(*TypeRegistry) error
TypeRegistryOption configures a TypeRegistry.
func WithFormatter ¶ added in v0.3.8
func WithFormatter(f func(schema.Type) (string, error)) TypeRegistryOption
WithFormatter configures the registry to use a formatting function for printing schema.Type as string.
func WithParser ¶ added in v0.3.8
func WithParser(parser func(string) (schema.Type, error)) TypeRegistryOption
WithParser configures the registry to use a parsing function for converting a string to a schema.Type.
func WithSpecFunc ¶ added in v0.3.8
func WithSpecFunc(spec func(schema.Type) (*schemaspec.Type, error)) TypeRegistryOption
WithSpecFunc configures the registry to use the given function for converting a schema.Type to schemaspec.Type
func WithSpecs ¶ added in v0.3.8
func WithSpecs(specs ...*schemaspec.TypeSpec) TypeRegistryOption
WithSpecs configures the registry to register the given list of type specs.
type TypeSpecOption ¶ added in v0.3.8
type TypeSpecOption func(*schemaspec.TypeSpec)
TypeSpecOption configures a schemaspec.TypeSpec.
func WithAttributes ¶ added in v0.3.8
func WithAttributes(attrs ...*schemaspec.TypeAttr) TypeSpecOption
WithAttributes returns an attributes TypeSpecOption.
func WithTypeFormatter ¶ added in v0.3.8
func WithTypeFormatter(f func(*schemaspec.Type) (string, error)) TypeSpecOption
WithTypeFormatter allows overriding the Format function for the Type.