schema

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CoreVariableTypes provides a slice of all the core supported
	// variable types to be used for clean validation of fields
	// with a field with VariableType.
	// This does not represent all possible variable types,
	// as provider custom variable types are also supported.
	CoreVariableTypes = []VariableType{
		VariableTypeString,
		VariableTypeInteger,
		VariableTypeFloat,
		VariableTypeBoolean,
	}
)
View Source
var (
	// DataSourceFieldTypes provides a slice of all the supported
	// data source field types to be used for clean validation of fields
	// with a field with DataSourceFieldType.
	DataSourceFieldTypes = []DataSourceFieldType{
		DataSourceFieldTypeString,
		DataSourceFieldTypeInteger,
		DataSourceFieldTypeFloat,
		DataSourceFieldTypeBoolean,
		DataSourceFieldTypeArray,
	}
)
View Source
var (
	// ExportTypes provides a slice of all the supported
	// export types.
	ExportTypes = []ExportType{
		ExportTypeString,
		ExportTypeObject,
		ExportTypeInteger,
		ExportTypeFloat,
		ExportTypeArray,
		ExportTypeBoolean,
	}
)
View Source
var (
	// ValueTypes provides a slice of all the supported
	// value types to be used for validation of
	// local value types in a blueprint.
	ValueTypes = []ValueType{
		ValueTypeString,
		ValueTypeInteger,
		ValueTypeFloat,
		ValueTypeBoolean,
		ValueTypeArray,
		ValueTypeObject,
	}
)

Functions

func GetDataSourceType added in v0.21.0

func GetDataSourceType(dataSource *DataSource) string

GetDataSourceType safely extracts the type from a data source, returning an empty string if the type wrapper is nil or empty.

func GetResourceType added in v0.21.0

func GetResourceType(resource *Resource) string

GetResourceType safely extracts the type from a resource, returning an empty string if the type wrapper is nil or empty.

Types

type Blueprint

type Blueprint struct {
	Version     *core.ScalarValue      `yaml:"version" json:"version"`
	Transform   *TransformValueWrapper `yaml:"transform,omitempty" json:"transform,omitempty"`
	Variables   *VariableMap           `yaml:"variables,omitempty" json:"variables,omitempty"`
	Values      *ValueMap              `yaml:"values,omitempty" json:"values,omitempty"`
	Include     *IncludeMap            `yaml:"include,omitempty" json:"include,omitempty"`
	Resources   *ResourceMap           `yaml:"resources" json:"resources"`
	DataSources *DataSourceMap         `yaml:"datasources,omitempty" json:"datasources,omitempty"`
	Exports     *ExportMap             `yaml:"exports,omitempty" json:"exports,omitempty"`
	Metadata    *core.MappingNode      `yaml:"metadata,omitempty" json:"metadata,omitempty"`
}

Blueprint provides the type for a blueprint specification loaded into memory.

func Load

func Load(specFilePath string, inputFormat SpecFormat) (*Blueprint, error)

Load deals with loading a blueprint specification from a YAML or JSON file on disk.

func LoadString

func LoadString(spec string, inputFormat SpecFormat) (*Blueprint, error)

LoadString deals with loading a blueprint specification from a given YAML or JSON with Commas and Comments string.

type Condition

type Condition struct {
	// A list of conditions that must all be true.
	And []*Condition `yaml:"and,omitempty" json:"and,omitempty"`
	// A list of conditions where at least one must be true.
	Or []*Condition `yaml:"or,omitempty" json:"or,omitempty"`
	// A condition that will be negated.
	Not *Condition `yaml:"not,omitempty" json:"not,omitempty"`
	// A condition expression that is expected
	// to be a substitution that resolves to a boolean.
	StringValue *substitutions.StringOrSubstitutions `yaml:"-" json:"-"`
	SourceMeta  *source.Meta                         `yaml:"-" json:"-"`
}

Condition represents a condition that can be used to determine if a resource should be created.

func (*Condition) FromJSONNode

func (c *Condition) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*Condition) MarshalJSON

func (c *Condition) MarshalJSON() ([]byte, error)

func (*Condition) MarshalYAML

func (c *Condition) MarshalYAML() (interface{}, error)

func (*Condition) UnmarshalJSON

func (c *Condition) UnmarshalJSON(data []byte) error

func (*Condition) UnmarshalYAML

func (c *Condition) UnmarshalYAML(value *yaml.Node) error

type DataSource

type DataSource struct {
	Type               *DataSourceTypeWrapper               `yaml:"type" json:"type"`
	DataSourceMetadata *DataSourceMetadata                  `yaml:"metadata" json:"metadata"`
	Filter             *DataSourceFilters                   `yaml:"filter" json:"filter"`
	Exports            *DataSourceFieldExportMap            `yaml:"exports" json:"exports"`
	Description        *substitutions.StringOrSubstitutions `yaml:"description,omitempty" json:"description,omitempty"`
	SourceMeta         *source.Meta                         `yaml:"-" json:"-"`
}

DataSource represents a blueprint data source in the specification. Data sources are accessible to all resources in a blueprint via the ${datasources.{dataSourceName}.{exportedField}} reference. For example, you would access a data source called network with an exported vpc field via ${datasources.network.vpc}.

func (*DataSource) FromJSONNode

func (s *DataSource) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DataSource) UnmarshalYAML

func (s *DataSource) UnmarshalYAML(value *yaml.Node) error

type DataSourceFieldExport

type DataSourceFieldExport struct {
	Type        *DataSourceFieldTypeWrapper          `yaml:"type" json:"type"`
	AliasFor    *bpcore.ScalarValue                  `yaml:"aliasFor" json:"aliasFor"`
	Description *substitutions.StringOrSubstitutions `yaml:"description,omitempty" json:"description,omitempty"`
	SourceMeta  *source.Meta                         `yaml:"-" json:"-"`
}

