tosca

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadFieldModeDefault             = 0
	ReadFieldModeList                = 1
	ReadFieldModeSequencedList       = 2
	ReadFieldModeUniqueSequencedList = 3
	ReadFieldModeItem                = 4
)

Variables

This section is empty.

Functions

func GetCanonicalName

func GetCanonicalName(entityPtr EntityPtr) string

func GetDescription added in v0.13.0

func GetDescription(entityPtr EntityPtr) (string, bool)

From HasMetadata interface

func GetEntityTypeName

func GetEntityTypeName(type_ reflect.Type) string

From "name" tag

func GetInformationMetadata added in v0.15.0

func GetInformationMetadata(metadata map[string]string) map[string]string

func GetKey

func GetKey(entityPtr EntityPtr) string

From Mappable interface

func GetMetadata

func GetMetadata(entityPtr EntityPtr) (map[string]string, bool)

From HasMetadata interface

func SetMetadata added in v0.13.0

func SetMetadata(entityPtr EntityPtr, name string, value string) bool

From HasMetadata interface

func ValidateRequiredFields

func ValidateRequiredFields(entityPtr EntityPtr) bool

From "require" tags

Types

type Context

type Context struct {
	Parent             *Context
	Name               string
	Path               ard.Path
	URL                urlpkg.URL
	Data               ard.Value
	Locator            ard.Locator
	CanonicalNamespace *string
	Namespace          *Namespace
	ScriptletNamespace *ScriptletNamespace
	Hierarchy          *Hierarchy
	Problems           *problems.Problems
	Quirks             Quirks
	Grammar            *Grammar
	ReadTagOverrides   map[string]string
}

func GetContext

func GetContext(entityPtr EntityPtr) *Context

From Contextual interface

func NewContext

func NewContext(stylist *terminal.Stylist, quirks Quirks) *Context

func (*Context) Clone

func (self *Context) Clone(data ard.Value) *Context

func (*Context) EmbedScriptlet

func (self *Context) EmbedScriptlet(name string, scriptlet string)

func (*Context) FieldChild

func (self *Context) FieldChild(name ard.Value, data ard.Value) *Context

func (*Context) FieldChildren

func (self *Context) FieldChildren() []*Context

func (*Context) FormatBadData

func (self *Context) FormatBadData() string

func (*Context) GetAncestor

func (self *Context) GetAncestor(generation int) *Context

func (*Context) GetCanonicalNamespace

func (self *Context) GetCanonicalNamespace() *string

func (*Context) GetFieldChild

func (self *Context) GetFieldChild(name string) (*Context, bool)

func (*Context) GetLocation

func (self *Context) GetLocation() (int, int)

func (*Context) GetRequiredFieldChild

func (self *Context) GetRequiredFieldChild(name string) (*Context, bool)

func (*Context) HasQuirk

func (self *Context) HasQuirk(quirk Quirk) bool

func (*Context) ImportScriptlet

func (self *Context) ImportScriptlet(name string, path string)

func (*Context) Is

func (self *Context) Is(typeNames ...ard.TypeName) bool

func (*Context) ListChild

func (self *Context) ListChild(index int, data ard.Value) *Context

func (*Context) MapChild

func (self *Context) MapChild(name ard.Value, data ard.Value) *Context

func (*Context) NewFunctionCall

func (self *Context) NewFunctionCall(name string, arguments []interface{}) *FunctionCall

func (*Context) NewImportContext

func (self *Context) NewImportContext(url urlpkg.URL) *Context

func (*Context) ReadBoolean

func (self *Context) ReadBoolean() *bool

func (*Context) ReadFields

func (self *Context) ReadFields(entityPtr EntityPtr) []string

From "read" tags

func (*Context) ReadFloat

func (self *Context) ReadFloat() *float64

func (*Context) ReadInteger

func (self *Context) ReadInteger() *int64

func (*Context) ReadListItems

func (self *Context) ReadListItems(read Reader, process Processor) bool

func (*Context) ReadMapItems

func (self *Context) ReadMapItems(read Reader, process Processor) bool

func (*Context) ReadSequencedListItems

func (self *Context) ReadSequencedListItems(read Reader, process Processor) bool

func (*Context) ReadString

func (self *Context) ReadString() *string

