Documentation
¶
Overview ¶
Package schema defines a data model for structured merges and diffs.
Index ¶
Constants ¶
const ( Numeric = Scalar("numeric") String = Scalar("string") Boolean = Scalar("boolean") )
const ( Associative = ListElementRelationship("associative") Atomic = ListElementRelationship("atomic") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Atom ¶
type Atom struct { // Exactly one of the below must be set. *Scalar `yaml:"scalar,omitempty"` *Struct `yaml:"struct,omitempty"` *List `yaml:"list,omitempty"` *Map `yaml:"map,omitempty"` *Untyped `yaml:"untyped,omitempty"` }
Atom represents the smallest possible pieces of the type system.
type List ¶
type List struct { ElementType TypeRef `yaml:"elementType,omitempty"` // ElementRelationship states the relationship between the list's elements // and must have one of these values: // * Atomic: the list is treated as a single entity, like a scalar. // * Associative: // - If the list element is a scalar, the list is treated as a set. // - If the list element is a struct, the list is treated as a map. // - The list element must not be a map or a list itself. ElementRelationship ListElementRelationship `yaml:"elementRelationship,omitempty"` // Iff ElementRelationship is Associative, and the element type is // struct, then Keys must have non-zero length, and it lists the fields // of the element's struct type which are to be used as the keys of the // list. // // Each key must refer to a single field name (no nesting, not JSONPath). Keys []string `yaml:"keys,omitempty"` }
List has zero or more elements of some type.
type ListElementRelationship ¶
type ListElementRelationship string
ListElementRelationship is an enum of the different possible relationships between list elements.
type Map ¶
type Map struct { ElementType TypeRef `yaml:"elementType,omitempty"` // Atomic maps must not have individual items merged. Atomic bool `yaml:"atomic,omitempty"` }
Map is a key-value pair. Its semantics are the same as an associative list, but:
- It is serialized differently: map: {"k": {"value": "v"}} list: [{"key": "k", "value": "v"}]
- Keys must be string typed.
- Keys can't have multiple components.
type Scalar ¶
type Scalar string
Scalar (AKA "primitive") has a single value which is either numeric, string, or boolean.
type Schema ¶
type Schema struct {
Types []TypeDef `yaml:"types,omitempty"`
}
Schema is a list of types.
func (Schema) FindNamedType ¶
FindNamedType returns the referenced TypeDef, if it exists, or (nil, false) if it doesn't.
type Struct ¶
type Struct struct { // Each struct field appears exactly once in this list. The order in // this list defines the canonical field ordering. Fields []StructField `yaml:"fields,omitempty"` }
Struct is a list of fields. Each field has a name and a type. Some fields may be grouped into unions.
type StructField ¶
type StructField struct { // Name is the field name. Name string `yaml:"name,omitempty"` // Type is the field type. Type TypeRef `yaml:"type,omitempty"` }
StructField pairs a field name with a field type.
type TypeDef ¶
type TypeDef struct { // Top level types should be named. Every type must have a unique name. Name string `yaml:"name,omitempty"` Atom `yaml:"atom,omitempty,inline"` }
TypeDef represents a node in a schema.
type TypeRef ¶
type TypeRef struct { // Either the name or one member of Atom should be set. NamedType *string `yaml:"namedType,omitempty"` Inlined Atom `yaml:"inlined,inline,omitempty"` }
TypeRef either refers to a named type or declares an inlined type.
type TypeSpecifier ¶
type TypeSpecifier struct { Type TypeRef `yaml:"type,omitempty"` Schema Schema `yaml:"schema,omitempty"` }
A TypeSpecifier references a particular type in a schema.