DataSourceFieldExport provides the definition of an exported field from a data source in a blueprint.

func (*DataSourceFieldExport) FromJSONNode

func (e *DataSourceFieldExport) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DataSourceFieldExport) UnmarshalYAML

func (e *DataSourceFieldExport) UnmarshalYAML(value *yaml.Node) error

type DataSourceFieldExportMap

type DataSourceFieldExportMap struct {
	Values map[string]*DataSourceFieldExport
	// Indicates if all fields should be exported,
	// this is set to true if the `export` field is set to `*`
	// in the blueprint.
	ExportAll bool
	// Mapping of exported field names to their source locations.
	SourceMeta map[string]*source.Meta
}

DataSourceFieldExportMap provides a mapping of names to data source field exports. This includes extra information about the locations of the keys in the original source being unmarshalled. This information will not always be present, it is populated when unmarshalling from YAML and JWCC source documents.

func (*DataSourceFieldExportMap) FromJSONNode

func (m *DataSourceFieldExportMap) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DataSourceFieldExportMap) MarshalJSON

func (m *DataSourceFieldExportMap) MarshalJSON() ([]byte, error)

func (*DataSourceFieldExportMap) MarshalYAML

func (m *DataSourceFieldExportMap) MarshalYAML() (any, error)

func (*DataSourceFieldExportMap) UnmarshalJSON

func (m *DataSourceFieldExportMap) UnmarshalJSON(data []byte) error

func (*DataSourceFieldExportMap) UnmarshalYAML

func (m *DataSourceFieldExportMap) UnmarshalYAML(value *yaml.Node) error

type DataSourceFieldType

type DataSourceFieldType string

DataSourceFieldType represents a type of exported field for a data source defined in a blueprint. Can be one of "string", "integer", "float", "boolean", "array" or "object".

const (
	// DataSourceFieldTypeString is for an exported
	// string field from a data source in a blueprint.
	DataSourceFieldTypeString DataSourceFieldType = "string"
	// DataSourceFieldTypeInteger is for an exported
	// integer field from a data source in a blueprint.
	DataSourceFieldTypeInteger DataSourceFieldType = "integer"
	// DataSourceFieldTypeFloat is for an exported
	// float field from a data source in a blueprint.
	DataSourceFieldTypeFloat DataSourceFieldType = "float"
	// DataSourceFieldTypeBoolean is for an exported
	// boolean field from a data source in a blueprint.
	DataSourceFieldTypeBoolean DataSourceFieldType = "boolean"
	// DataSourceFieldTypeArray is for an exported
	// array field from a data source in a blueprint.
	DataSourceFieldTypeArray DataSourceFieldType = "array"
)

func (DataSourceFieldType) Equal

func (t DataSourceFieldType) Equal(compareWith DataSourceFieldType) bool

type DataSourceFieldTypeWrapper

type DataSourceFieldTypeWrapper struct {
	Value      DataSourceFieldType
	SourceMeta *source.Meta
}

DataSourceFieldTypeWrapper provides a struct that holds a data source field type value. The reason that this exists is to allow more fine-grained control when serialising and deserialising data source field exports in a blueprint so we can check precise values.

func (*DataSourceFieldTypeWrapper) FromJSONNode

func (t *DataSourceFieldTypeWrapper) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DataSourceFieldTypeWrapper) MarshalJSON

func (t *DataSourceFieldTypeWrapper) MarshalJSON() ([]byte, error)

func (*DataSourceFieldTypeWrapper) MarshalYAML

func (t *DataSourceFieldTypeWrapper) MarshalYAML() (interface{}, error)

func (*DataSourceFieldTypeWrapper) UnmarshalJSON

func (t *DataSourceFieldTypeWrapper) UnmarshalJSON(data []byte) error

func (*DataSourceFieldTypeWrapper) UnmarshalYAML

func (t *DataSourceFieldTypeWrapper) UnmarshalYAML(value *yaml.Node) error

type DataSourceFilter

type DataSourceFilter struct {
	Field      *bpcore.ScalarValue              `yaml:"field" json:"field"`
	Operator   *DataSourceFilterOperatorWrapper `yaml:"operator" json:"operator"`
	Search     *DataSourceFilterSearch          `yaml:"search" json:"search"`
	SourceMeta *source.Meta                     `yaml:"-" json:"-"`
}

DataSourceFilter provides the definition of a filter used to select a specific data source instance from a provider.

func (*DataSourceFilter) FromJSONNode

func (f *DataSourceFilter) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DataSourceFilter) UnmarshalYAML

func (f *DataSourceFilter) UnmarshalYAML(value *yaml.Node) error

type DataSourceFilterOperator

type DataSourceFilterOperator string

DataSourceFilterOperator represents a filter operator for a data source defined in a blueprint. Can be one of "=", "!=", "in", "not in", "has key", "not has key", "contains", "not contains", "starts with", "not starts with", "ends with", "not ends with", ">", "<", ">=" or "<=".