func (*Context) ReadStringList

func (self *Context) ReadStringList() *[]string

func (*Context) ReadStringListFixed

func (self *Context) ReadStringListFixed(length int) *[]string

func (*Context) ReadStringMap

func (self *Context) ReadStringMap() *map[string]interface{}

func (*Context) ReadStringOrStringList

func (self *Context) ReadStringOrStringList() *[]string

func (*Context) ReadStringStringMap

func (self *Context) ReadStringStringMap() *map[string]string

func (*Context) Report

func (self *Context) Report(skip int, item string, message string) bool

func (*Context) ReportAspectWrongType added in v0.16.0

func (self *Context) ReportAspectWrongType(aspect string, value ard.Value, allowedTypeNames ...ard.TypeName) bool

func (*Context) ReportCopyLoop

func (self *Context) ReportCopyLoop(name string) bool

func (*Context) ReportDuplicateMapKey added in v0.13.0

func (self *Context) ReportDuplicateMapKey(key string) bool

func (*Context) ReportError

func (self *Context) ReportError(err error) bool

func (*Context) ReportFieldMalformedSequencedList

func (self *Context) ReportFieldMalformedSequencedList() bool

func (*Context) ReportFieldMissing

func (self *Context) ReportFieldMissing() bool

func (*Context) ReportFieldReferenceNotFound

func (self *Context) ReportFieldReferenceNotFound(types ...reflect.Type) bool

func (*Context) ReportFieldUnsupported

func (self *Context) ReportFieldUnsupported() bool

func (*Context) ReportFieldUnsupportedValue

func (self *Context) ReportFieldUnsupportedValue() bool

func (*Context) ReportImportIncompatible

func (self *Context) ReportImportIncompatible(url urlpkg.URL) bool

func (*Context) ReportImportLoop

func (self *Context) ReportImportLoop(url urlpkg.URL) bool

func (*Context) ReportIncompatible

func (self *Context) ReportIncompatible(name string, target string, kind string) bool

func (*Context) ReportIncompatibleExtension

func (self *Context) ReportIncompatibleExtension(extension string, requiredExtensions []string) bool

func (*Context) ReportIncompatibleType

func (self *Context) ReportIncompatibleType(type_ EntityPtr, parentType EntityPtr) bool

func (*Context) ReportIncompatibleTypeInSet added in v0.11.0

func (self *Context) ReportIncompatibleTypeInSet(type_ EntityPtr) bool

func (*Context) ReportInheritanceLoop

func (self *Context) ReportInheritanceLoop(parentType EntityPtr) bool

func (*Context) ReportMissingEntrySchema

func (self *Context) ReportMissingEntrySchema(kind string) bool

func (*Context) ReportNameAmbiguous

func (self *Context) ReportNameAmbiguous(type_ reflect.Type, name string, entityPtrs ...EntityPtr) bool

func (*Context) ReportNotInRange

func (self *Context) ReportNotInRange(name string, value uint64, lower uint64, upper uint64) bool

func (*Context) ReportPath

func (self *Context) ReportPath(skip int, message string) bool

func (*Context) ReportPathf

func (self *Context) ReportPathf(skip int, f string, arg ...interface{}) bool

func (*Context) ReportPrimitiveType

func (self *Context) ReportPrimitiveType() bool

func (*Context) ReportProblematic

func (self *Context) ReportProblematic(skip int, problematic problems.Problematic) bool

func (*Context) ReportPropertyRequired

func (self *Context) ReportPropertyRequired(kind string) bool

func (*Context) ReportReferenceAmbiguous

func (self *Context) ReportReferenceAmbiguous(kind string, entityPtr EntityPtr) bool

func (*Context) ReportReferenceNotFound

func (self *Context) ReportReferenceNotFound(kind string, entityPtr EntityPtr) bool

func (*Context) ReportRepositoryInaccessible

func (self *Context) ReportRepositoryInaccessible(repositoryName string) bool

func (*Context) ReportReservedMetadata

func (self *Context) ReportReservedMetadata() bool

func (*Context) ReportTypeIncomplete

func (self *Context) ReportTypeIncomplete(parentType EntityPtr) bool

func (*Context) ReportURL added in v0.18.0

