Documentation
¶
Overview ¶
A programming model for composable configuration
Index ¶
- func ConstructMetadata_DisableStackTraceInMetadata() string
- func ConstructMetadata_ErrorMetadataKey() string
- func ConstructMetadata_InfoMetadataKey() string
- func ConstructMetadata_WarningMetadataKey() string
- func Node_PathSep() string
- type Construct
- type ConstructIface
- type ConstructMetadata
- type ConstructMetadataIface
- type ConstructOptions
- type ConstructOptionsIface
- type ConstructOrder
- type Dependency
- type DependencyIface
- type IAspect
- type IAspectIface
- type IConstruct
- type IConstructIface
- type INodeFactory
- type INodeFactoryIface
- type ISynthesisSession
- type ISynthesisSessionIface
- type IValidation
- type IValidationIface
- type MetadataEntry
- type MetadataEntryIface
- type Node
- func (n *Node) AddDependency(dependencies IConstructIface)
- func (n *Node) AddError(message string)
- func (n *Node) AddInfo(message string)
- func (n *Node) AddMetadata(type_ string, data interface{}, fromFunction interface{})
- func (n *Node) AddValidation(validation IValidationIface)
- func (n *Node) AddWarning(message string)
- func (n *Node) ApplyAspect(aspect IAspectIface)
- func (n *Node) FindAll(order ConstructOrder) []IConstructIface
- func (n *Node) FindChild(id string) IConstructIface
- func (n *Node) GetAddr() string
- func (n *Node) GetChildren() []IConstructIface
- func (n *Node) GetDefaultChild() IConstructIface
- func (n *Node) GetDependencies() []DependencyIface
- func (n *Node) GetId() string
- func (n *Node) GetLocked() bool
- func (n *Node) GetMetadata() []MetadataEntryIface
- func (n *Node) GetPath() string
- func (n *Node) GetRoot() IConstructIface
- func (n *Node) GetScope() IConstructIface
- func (n *Node) GetScopes() []IConstructIface
- func (n *Node) GetUniqueId() string
- func (n *Node) Prepare()
- func (n *Node) SetContext(key string, value interface{})
- func (n *Node) SetDefaultChild(val IConstructIface)
- func (n *Node) Synthesize(options SynthesisOptionsIface)
- func (n *Node) TryFindChild(id string) IConstructIface
- func (n *Node) TryGetContext(key string) interface{}
- func (n *Node) TryRemoveChild(childName string) bool
- func (n *Node) Validate() []ValidationErrorIface
- type NodeIface
- type SynthesisOptions
- type SynthesisOptionsIface
- type ValidationError
- type ValidationErrorIface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstructMetadata_DisableStackTraceInMetadata ¶
func ConstructMetadata_DisableStackTraceInMetadata() string
func ConstructMetadata_ErrorMetadataKey ¶
func ConstructMetadata_ErrorMetadataKey() string
func ConstructMetadata_InfoMetadataKey ¶
func ConstructMetadata_InfoMetadataKey() string
func ConstructMetadata_WarningMetadataKey ¶
func ConstructMetadata_WarningMetadataKey() string
func Node_PathSep ¶
func Node_PathSep() string
Types ¶
type Construct ¶
type Construct struct {
}
Represents the building block of the construct graph.
All constructs besides the root construct must be created within the scope of another construct. Struct proxy
func (*Construct) OnSynthesize ¶
func (c *Construct) OnSynthesize(session ISynthesisSessionIface)
func (*Construct) OnValidate ¶
type ConstructIface ¶
type ConstructIface interface {
IConstructIface
OnPrepare()
OnSynthesize(session ISynthesisSessionIface)
OnValidate() []string
ToString() string
}
Class interface
func NewConstruct ¶
func NewConstruct(scope ConstructIface, id string, options ConstructOptionsIface) ConstructIface
Creates a new construct node.
type ConstructMetadata ¶
type ConstructMetadata struct {
}
Metadata keys used by constructs. Struct proxy
type ConstructOptions ¶
type ConstructOptions struct {
// A factory for attaching `Node`s to the construct.
NodeFactory INodeFactoryIface `json:"nodeFactory"`
}
Options for creating constructs. Struct proxy
func (*ConstructOptions) GetNodeFactory ¶
func (c *ConstructOptions) GetNodeFactory() INodeFactoryIface
type ConstructOptionsIface ¶
type ConstructOptionsIface interface {
GetNodeFactory() INodeFactoryIface
}
ConstructOptionsIface is the public interface for the custom type ConstructOptions
type ConstructOrder ¶
type ConstructOrder string
In what order to return constructs.
const ( ConstructOrderPreorder ConstructOrder = "PREORDER" ConstructOrderPostorder ConstructOrder = "POSTORDER" )
type Dependency ¶
type Dependency struct {
// Source the dependency.
Source IConstructIface `json:"source"`
// Target of the dependency.
Target IConstructIface `json:"target"`
}
A single dependency. Struct proxy
func (*Dependency) GetSource ¶
func (d *Dependency) GetSource() IConstructIface
func (*Dependency) GetTarget ¶
func (d *Dependency) GetTarget() IConstructIface
type DependencyIface ¶
type DependencyIface interface {
GetSource() IConstructIface
GetTarget() IConstructIface
}
DependencyIface is the public interface for the custom type Dependency
type IAspect ¶
type IAspect struct{}
func (*IAspect) Visit ¶
func (i *IAspect) Visit(node IConstructIface)
type IAspectIface ¶
type IAspectIface interface {
// All aspects can visit an IConstruct.
Visit(node IConstructIface)
}
Represents an Aspect.
type IConstruct ¶
type IConstruct struct{}
type INodeFactory ¶
type INodeFactory struct{}
func (*INodeFactory) CreateNode ¶
func (i *INodeFactory) CreateNode(host ConstructIface, scope IConstructIface, id string) NodeIface
type INodeFactoryIface ¶
type INodeFactoryIface interface {
// Returns a new `Node` associated with `host`.
CreateNode(host ConstructIface, scope IConstructIface, id string) NodeIface
}
A factory for attaching `Node`s to the construct.
type ISynthesisSession ¶
type ISynthesisSession struct{}
func (*ISynthesisSession) GetOutdir ¶
func (i *ISynthesisSession) GetOutdir() string
type ISynthesisSessionIface ¶
type ISynthesisSessionIface interface {
// The output directory for this synthesis session.
GetOutdir() string
}
Represents a single session of synthesis.
Passed into `construct.onSynthesize()` methods.
type IValidation ¶
type IValidation struct{}
func (*IValidation) Validate ¶
func (i *IValidation) Validate() []string
type IValidationIface ¶
type IValidationIface interface {
// Validate the current construct.
//
// This method can be implemented by derived constructs in order to perform
// validation logic. It is called on all constructs before synthesis.
//
// Returns: An array of validation error messages, or an empty array if there the construct is valid.
Validate() []string
}
Implement this interface in order for the construct to be able to validate itself.
type MetadataEntry ¶
type MetadataEntry struct {
// The data.
Data interface{} `json:"data"`
// The metadata entry type.
Type string `json:"type"`
// Stack trace.
//
// Can be omitted by setting the context key
// `ConstructMetadata.DISABLE_STACK_TRACE_IN_METADATA` to 1.
Trace []string `json:"trace"`
}
An entry in the construct metadata table. Struct proxy
func (*MetadataEntry) GetData ¶
func (m *MetadataEntry) GetData() interface{}
func (*MetadataEntry) GetTrace ¶
func (m *MetadataEntry) GetTrace() []string
func (*MetadataEntry) GetType ¶
func (m *MetadataEntry) GetType() string
type MetadataEntryIface ¶
MetadataEntryIface is the public interface for the custom type MetadataEntry
type Node ¶
type Node struct {
// Returns an opaque tree-unique address for this construct.
//
// Addresses are 42 characters hexadecimal strings. They begin with "c8"
// followed by 40 lowercase hexadecimal characters (0-9a-f).
//
// Addresses are calculated using a SHA-1 of the components of the construct
// path.
//
// To enable refactorings of construct trees, constructs with the ID `Default`
// will be excluded from the calculation. In those cases constructs in the
// same tree may have the same addreess.
//
// TODO: EXAMPLE
//
Addr string `json:"addr"`
// All direct children of this construct.
Children []IConstructIface `json:"children"`
// Return all dependencies registered on this node or any of its children.
Dependencies []DependencyIface `json:"dependencies"`
// The id of this construct within the current scope.
//
// This is a a scope-unique id. To obtain an app-unique id for this construct, use `uniqueId`.
Id string `json:"id"`
// Returns true if this construct or the scopes in which it is defined are locked.
Locked bool `json:"locked"`
// An immutable array of metadata objects associated with this construct.
//
// This can be used, for example, to implement support for deprecation notices, source mapping, etc.
Metadata []MetadataEntryIface `json:"metadata"`
// The full, absolute path of this construct in the tree.
//
// Components are separated by '/'.
Path string `json:"path"`
// Returns the root of the construct tree.
//
// Returns: The root of the construct tree.
Root IConstructIface `json:"root"`
// All parent scopes of this construct.
//
// Returns: a list of parent scopes. The last element in the list will always
// be the current construct and the first element will be the root of the
// tree.
Scopes []IConstructIface `json:"scopes"`
// A tree-global unique alphanumeric identifier for this construct.
//
// Includes
// all components of the tree.
// Deprecated: please avoid using this property and use `uid` instead. This
// algorithm uses MD5, which is not FIPS-complient and also excludes the
// identity of the root construct from the calculation.
UniqueId string `json:"uniqueId"`
// Returns the scope in which this construct is defined.
//
// The value is `undefined` at the root of the construct scope tree.
Scope IConstructIface `json:"scope"`
// Returns the child construct that has the id `Default` or `Resource"`.
//
// This is usually the construct that provides the bulk of the underlying functionality.
// Useful for modifications of the underlying construct that are not available at the higher levels.
// Override the defaultChild property.
//
// This should only be used in the cases where the correct
// default child is not named 'Resource' or 'Default' as it
// should be.
//
// If you set this to undefined, the default behavior of finding
// the child named 'Resource' or 'Default' will be used.
//
// Returns: a construct or undefined if there is no default child
DefaultChild IConstructIface `json:"defaultChild"`
}
Represents the construct node in the scope tree. Struct proxy
func (*Node) AddDependency ¶
func (n *Node) AddDependency(dependencies IConstructIface)
func (*Node) AddMetadata ¶
func (*Node) AddValidation ¶
func (n *Node) AddValidation(validation IValidationIface)
func (*Node) AddWarning ¶
func (*Node) ApplyAspect ¶
func (n *Node) ApplyAspect(aspect IAspectIface)
func (*Node) FindAll ¶
func (n *Node) FindAll(order ConstructOrder) []IConstructIface
func (*Node) FindChild ¶
func (n *Node) FindChild(id string) IConstructIface
func (*Node) GetChildren ¶
func (n *Node) GetChildren() []IConstructIface
func (*Node) GetDefaultChild ¶
func (n *Node) GetDefaultChild() IConstructIface
func (*Node) GetDependencies ¶
func (n *Node) GetDependencies() []DependencyIface
func (*Node) GetMetadata ¶
func (n *Node) GetMetadata() []MetadataEntryIface
func (*Node) GetRoot ¶
func (n *Node) GetRoot() IConstructIface
func (*Node) GetScope ¶
func (n *Node) GetScope() IConstructIface
func (*Node) GetScopes ¶
func (n *Node) GetScopes() []IConstructIface
func (*Node) GetUniqueId ¶
func (*Node) SetContext ¶
func (*Node) SetDefaultChild ¶
func (n *Node) SetDefaultChild(val IConstructIface)
func (*Node) Synthesize ¶
func (n *Node) Synthesize(options SynthesisOptionsIface)
func (*Node) TryFindChild ¶
func (n *Node) TryFindChild(id string) IConstructIface
func (*Node) TryGetContext ¶
func (*Node) TryRemoveChild ¶
func (*Node) Validate ¶
func (n *Node) Validate() []ValidationErrorIface
type NodeIface ¶
type NodeIface interface {
GetAddr() string
GetChildren() []IConstructIface
GetDependencies() []DependencyIface
GetId() string
GetLocked() bool
GetMetadata() []MetadataEntryIface
GetPath() string
GetRoot() IConstructIface
GetScopes() []IConstructIface
GetUniqueId() string
GetScope() IConstructIface
GetDefaultChild() IConstructIface
SetDefaultChild(val IConstructIface)
AddDependency(dependencies IConstructIface)
AddError(message string)
AddInfo(message string)
AddMetadata(type_ string, data interface{}, fromFunction interface{})
AddValidation(validation IValidationIface)
AddWarning(message string)
ApplyAspect(aspect IAspectIface)
FindAll(order ConstructOrder) []IConstructIface
FindChild(id string) IConstructIface
Prepare()
SetContext(key string, value interface{})
Synthesize(options SynthesisOptionsIface)
TryFindChild(id string) IConstructIface
TryGetContext(key string) interface{}
TryRemoveChild(childName string) bool
Validate() []ValidationErrorIface
}
Class interface
func NewNode ¶
func NewNode(host ConstructIface, scope IConstructIface, id string) NodeIface
func Node_Of ¶
func Node_Of(construct IConstructIface) NodeIface
type SynthesisOptions ¶
type SynthesisOptions struct {
// The output directory into which to synthesize the cloud assembly.
Outdir string `json:"outdir"`
// Additional context passed into the synthesis session object when `construct.synth` is called.
SessionContext map[string]interface{} `json:"sessionContext"`
// Whether synthesis should skip the validation phase.
SkipValidation bool `json:"skipValidation"`
}
Options for synthesis. Struct proxy
func (*SynthesisOptions) GetOutdir ¶
func (s *SynthesisOptions) GetOutdir() string
func (*SynthesisOptions) GetSessionContext ¶
func (s *SynthesisOptions) GetSessionContext() map[string]interface{}
func (*SynthesisOptions) GetSkipValidation ¶
func (s *SynthesisOptions) GetSkipValidation() bool
type SynthesisOptionsIface ¶
type SynthesisOptionsIface interface {
GetOutdir() string
GetSessionContext() map[string]interface{}
GetSkipValidation() bool
}
SynthesisOptionsIface is the public interface for the custom type SynthesisOptions
type ValidationError ¶
type ValidationError struct {
// The error message.
Message string `json:"message"`
// The construct which emitted the error.
Source ConstructIface `json:"source"`
}
An error returned during the validation phase. Struct proxy
func (*ValidationError) GetMessage ¶
func (v *ValidationError) GetMessage() string
func (*ValidationError) GetSource ¶
func (v *ValidationError) GetSource() ConstructIface
type ValidationErrorIface ¶
type ValidationErrorIface interface {
GetMessage() string
GetSource() ConstructIface
}
ValidationErrorIface is the public interface for the custom type ValidationError