const (
	// DataSourceFilterOperatorEquals represents the "=" filter operator.
	DataSourceFilterOperatorEquals DataSourceFilterOperator = "="
	// DataSourceFilterOperatorNotEquals represents the "!=" filter operator.
	DataSourceFilterOperatorNotEquals DataSourceFilterOperator = "!="
	// DataSourceFilterOperatorIn represents the "in" filter operator.
	DataSourceFilterOperatorIn DataSourceFilterOperator = "in"
	// DataSourceFilterOperatorNotIn represents the "not in" filter operator.
	DataSourceFilterOperatorNotIn DataSourceFilterOperator = "not in"
	// DataSourceFilterOperatorHasKey represents the "has key" filter operator.
	DataSourceFilterOperatorHasKey DataSourceFilterOperator = "has key"
	// DataSourceFilterOperatorNotHasKey represents the "not has key" filter operator.
	DataSourceFilterOperatorNotHasKey DataSourceFilterOperator = "not has key"
	// DataSourceFilterOperatorContains represents the "contains" filter operator.
	DataSourceFilterOperatorContains DataSourceFilterOperator = "contains"
	// DataSourceFilterOperatorNotContains represents the "not contains" filter operator.
	DataSourceFilterOperatorNotContains DataSourceFilterOperator = "not contains"
	// DataSourceFilterOperatorStartsWith represents the "starts with" filter operator.
	DataSourceFilterOperatorStartsWith DataSourceFilterOperator = "starts with"
	// DataSourceFilterOperatorNotStartsWith represents the "not starts with" filter operator.
	DataSourceFilterOperatorNotStartsWith DataSourceFilterOperator = "not starts with"
	// DataSourceFilterOperatorEndsWith represents the "ends with" filter operator.
	DataSourceFilterOperatorEndsWith DataSourceFilterOperator = "ends with"
	// DataSourceFilterOperatorNotEndsWith represents the "not ends with" filter operator.
	DataSourceFilterOperatorNotEndsWith DataSourceFilterOperator = "not ends with"
	// DataSourceFilterOperatorGreaterThan represents the ">" filter operator.
	DataSourceFilterOperatorGreaterThan DataSourceFilterOperator = ">"
	// DataSourceFilterOperatorLessThan represents the "<" filter operator.
	DataSourceFilterOperatorLessThan DataSourceFilterOperator = "<"
	// DataSourceFilterOperatorGreaterThanOrEqual represents the ">=" filter operator.
	DataSourceFilterOperatorGreaterThanOrEqual DataSourceFilterOperator = ">="
	// DataSourceFilterOperatorLessThanOrEqual represents the "<=" filter operator.
	DataSourceFilterOperatorLessThanOrEqual DataSourceFilterOperator = "<="
)

func (DataSourceFilterOperator) Equal

type DataSourceFilterOperatorWrapper

type DataSourceFilterOperatorWrapper struct {
	Value      DataSourceFilterOperator
	SourceMeta *source.Meta
}

DataSourceFilterOperatorWrapper provides a struct that holds a data source filter operator value. The reason that this exists is to allow more fine-grained control when serialising and deserialising data source filter operators in a blueprint so we can check precise values.

func (*DataSourceFilterOperatorWrapper) FromJSONNode

func (w *DataSourceFilterOperatorWrapper) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DataSourceFilterOperatorWrapper) MarshalJSON

func (w *DataSourceFilterOperatorWrapper) MarshalJSON() ([]byte, error)

func (*DataSourceFilterOperatorWrapper) MarshalYAML

func (w *DataSourceFilterOperatorWrapper) MarshalYAML() (interface{}, error)

func (*DataSourceFilterOperatorWrapper) UnmarshalJSON

func (w *DataSourceFilterOperatorWrapper) UnmarshalJSON(data []byte) error

func (*DataSourceFilterOperatorWrapper) UnmarshalYAML

func (w *DataSourceFilterOperatorWrapper) UnmarshalYAML(value *yaml.Node) error

type DataSourceFilterSearch

type DataSourceFilterSearch struct {
	Values     []*substitutions.StringOrSubstitutions
	SourceMeta *source.Meta
}

DataSourceFilterSearch provides the definition of one or more search values for a data source filter.

func (*DataSourceFilterSearch) FromJSONNode

func (s *DataSourceFilterSearch) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DataSourceFilterSearch) MarshalJSON

func (s *DataSourceFilterSearch) MarshalJSON() ([]byte, error)

func (*DataSourceFilterSearch) MarshalYAML

func (s *DataSourceFilterSearch) MarshalYAML() (interface{}, error)

func (*DataSourceFilterSearch) UnmarshalJSON

func (s *DataSourceFilterSearch) UnmarshalJSON(data []byte) error

func (*DataSourceFilterSearch) UnmarshalYAML

func (s *DataSourceFilterSearch) UnmarshalYAML(value *yaml.Node) error

type DataSourceFilters added in v0.19.0

type DataSourceFilters struct {
	Filters []*DataSourceFilter `yaml:"filters" json:"filters"`
}

DataSourceFilters provides a slice of one or more filters parsed from a mapping for a single filter or a sequence of filters.

func (*DataSourceFilters) FromJSONNode added in v0.19.0

func (f *DataSourceFilters) FromJSONNode(node *json.Node, linePositions []int, parentPath string) error

func (*DataSourceFilters) MarshalJSON added in v0.19.0

func (s *DataSourceFilters) MarshalJSON() ([]byte, error)

func (*DataSourceFilters) MarshalYAML added in v0.19.0

func (s *DataSourceFilters) MarshalYAML() (interface{}, error)

func (*DataSourceFilters) UnmarshalJSON added in v0.19.0

func (s *DataSourceFilters) UnmarshalJSON(data []byte) error

func (*DataSourceFilters) UnmarshalYAML added in v0.19.0

func (s *DataSourceFilters) UnmarshalYAML(value *yaml.Node) error

type DataSourceMap

type DataSourceMap struct {
	Values map[string]*DataSource
	// Mapping of data source names to their source locations.
	SourceMeta map[string]*source.Meta
}

DataSourceMap provides a mapping of names to data sources. This includes extra information about the locations of the keys in the original source being unmarshalled. This information will not always be present, it is populated when unmarshalling from YAML and JWCC source documents.

func (*DataSourceMap) FromJSONNode

func (m *DataSourceMap) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DataSourceMap) MarshalJSON

func (m *DataSourceMap) MarshalJSON() ([]byte, error)

func (*DataSourceMap) MarshalYAML