func (self *Context) ReportURL(skip int, item string, message string, row int, column int) bool

func (*Context) ReportUndeclared

func (self *Context) ReportUndeclared(kind string) bool

func (*Context) ReportUnknown

func (self *Context) ReportUnknown(kind string) bool

func (*Context) ReportUnknownDataType

func (self *Context) ReportUnknownDataType(dataTypeName string) bool

func (*Context) ReportUnsupportedType

func (self *Context) ReportUnsupportedType() bool

func (*Context) ReportValueInvalid added in v0.18.0

func (self *Context) ReportValueInvalid(kind string, reason string) bool

func (*Context) ReportValueMalformed

func (self *Context) ReportValueMalformed(kind string, reason string) bool

func (*Context) ReportValueWrongFormat

func (self *Context) ReportValueWrongFormat(format string) bool

func (*Context) ReportValueWrongLength

func (self *Context) ReportValueWrongLength(kind string, length int) bool

func (*Context) ReportValueWrongType

func (self *Context) ReportValueWrongType(allowedTypeNames ...ard.TypeName) bool

func (*Context) Reportf

func (self *Context) Reportf(skip int, f string, arg ...interface{}) bool

func (*Context) SequencedListChild

func (self *Context) SequencedListChild(index int, name string, data ard.Value) *Context

func (*Context) SetReadTag added in v0.13.0

func (self *Context) SetReadTag(fieldName string, tag string)

func (*Context) ValidateType

func (self *Context) ValidateType(requiredTypeNames ...ard.TypeName) bool

func (*Context) ValidateUnsupportedFields

func (self *Context) ValidateUnsupportedFields(keys []string)

type Contextual

type Contextual interface {
	GetContext() *Context
}

type EntityPtr added in v0.14.0

type EntityPtr = interface{}

func GetParent

func GetParent(entityPtr EntityPtr) (EntityPtr, bool)

From Hierarchical interface

type EntityPtrs

type EntityPtrs []interface{}

func (EntityPtrs) Len

func (self EntityPtrs) Len() int

func (EntityPtrs) Less

func (self EntityPtrs) Less(i, j int) bool

func (EntityPtrs) Swap

func (self EntityPtrs) Swap(i, j int)

type FunctionCall

type FunctionCall struct {
	Name      string        `json:"name" yaml:"name"`
	Arguments []interface{} `json:"arguments" yaml:"arguments"`
	URL       string        `json:"url,omitempty" yaml:"url,omitempty"`
	Row       int           `json:"row,omitempty" yaml:"row,omitempty"`
	Column    int           `json:"column,omitempty" yaml:"column,omitempty"`
	Path      string        `json:"path,omitempty" yaml:"path,omitempty"`
}

func NewFunctionCall

func NewFunctionCall(name string, arguments []interface{}, url string, row int, column int, path string) *FunctionCall

type Grammar

type Grammar struct {
	Versions GrammarVersions
	Readers  Readers
}

func NewGrammar

func NewGrammar() Grammar

func (*Grammar) RegisterReader

func (self *Grammar) RegisterReader(name string, reader Reader)

func (*Grammar) RegisterVersion

func (self *Grammar) RegisterVersion(keyword string, version string, implicitProfilePath string)

type GrammarVersion

type GrammarVersion struct {
	Version             string
	ImplicitProfilePath string
}

type GrammarVersions

type GrammarVersions map[string][]GrammarVersion

func (GrammarVersions) Add

func (self GrammarVersions) Add(keyword string, version string, implicitProfilePath string)

type HasMetadata

type HasMetadata interface {
	GetDescription() (string, bool)
	GetMetadata() (map[string]string, bool) // should return a copy
	SetMetadata(name string, value string) bool
}

Must be thread-safe!

type Hierarchical

type Hierarchical interface {
	GetParent() EntityPtr
}

type Hierarchy

type Hierarchy struct {
	// contains filtered or unexported fields
}

func NewHierarchy

func NewHierarchy() *Hierarchy

func NewHierarchyFor added in v0.14.0

func NewHierarchyFor(entityPtr EntityPtr, hierarchyContext HierarchyContext) *Hierarchy

func (*Hierarchy) AddTo

func (self *Hierarchy) AddTo(entityPtr EntityPtr)

Into "hierarchy" tags

func (*Hierarchy) Empty added in v0.14.0

func (self *Hierarchy) Empty() bool

func (*Hierarchy) Find

func (self *Hierarchy) Find(entityPtr EntityPtr) (*Hierarchy, bool)

func (*Hierarchy) GetContext

func (self *Hierarchy) GetContext() *Context

func (*Hierarchy) IsCompatible

func (self *Hierarchy) IsCompatible(baseEntityPtr EntityPtr, entityPtr EntityPtr) bool

func (Hierarchy) Len

func (self Hierarchy) Len() int

func (Hierarchy) Less

func (self Hierarchy) Less(i, j int) bool

func (*Hierarchy) Lookup

func (self *Hierarchy) Lookup(name string, type_ reflect.Type) (*Hierarchy, bool)

func (*Hierarchy) Merge

func (self *Hierarchy) Merge(hierarchy *Hierarchy, hierarchyContext HierarchyContext)

func (*Hierarchy) Print

func (self *Hierarchy) Print(indent int)

Note that the same name could be printed out twice in the hierarchy, even under the same parent! That's because we are printing the local name of the type, and types imported from other files can have the same name (though you would need a namespace_prefix to avoid a namespace error)

func (*Hierarchy) PrintChild

func (self *Hierarchy) PrintChild(indent int, treePrefix terminal.TreePrefix, last bool)

func (*Hierarchy) PrintChildren

func (self *Hierarchy) PrintChildren(indent int, treePrefix terminal.TreePrefix)

func (*Hierarchy) Range added in v0.14.0

func (self *Hierarchy) Range(f func(EntityPtr, EntityPtr) bool)

func (*Hierarchy) Root

func (self *Hierarchy) Root() *Hierarchy

func (Hierarchy) Swap

func (self Hierarchy) Swap(i, j int)

type HierarchyContext

type HierarchyContext map[EntityPtr]bool

Keeps track of failed types

type HierarchyDescendants

type HierarchyDescendants []EntityPtr

type ImportSpec

type ImportSpec struct {
	URL             url.URL
	NameTransformer NameTransformer
	Implicit        bool
}

type Importer

type Importer interface {
	GetImportSpecs() []*ImportSpec
}

type Inherits

type Inherits interface {
	Inherit()
}

type Mappable

type Mappable interface {
	GetKey() string
}

type NameTransformer

type NameTransformer = func(string, EntityPtr) []string

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

func NewNamespace

func NewNamespace() *Namespace

func NewNamespaceFor added in v0.14.0

func NewNamespaceFor(entityPtr EntityPtr) *Namespace

From "namespace" tags

func (*Namespace) Empty added in v0.14.0

func (self *Namespace) Empty() bool

func (*Namespace) Lookup

func (self *Namespace) Lookup(name string) (EntityPtr, bool)

func (*Namespace) LookupForType

func (self *Namespace) LookupForType(name string, type_ reflect.Type) (EntityPtr, bool)

func (*Namespace) Merge

func (self *Namespace) Merge(namespace *Namespace, nameTransformer NameTransformer)

func (*Namespace) Print

func (self *Namespace) Print(indent int)

func (*Namespace) Range added in v0.14.0

func (self *Namespace) Range(f func(EntityPtr, EntityPtr) bool)

func (*Namespace) Set

func (self *Namespace) Set(name string, entityPtr EntityPtr) (EntityPtr, bool)

If the name has already been set returns existing entityPtr, true

type PreReadable

type PreReadable interface {
	PreRead()
}

type Processor

type Processor = func(ard.Value)

type Quirk added in v0.12.0

type Quirk string
const QuirkDataTypesStringPermissive Quirk = "data_types.string.permissive"

By default Puccini is strict about "string"-typed values and will consider integers, floats, and boolean values to be problems. This quirk will accept such values and convert them as sensibly as possible to strings. This includes accepting floats and integers for the TOSCA "version" primitive type. Note that string conversions may very well *not* be identical to the literal YAML. For example, `1.0000` in YAML (a float) would become the string `1` in TOSCA.

const QuirkDataTypesTimestampPermissive Quirk = "data_types.timestamp.permissive"