func (m *DataSourceMap) MarshalYAML() (any, error)

func (*DataSourceMap) UnmarshalJSON

func (m *DataSourceMap) UnmarshalJSON(data []byte) error

func (*DataSourceMap) UnmarshalYAML

func (m *DataSourceMap) UnmarshalYAML(value *yaml.Node) error

type DataSourceMetadata

type DataSourceMetadata struct {
	DisplayName *substitutions.StringOrSubstitutions `yaml:"displayName" json:"displayName"`
	Annotations *StringOrSubstitutionsMap            `yaml:"annotations,omitempty" json:"annotations,omitempty"`
	Custom      *bpcore.MappingNode                  `yaml:"custom,omitempty" json:"custom,omitempty"`
	SourceMeta  *source.Meta                         `yaml:"-" json:"-"`
}

DataSourceMetadata represents the metadata associated with a blueprint data source that can be used to provide annotations that are used to configure data sources when fetching data from the data source provider.

func (*DataSourceMetadata) FromJSONNode

func (m *DataSourceMetadata) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DataSourceMetadata) UnmarshalYAML

func (m *DataSourceMetadata) UnmarshalYAML(value *yaml.Node) error

type DataSourceTypeWrapper

type DataSourceTypeWrapper struct {
	Value      string
	SourceMeta *source.Meta
}

DataSourceTypeWrapper provides a struct that holds a data source type value.

func (*DataSourceTypeWrapper) FromJSONNode

func (t *DataSourceTypeWrapper) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DataSourceTypeWrapper) MarshalJSON

func (t *DataSourceTypeWrapper) MarshalJSON() ([]byte, error)

func (*DataSourceTypeWrapper) MarshalYAML

func (t *DataSourceTypeWrapper) MarshalYAML() (interface{}, error)

func (*DataSourceTypeWrapper) UnmarshalJSON

func (t *DataSourceTypeWrapper) UnmarshalJSON(data []byte) error

func (*DataSourceTypeWrapper) UnmarshalYAML

func (t *DataSourceTypeWrapper) UnmarshalYAML(value *yaml.Node) error

type DependsOnList

type DependsOnList struct {
	StringList
}

DependsOnList provides a list of resource names that a resource depends on. This can include extra information about the locations of elements in the list in the original source, depending on the source format.

func (*DependsOnList) FromJSONNode

func (t *DependsOnList) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*DependsOnList) MarshalJSON

func (t *DependsOnList) MarshalJSON() ([]byte, error)

func (*DependsOnList) MarshalYAML

func (t *DependsOnList) MarshalYAML() (any, error)

func (*DependsOnList) UnmarshalJSON

func (t *DependsOnList) UnmarshalJSON(data []byte) error

func (*DependsOnList) UnmarshalYAML

func (t *DependsOnList) UnmarshalYAML(value *yaml.Node) error

type Error

type Error struct {
	ReasonCode ErrorSchemaReasonCode
	Err        error
	// The line in the source blueprint file
	// where the error occurred.
	// This will be nil if the error is not related
	// to a specific line in the blueprint file
	// or the source format is JSON.
	SourceLine *int
	// The column on a line in the source blueprint file
	// where the error occurred.
	// This will be nil if the error is not related
	// to a specific line/column in the blueprint file
	// or the source format is JSON.
	SourceColumn *int
}

Error represents an error due to an issue with the schema of a blueprint.

func (*Error) Error

func (e *Error) Error() string

type ErrorSchemaReasonCode

type ErrorSchemaReasonCode string
const (
	// ErrorSchemaReasonCodeInvalidDataSourceFieldType is provided
	// when the reason for a blueprint schema load error is due
	// to an invalid data source exported field type.
	ErrorSchemaReasonCodeInvalidDataSourceFieldType ErrorSchemaReasonCode = "invalid_data_source_field_type"
	// ErrorSchemaReasonCodeInvalidTransformType is provided
	// when the reason for a blueprint schema load error is due to
	// an invalid transform field value being provided.
	ErrorSchemaReasonCodeInvalidTransformType ErrorSchemaReasonCode = "invalid_transform_type"
	// ErrorSchemaReasonCodeInvalidDependencyType is provided
	// when the reason for a blueprint schema load error is due
	// to an invalid dependsOn field value being provided for a resource.
	ErrorSchemaReasonCodeInvalidDependencyType ErrorSchemaReasonCode = "invalid_dependency_type"
	// ErrorSchemaReasonCodeInvalidMap is provided when the reason
	// for a blueprint schema load error is due to an invalid map
	// being provided.
	ErrorSchemaReasonCodeInvalidMap ErrorSchemaReasonCode = "invalid_map"
	// ErrorSchemaReasonCodeInvalidMapKey is provided when the reason
	// for a blueprint schema load error is due to an invalid array (sequence)
	// being provided.
	ErrorSchemaReasonCodeInvalidArray ErrorSchemaReasonCode = "invalid_array"
	// ErrorSchemaReasonCodeInvalidArrayOrString is provided when the reason
	// for a blueprint schema load error is due to an invalid value being provided
	// for a field that can be either a string or an array of strings.
	ErrorSchemaReasonCodeInvalidArrayOrString ErrorSchemaReasonCode = "invalid_array_or_string"
	// ErrorSchemaReasonCodeInvalidResourceCondition is provided
	// when the reason for a blueprint schema load error is due
	// to an invalid resource condition being provided.
	ErrorSchemaReasonCodeInvalidResourceCondition ErrorSchemaReasonCode = "invalid_resource_condition"
	// ErrorSchemaReasonCodeGeneral is provided when the reason
	// for a blueprint schema load error is not specific,
	// primarily used for errors wrapped with parent scope line information.
	ErrorSchemaReasonCodeGeneral ErrorSchemaReasonCode = "general"
)

type Export

type Export struct {
	Type        *ExportTypeWrapper                   `yaml:"type" json:"type"`
	Field       *bpcore.ScalarValue                  `yaml:"field" json:"field"`
	Description *substitutions.StringOrSubstitutions `yaml:"description,omitempty" json:"description,omitempty"`
	SourceMeta  *source.Meta                         `yaml:"-" json:"-"`
}

Export represents a blueprint exported field in the specification. Exports are designed to be persisted with the state of a blueprint instance and to be accessible to other blueprints and external systems exposed via an API, an include reference or as a field in a "blueprint" resource. (The latter of the three options would require an implementation of blueprint resource provider)

func (*Export) FromJSONNode

func (e *Export) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*Export) UnmarshalYAML

func (e *Export) UnmarshalYAML(value *yaml.Node) error

type ExportMap

type ExportMap struct {
	Values map[string]*Export
	// Mapping of export names to their source locations.
	SourceMeta map[string]*source.Meta
}

ExportMap provides a mapping of names to exports. This includes extra information about the locations of the keys in the original source being unmarshalled. This information will not always be present, it is populated when unmarshalling from YAML and JWCC source documents.

func (*ExportMap) FromJSONNode

func (m *ExportMap) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*ExportMap) MarshalJSON

func (m *ExportMap) MarshalJSON() ([]byte, error)

func (*ExportMap) MarshalYAML

func (m *ExportMap) MarshalYAML() (any, error)

func (*ExportMap) UnmarshalJSON

func (m *ExportMap) UnmarshalJSON(data []byte) error

func (*ExportMap) UnmarshalYAML

func (m *ExportMap) UnmarshalYAML(value *yaml.Node) error

type ExportType

type ExportType string

ExportType represents a type of exported field defined in a blueprint. Can be one of "string", "object", "integer", "float", "array" or "boolean".

const (
	// ExportTypeString is for a string export
	// in a blueprint.
	ExportTypeString ExportType = "string"
	// ExportTypeObject is for an object export
	// in a blueprint.
	ExportTypeObject ExportType = "object"
	// ExportTypeInteger is for an integer export
	// in a blueprint.
	ExportTypeInteger ExportType = "integer"
	// ExportTypeFloat is for a float export
	// in a blueprint.
	ExportTypeFloat ExportType = "float"
	// ExportTypeArray is for an array export
	// in a blueprint.
	ExportTypeArray ExportType = "array"
	// ExportTypeBoolean is for a boolean export
	// in a blueprint.
	ExportTypeBoolean ExportType = "boolean"
)

func (ExportType) Equal

func (t ExportType) Equal(compareWith ExportType) bool

type ExportTypeWrapper

type ExportTypeWrapper struct {
	Value      ExportType
	SourceMeta *source.Meta
}

ExportTypeWrapper provides a struct that holds an export type value.

func (*ExportTypeWrapper) FromJSONNode

func (t *ExportTypeWrapper) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*ExportTypeWrapper) MarshalJSON

func (t *ExportTypeWrapper) MarshalJSON() ([]byte, error)

func (*ExportTypeWrapper) MarshalYAML

func (t *ExportTypeWrapper) MarshalYAML() (interface{}, error)

func (*ExportTypeWrapper) UnmarshalJSON

func (t *ExportTypeWrapper) UnmarshalJSON(data []byte) error

func (*ExportTypeWrapper) UnmarshalYAML

func (t *ExportTypeWrapper) UnmarshalYAML(value *yaml.Node) error

type Include

type Include struct {
	// The path to the child blueprint on a local or remote file system.
	Path *substitutions.StringOrSubstitutions `yaml:"path" json:"path"`
	// The variables to pass down to the child blueprint.
	Variables *core.MappingNode `yaml:"variables" json:"variables"`
	// Extra metadata to be used by include resolver plugins.
	// An example of this could be the use of fields that provide information
	// about a remote location to download the child blueprint from such as
	// an AWS S3 bucket.
	Metadata    *core.MappingNode                    `yaml:"metadata" json:"metadata"`
	Description *substitutions.StringOrSubstitutions `yaml:"description" json:"description"`
	SourceMeta  *source.Meta                         `yaml:"-" json:"-"`
}

Include represents a child blueprint include in the specification. This provides a method of creating modular blueprints that is native to the spec and doesn't require a third party plugin to implement. (e.g. a celerity/blueprint resource type)

func (*Include) FromJSONNode

func (i *Include) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*Include) UnmarshalYAML

func (i *Include) UnmarshalYAML(value *yaml.Node) error

type IncludeMap

type IncludeMap struct {
	Values map[string]*Include
	// Mapping of include names to their source locations.
	SourceMeta map[string]*source.Meta
}

IncludeMap provides a mapping of names to child blueprint includes. This includes extra information about the locations of the keys in the original source being unmarshalled. This information will not always be present, it is populated when unmarshalling from YAML and JWCC source documents.

func (*IncludeMap) FromJSONNode

func (m *IncludeMap) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*IncludeMap) MarshalJSON

func (m *IncludeMap) MarshalJSON() ([]byte, error)

func (*IncludeMap) MarshalYAML

func (m *IncludeMap) MarshalYAML() (any, error)

func (*IncludeMap) UnmarshalJSON

func (m *IncludeMap) UnmarshalJSON(data []byte) error

func (*IncludeMap) UnmarshalYAML

func (m *IncludeMap) UnmarshalYAML(value *yaml.Node) error

type LinkSelector

type LinkSelector struct {
	ByLabel    *StringMap   `yaml:"byLabel" json:"byLabel"`
	SourceMeta *source.Meta `yaml:"-" json:"-"`
}

LinkSelector allows a resource to select other resources to link to by label.

func (*LinkSelector) FromJSONNode