By default Puccini requires all "timestamp" values to be specified as strings in the ISO 8601 format. However, some YAML environments may support the optional !!timestamp type. This quirk will allow such values. Note that such values will not have the "$originalString" key, because the literal YAML is not preserved by the YAML parser.

const QuirkImportsImplicitDisable Quirk = "imports.implicit.disable"

In TOSCA 1.0-1.3 the Simple Profile is implicitly imported by default. This quirk will disable implicit imports.

const QuirkImportsPermissive Quirk = "imports.permissive"

By default Puccini will report an error if a unit imports another unit with an incompatible grammar. This quirk will disable the check.

const QuirkNamespaceNormativeIgnore Quirk = "namespace.normative.ignore"

This will ignore any type that is has the "puccini.normative: 'true'" metadata.

const QuirkNamespaceNormativeShortcutsDisable Quirk = "namespace.normative.shortcuts.disable"

In TOSCA 1.0-1.3 all the normative types have long names, such as "tosca.nodes.Compute", prefixed names ("tosca:Compute"), and also short names ("Compute"). Those short names are annoying because it means you can't use those names for your own types. This quirk disables the short names (the prefixed names remain).

const QuirkSubstitutionMappingsRequirementsList Quirk = "substitution_mappings.requirements.list"

According to the examples in the TOSCA 1.0-1.3 specs, the `requirements` key under `substitution_mappings` is syntactically a map. However, this syntax is inconsistent because it doesn't match the syntax in node templates, which is a sequenced list. (In node types, too, it is a sequenced list, although grammatically it works like a map.) This quirk changes the expected syntax to be a sequenced list.

type Quirks added in v0.12.0

type Quirks []Quirk

func NewQuirks added in v0.12.0

func NewQuirks(quirks ...string) Quirks

func (Quirks) Has added in v0.12.0

func (self Quirks) Has(quirk Quirk) bool

type ReadField

type ReadField struct {
	FieldName string
	Key       string
	Context   *Context
	Entity    reflect.Value
	Reader    Reader
	Mode      int
	Important bool
	Wildcard  bool
}

func NewReadField

func NewReadField(fieldName string, tag string, context *Context, entity reflect.Value) *ReadField

func (*ReadField) Read

func (self *ReadField) Read()

type Reader

type Reader = func(*Context) EntityPtr

type Readers

type Readers map[string]Reader

type Scriptlet

type Scriptlet struct {
	Origin                urlpkg.URL `json:"origin" yaml:"origin"`
	Path                  string     `json:"path" yaml:"path"`
	Scriptlet             string     `json:"scriptlet" yaml:"scriptlet"`
	NativeArgumentIndexes []uint     `json:"nativeArgumentIndexes" yaml:"nativeArgumentIndexes"`
}

func (*Scriptlet) Read

func (self *Scriptlet) Read() (string, error)

type ScriptletNamespace

type ScriptletNamespace struct {
	// contains filtered or unexported fields
}

func NewScriptletNamespace added in v0.14.0

func NewScriptletNamespace() *ScriptletNamespace

func (*ScriptletNamespace) Lookup added in v0.14.0

func (self *ScriptletNamespace) Lookup(name string) (*Scriptlet, bool)

func (*ScriptletNamespace) Merge

func (self *ScriptletNamespace) Merge(namespace *ScriptletNamespace)

func (*ScriptletNamespace) Range added in v0.14.0

func (self *ScriptletNamespace) Range(f func(string, *Scriptlet) bool)

func (*ScriptletNamespace) RegisterScriptlet

func (self *ScriptletNamespace) RegisterScriptlet(name string, scriptlet string, nativeArgumentIndexes []uint)

func (*ScriptletNamespace) RegisterScriptlets

func (self *ScriptletNamespace) RegisterScriptlets(scriptlets map[string]string, nativeArgumentIndexes map[string][]uint, ignore ...string)

func (*ScriptletNamespace) Set added in v0.14.0

func (self *ScriptletNamespace) Set(name string, scriptlet *Scriptlet)

type TypesByName

type TypesByName []reflect.Type

func (TypesByName) Len

func (self TypesByName) Len() int

func (TypesByName) Less

func (self TypesByName) Less(i, j int) bool

func (TypesByName) Swap

func (self TypesByName) Swap(i, j int)

Jump to

Keyboard shortcuts

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