func (s *LinkSelector) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*LinkSelector) UnmarshalYAML

func (s *LinkSelector) UnmarshalYAML(value *yaml.Node) error

type Loader

type Loader func(string, SpecFormat) (*Blueprint, error)

Loader provides a function that loads a serialised blueprint spec either from a file path or a serialised string already loaded in memory.

type Metadata

type Metadata struct {
	DisplayName *substitutions.StringOrSubstitutions `yaml:"displayName" json:"displayName"`
	Annotations *StringOrSubstitutionsMap            `yaml:"annotations,omitempty" json:"annotations,omitempty"`
	Labels      *StringMap                           `yaml:"labels,omitempty" json:"labels,omitempty"`
	Custom      *core.MappingNode                    `yaml:"custom,omitempty" json:"custom,omitempty"`
	SourceMeta  *source.Meta                         `yaml:"-" json:"-"`
}

Metadata represents the metadata associated with a blueprint resource that can be used to provide labels and annotations that can be used to configure instances and used for link selections.

func (*Metadata) FromJSONNode

func (m *Metadata) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*Metadata) UnmarshalYAML

func (m *Metadata) UnmarshalYAML(value *yaml.Node) error

type Resource

type Resource struct {
	Type         *ResourceTypeWrapper                 `yaml:"type" json:"type"`
	Description  *substitutions.StringOrSubstitutions `yaml:"description,omitempty" json:"description,omitempty"`
	Metadata     *Metadata                            `yaml:"metadata,omitempty" json:"metadata,omitempty"`
	DependsOn    *DependsOnList                       `yaml:"dependsOn,omitempty" json:"dependsOn,omitempty"`
	Condition    *Condition                           `yaml:"condition,omitempty" json:"condition,omitempty"`
	Each         *substitutions.StringOrSubstitutions `yaml:"each,omitempty" json:"each,omitempty"`
	LinkSelector *LinkSelector                        `yaml:"linkSelector,omitempty" json:"linkSelector,omitempty"`
	Spec         *core.MappingNode                    `yaml:"spec" json:"spec"`
	SourceMeta   *source.Meta                         `yaml:"-" json:"-"`
}

Resource represents a blueprint resource in the specification.

func (*Resource) FromJSONNode

func (r *Resource) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*Resource) UnmarshalYAML

func (r *Resource) UnmarshalYAML(value *yaml.Node) error

type ResourceMap

type ResourceMap struct {
	Values map[string]*Resource
	// Mapping of resource names to their source locations.
	SourceMeta map[string]*source.Meta
}

ResourceMap provides a mapping of names to resources. This includes extra information about the locations of the keys in the original source being unmarshalled. This information will not always be present, it is populated when unmarshalling from YAML and JWCC source documents.

func (*ResourceMap) FromJSONNode

func (m *ResourceMap) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*ResourceMap) MarshalJSON

func (m *ResourceMap) MarshalJSON() ([]byte, error)

func (*ResourceMap) MarshalYAML

func (m *ResourceMap) MarshalYAML() (any, error)

func (*ResourceMap) UnmarshalJSON

func (m *ResourceMap) UnmarshalJSON(data []byte) error

func (*ResourceMap) UnmarshalYAML

func (m *ResourceMap) UnmarshalYAML(value *yaml.Node) error

type ResourceTypeWrapper

type ResourceTypeWrapper struct {
	Value      string
	SourceMeta *source.Meta
}

ResourceTypeWrapper provides a struct that holds a resource type value.

func (*ResourceTypeWrapper) FromJSONNode

func (t *ResourceTypeWrapper) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*ResourceTypeWrapper) MarshalJSON

func (t *ResourceTypeWrapper) MarshalJSON() ([]byte, error)

func (*ResourceTypeWrapper) MarshalYAML

func (t *ResourceTypeWrapper) MarshalYAML() (any, error)

func (*ResourceTypeWrapper) UnmarshalJSON

func (t *ResourceTypeWrapper) UnmarshalJSON(data []byte) error

func (*ResourceTypeWrapper) UnmarshalYAML

func (t *ResourceTypeWrapper) UnmarshalYAML(value *yaml.Node) error

type SpecFormat

type SpecFormat string

SpecFormat is the format of a specification to be used for transport and storage.

const (
	// JWCCSpecFormat determines that a spec being loaded
	// or exported should be serialised or deserialised
	// in the JSON with Commas and Comments format.
	JWCCSpecFormat SpecFormat = "jwcc"
	// YAMLSpecFormat determines that a spec being loaded
	// or exported should be serialised or deserialised
	// in the YAML format.
	YAMLSpecFormat SpecFormat = "yaml"
)

type StringList

type StringList struct {
	Values []string
	// A list of source meta information for each string value
	// that if populated, will be in the same order as the values.
	SourceMeta []*source.Meta
}

StringList provides a list of strings with source meta information that is populated for certain source formats. This should always be embedded in a struct that provides context such as a transform list or a depends on list so more specific errors can be returned.

func (*StringList) FromJSONNode

func (t *StringList) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*StringList) MarshalJSON

func (t *StringList) MarshalJSON() ([]byte, error)

func (*StringList) MarshalYAML

func (t *StringList) MarshalYAML() (interface{}, error)

type StringMap

type StringMap struct {
	Values map[string]string
	// Mapping of field names to their source locations.
	SourceMeta map[string]*source.Meta
}

StringMap provides a mapping of names to string literals. This includes extra information about the locations of the keys in the original source being unmarshalled. This information will not always be present, it is populated when unmarshalling from YAML and JWCC source documents.

func (*StringMap) FromJSONNode

func (m *StringMap) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*StringMap) MarshalJSON

func (m *StringMap) MarshalJSON() ([]byte, error)

func (*StringMap) MarshalYAML

func (m *StringMap) MarshalYAML() (interface{}, error)

func (*StringMap) UnmarshalJSON

func (m *StringMap) UnmarshalJSON(data []byte) error

func (*StringMap) UnmarshalYAML

func (m *StringMap) UnmarshalYAML(value *yaml.Node) error

type StringOrSubstitutionsMap

type StringOrSubstitutionsMap struct {
	Values map[string]*substitutions.StringOrSubstitutions
	// Mapping of field names to their source locations.
	SourceMeta map[string]*source.Meta
}

StringOrSubstitutionsMap provides a mapping of names to expanded strings that may contain substitutions. This includes extra information about the locations of the keys in the original source being unmarshalled. This information will not always be present, it is populated when unmarshalling from YAML and JWCC source documents.

func (*StringOrSubstitutionsMap) FromJSONNode

func (m *StringOrSubstitutionsMap) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*StringOrSubstitutionsMap) MarshalJSON

func (m *StringOrSubstitutionsMap) MarshalJSON() ([]byte, error)

func (*StringOrSubstitutionsMap) MarshalYAML

func (m *StringOrSubstitutionsMap) MarshalYAML() (interface{}, error)

func (*StringOrSubstitutionsMap) UnmarshalJSON

func (m *StringOrSubstitutionsMap) UnmarshalJSON(data []byte) error

func (*StringOrSubstitutionsMap) UnmarshalYAML

func (m *StringOrSubstitutionsMap) UnmarshalYAML(value *yaml.Node) error

type TransformValueWrapper

type TransformValueWrapper struct {
	StringList
}

TransformValueWrapper holds one or more transforms to be applied to a specification. This allows for users to provide the transform field in a spec as a string or as a list of strings.

func (*TransformValueWrapper) FromJSONNode

func (t *TransformValueWrapper) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*TransformValueWrapper) MarshalJSON

func (t *TransformValueWrapper) MarshalJSON() ([]byte, error)

func (*TransformValueWrapper) MarshalYAML

func (t *TransformValueWrapper) MarshalYAML() (interface{}, error)

func (*TransformValueWrapper) UnmarshalJSON

func (t *TransformValueWrapper) UnmarshalJSON(data []byte) error

func (*TransformValueWrapper) UnmarshalYAML

func (t *TransformValueWrapper) UnmarshalYAML(value *yaml.Node) error

type TreeNode

type TreeNode struct {
	// Label is the label of the tree node.
	// For a node that represents a named field in a schema element,
	// the label is the name of the field. (e.g. "variables" or "resources")
	// For a node that represents an element in a list, the label is the index
	// of the element in the list.
	// For a node that represents an element in a mapping, the label is the key
	// of the element in the mapping.
	Label string
	// Path contains the path to the tree node relative to the root.
	// For example, the path to a variable type node could be
	// "/variables/myVar/type".
	// "/" is used as the separator as "." can be in names of elements.
	// The path is made up of the labels of the nodes in the tree.
	Path string
	// Type is the type of the tree node.
	Type TreeNodeType
	// Children is a list of child nodes in the tree.
	Children []*TreeNode
	// SchemaElement is the schema element that this tree node represents.
	SchemaElement interface{}
	// Range is the source range of the tree node in the blueprint source document.
	Range *source.Range
}

TreeNode is a tree representation of a blueprint schema that is in sequential source order, from left to right. As a blueprint is made up of an augmentation of a host document language (e.g. YAML) and the embedded substitution language, there is no natural AST or AST-like representation of a blueprint.

TreeNode is derived from a parsed schema to provide a sequential representation of elements in a blueprint that makes it easier to determine accurate ranges for diagnostics, completions and other language server features.

The unordered maps used in the schema structs are not suitable for efficiently determining where elements start and end which is essential for tools such as language servers.

A tree should only be used when source location information is made available by the host document language parser. (e.g. YAML)

func SchemaToTree

func SchemaToTree(blueprint *Blueprint) *TreeNode

SchemaToTree converts a blueprint schema to a tree representation.

func (*TreeNode) SetRangeEnd

func (n *TreeNode) SetRangeEnd(end *source.Meta)

SetRangeEnd sets the range end of a tree node and the last child. This is applied recursively to the last child of the last child and so on.

type TreeNodeType

type TreeNodeType int

TreeNodeType is the type of a tree node.

const (
	// TreeNodeTypeNonTerminal is a non-terminal node of the tree
	// of a blueprint.
	TreeNodeTypeNonTerminal TreeNodeType = iota
	// TreeNodeTypeLeaf is a leaf node of the tree
	// of a blueprint.
	TreeNodeTypeLeaf
)

type Value

type Value struct {
	Type        *ValueTypeWrapper                    `yaml:"type" json:"type"`
	Value       *bpcore.MappingNode                  `yaml:"value" json:"value"`
	Description *substitutions.StringOrSubstitutions `yaml:"description,omitempty" json:"description,omitempty"`
	Secret      *bpcore.ScalarValue                  `yaml:"secret" json:"secret"`
	SourceMeta  *source.Meta                         `yaml:"-" json:"-"`
}

Value provides the definition of a value that can be used in a blueprint.

func (*Value) FromJSONNode

func (v *Value) FromJSONNode(node *json.Node, linePositions []int, parentPath string) error

func (*Value) UnmarshalYAML

func (t *Value) UnmarshalYAML(value *yaml.Node) error

type ValueMap

type ValueMap struct {
	Values map[string]*Value
	// Mapping of value names to their source locations.
	SourceMeta map[string]*source.Meta
}

ValueMap provides a mapping of names to value definitions in a blueprint. This includes extra information about the locations of the keys in the original source being unmarshalled. This information will not always be present, it is populated when unmarshalling from YAML and JWCC source documents.

func (*ValueMap) FromJSONNode

func (m *ValueMap) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*ValueMap) MarshalJSON

func (m *ValueMap) MarshalJSON() ([]byte, error)

func (*ValueMap) MarshalYAML

func (m *ValueMap) MarshalYAML() (any, error)

func (*ValueMap) UnmarshalJSON

func (m *ValueMap) UnmarshalJSON(data []byte) error

func (*ValueMap) UnmarshalYAML

func (m *ValueMap) UnmarshalYAML(value *yaml.Node) error

type ValueType

type ValueType string

ValueType represents a type of value defined in a blueprint. Can be one of "string", "integer", "float", "boolean", "array" or "object".

const (
	// ValueTypeString is for a string value
	// in a blueprint.
	ValueTypeString ValueType = "string"
	// ValueTypeInteger is for an integer value
	// in a blueprint.
	ValueTypeInteger ValueType = "integer"
	// ValueTypeFloat is for a float value
	// in a blueprint.
	ValueTypeFloat ValueType = "float"
	// ValueTypeBoolean is for a boolean value
	// in a blueprint.
	ValueTypeBoolean ValueType = "boolean"
	// ValueTypeArray is for an array value
	// in a blueprint.
	ValueTypeArray ValueType = "array"
	// ValueTypeObject is for an object value
	// in a blueprint.
	ValueTypeObject ValueType = "object"
)

func (ValueType) Equal

func (t ValueType) Equal(compareWith ValueType) bool

type ValueTypeWrapper

type ValueTypeWrapper struct {
	Value      ValueType
	SourceMeta *source.Meta
}

ValueTypeWrapper provides a struct that holds a value type. The reason that this exists is to allow more fine-grained control when serialising and deserialising values in a blueprint so we can check precise value types.

func (*ValueTypeWrapper) FromJSONNode

func (t *ValueTypeWrapper) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*ValueTypeWrapper) MarshalJSON

func (t *ValueTypeWrapper) MarshalJSON() ([]byte, error)

func (*ValueTypeWrapper) MarshalYAML

func (t *ValueTypeWrapper) MarshalYAML() (any, error)

func (*ValueTypeWrapper) UnmarshalJSON

func (t *ValueTypeWrapper) UnmarshalJSON(data []byte) error

func (*ValueTypeWrapper) UnmarshalYAML

func (t *ValueTypeWrapper) UnmarshalYAML(value *yaml.Node) error

type Variable

type Variable struct {
	Type          *VariableTypeWrapper  `yaml:"type" json:"type"`
	Description   *bpcore.ScalarValue   `yaml:"description,omitempty" json:"description,omitempty"`
	Secret        *bpcore.ScalarValue   `yaml:"secret" json:"secret"`
	Default       *bpcore.ScalarValue   `yaml:"default,omitempty" json:"default,omitempty"`
	AllowedValues []*bpcore.ScalarValue `yaml:"allowedValues,omitempty" json:"allowedValues,omitempty"`
	SourceMeta    *source.Meta          `yaml:"-" json:"-"`
}

Variable provides the definition of a variable that can be used in a blueprint.

func (*Variable) FromJSONNode

func (v *Variable) FromJSONNode(node *json.Node, linePositions []int, parentPath string) error

func (*Variable) UnmarshalYAML

func (v *Variable) UnmarshalYAML(value *yaml.Node) error

type VariableMap

type VariableMap struct {
	Values map[string]*Variable
	// Mapping of variable names to their source locations.
	SourceMeta map[string]*source.Meta
}

VariableMap provides a mapping of names to variable values in a blueprint. This includes extra information about the locations of the keys in the original source being unmarshalled. This information will not always be present, it is populated when unmarshalling from YAML and JWCC source documents.

func (*VariableMap) FromJSONNode

func (m *VariableMap) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*VariableMap) MarshalJSON

func (m *VariableMap) MarshalJSON() ([]byte, error)

func (*VariableMap) MarshalYAML

func (m *VariableMap) MarshalYAML() (any, error)

func (*VariableMap) UnmarshalJSON

func (m *VariableMap) UnmarshalJSON(data []byte) error

func (*VariableMap) UnmarshalYAML

func (m *VariableMap) UnmarshalYAML(value *yaml.Node) error

type VariableType

type VariableType string

VariableType represents a type of variable defined in a blueprint. Can be one of "string", "integer", "float" or "boolean" or a custom type defined by a resource provider.

const (
	// VariableTypeString is for a string variable
	// in a blueprint.
	VariableTypeString VariableType = "string"
	// VariableTypeInteger is for an integer value
	// in a blueprint.
	VariableTypeInteger VariableType = "integer"
	// VariableTypeFloat is for a float value
	// in a blueprint.
	VariableTypeFloat VariableType = "float"
	// VariableTypeBoolean is for a boolean value
	// in a blueprint.
	VariableTypeBoolean VariableType = "boolean"
)

func (VariableType) Equal

func (t VariableType) Equal(compareWith VariableType) bool

type VariableTypeWrapper

type VariableTypeWrapper struct {
	Value      VariableType
	SourceMeta *source.Meta
}

VariableTypeWrapper provides a struct that holds a variable type value.

func (*VariableTypeWrapper) FromJSONNode

func (t *VariableTypeWrapper) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

func (*VariableTypeWrapper) MarshalJSON

func (t *VariableTypeWrapper) MarshalJSON() ([]byte, error)

func (*VariableTypeWrapper) MarshalYAML

func (t *VariableTypeWrapper) MarshalYAML() (interface{}, error)

func (*VariableTypeWrapper) UnmarshalJSON

func (t *VariableTypeWrapper) UnmarshalJSON(data []byte) error

func (*VariableTypeWrapper) UnmarshalYAML

func (t *VariableTypeWrapper) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

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