Documentation
¶
Overview ¶
aws-cloudformation-resource-schema-sdk-go handles CloudFormation Resource Providers Schema functionality in Go.
This includes, but is not limited to, wrapping JSON Schema library usage, validating resource schemas using the CloudFormation Resource Providers Meta-Schema, and providing native Go types/methods for working with a resource schema.
The README for this package has additional information about JSON Schema and CloudFormation Resource Providers.
Index ¶
- Constants
- type Handler
- type MetaJsonSchema
- type Property
- type PropertyJsonPointer
- type PropertyJsonPointers
- type Reference
- type Resource
- func (r *Resource) Expand() error
- func (r *Resource) IsCreateOnlyPropertyPath(path string) bool
- func (r *Resource) IsRequired(name string) bool
- func (r *Resource) ResolveProperties(properties map[string]*Property) error
- func (r *Resource) ResolveProperty(property *Property) (bool, error)
- func (r *Resource) ResolveReference(ref Reference) (*Property, error)
- type ResourceJsonSchema
- type ResourceLink
- type Type
Constants ¶
const ( HandlerTypeCreate = "create" HandlerTypeDelete = "delete" HandlerTypeList = "list" HandlerTypeRead = "read" HandlerTypeUpdate = "update" )
const ( PropertyFormatDate = "date" PropertyFormatDateTime = "date-time" PropertyFormatEmail = "email" PropertyFormatHostname = "hostname" PropertyFormatIdnEmail = "idn-email" PropertyFormatIdnHostname = "idn-hostname" PropertyFormatIpv4 = "ipv4" PropertyFormatIpv6 = "ipv6" PropertyFormatIri = "iri" PropertyFormatIriReference = "iri-reference" PropertyFormatJsonPointer = "json-pointer" PropertyFormatRegex = "regex" PropertyFormatRelativeJsonPointer = "relative-json-pointer" PropertyFormatTime = "time" PropertyFormatUri = "uri" PropertyFormatUriReference = "uri-reference" PropertyFormatUriTemplate = "uri-template" )
const ( PropertyTypeArray = "array" PropertyTypeBoolean = "boolean" PropertyTypeInteger = "integer" PropertyTypeNull = "null" PropertyTypeNumber = "number" PropertyTypeObject = "object" PropertyTypeString = "string" )
const ( ReferenceAnchor = "#" ReferenceSeparator = "/" ReferenceTypeDefinitions = "definitions" ReferenceTypeProperties = "properties" )
const ( ReplacementStrategyCreateThenDelete = "create_then_delete" ReplacementStrategyDeleteThenCreate = "delete_then_create" )
const (
PropertyJsonPointerSeparator = "/"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetaJsonSchema ¶
type MetaJsonSchema struct {
// contains filtered or unexported fields
}
MetaJsonSchema represents the meta-schema for resource schemas
func NewMetaJsonSchemaDocument ¶
func NewMetaJsonSchemaDocument(document string) (*MetaJsonSchema, error)
NewMetaJsonSchemaDocument returns a MetaJsonSchema or any errors from the provided document.
func NewMetaJsonSchemaPath ¶
func NewMetaJsonSchemaPath(path string) (*MetaJsonSchema, error)
NewMetaJsonSchemaPath returns a MetaJsonSchema or any errors from the provided document at the file path.
func (*MetaJsonSchema) ValidateResourceDocument ¶
func (s *MetaJsonSchema) ValidateResourceDocument(document string) error
ValidateResourceDocument validates the provided document against the meta-schema.
func (*MetaJsonSchema) ValidateResourceJsonSchema ¶
func (s *MetaJsonSchema) ValidateResourceJsonSchema(resourceJsonSchema *ResourceJsonSchema) error
ValidateResourceJsonSchema validates the provided ResourceJsonSchema against the meta-schema.
func (*MetaJsonSchema) ValidateResourcePath ¶
func (s *MetaJsonSchema) ValidateResourcePath(path string) error
ValidateResourcePath validates the provided document at the file path against the meta-schema.
type Property ¶
type Property struct {
AdditionalProperties *bool `json:"additionalProperties,omitempty"`
Comment *string `json:"$comment,omitempty"`
Description *string `json:"description,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Examples []interface{} `json:"examples,omitempty"`
Format *string `json:"format,omitempty"`
InsertionOrder *bool `json:"insertionOrder,omitempty"`
Items *Property `json:"items,omitempty"`
Maximum *int `json:"maximum,omitempty"`
MaxItems *int `json:"maxItems,omitempty"`
MaxLength *int `json:"maxLength,omitempty"`
Minimum *int `json:"minimum,omitempty"`
MinItems *int `json:"minItems,omitempty"`
MinLength *int `json:"minLength,omitempty"`
Pattern *string `json:"pattern,omitempty"`
PatternProperties map[string]*Property `json:"patternProperties,omitempty"`
Properties map[string]*Property `json:"properties,omitempty"`
Ref *Reference `json:"$ref,omitempty"`
Required []string `json:"required,omitempty"`
Type *Type `json:"type,omitempty"`
UniqueItems *bool `json:"uniqueItems,omitempty"`
}
Property represents the CloudFormation Resource Schema customization for Definitions and Properties.
func (*Property) IsRequired ¶ added in v0.2.0
type PropertyJsonPointer ¶
type PropertyJsonPointer string
PropertyJsonPointer is a simplistic RFC 6901 handler for properties JSON Pointers.
func (*PropertyJsonPointer) EqualsPath ¶
func (p *PropertyJsonPointer) EqualsPath(path []string) bool
EqualsPath returns true if all path parts match.
This automatically handles stripping the /properties prefix.
func (*PropertyJsonPointer) EqualsStringPath ¶
func (p *PropertyJsonPointer) EqualsStringPath(path string) bool
EqualsStringPath returns true if the path string matches.
This automatically handles stripping the /properties prefix.
func (*PropertyJsonPointer) Path ¶
func (p *PropertyJsonPointer) Path() []string
Path returns the path parts.
This automatically handles stripping the /properties path part.
func (*PropertyJsonPointer) String ¶
func (p *PropertyJsonPointer) String() string
String returns a string representation of the PropertyJsonPointer.
type PropertyJsonPointers ¶
type PropertyJsonPointers []PropertyJsonPointer
PropertyJsonPointers is a list of PropertyJsonPointer.
func (PropertyJsonPointers) ContainsPath ¶
func (ptrs PropertyJsonPointers) ContainsPath(path []string) bool
ContainsPath returns true if an element matches the path.
type Reference ¶
type Reference string
Reference is an internal implementation for RFC 6901 JSON Pointer values.
type Resource ¶
type Resource struct {
AdditionalIdentifiers []PropertyJsonPointers `json:"additionalIdentifiers,omitempty"`
AdditionalProperties *bool `json:"additionalProperties,omitempty"`
ConditionalCreateOnlyProperties PropertyJsonPointers `json:"conditionalCreateOnlyProperties,omitempty"`
CreateOnlyProperties PropertyJsonPointers `json:"createOnlyProperties,omitempty"`
Definitions map[string]*Property `json:"definitions,omitempty"`
DeprecatedProperties PropertyJsonPointers `json:"deprecatedProperties,omitempty"`
Description *string `json:"description,omitempty"`
Handlers map[string]*Handler `json:"handlers,omitempty"`
PrimaryIdentifier PropertyJsonPointers `json:"primaryIdentifier,omitempty"`
Properties map[string]*Property `json:"properties,omitempty"`
ReadOnlyProperties PropertyJsonPointers `json:"readOnlyProperties,omitempty"`
ReplacementStrategy *string `json:"replacementStrategy,omitempty"`
Required []string `json:"required,omitempty"`
ResourceLink *ResourceLink `json:"resourceLink,omitempty"`
SourceURL *string `json:"sourceUrl,omitempty"`
Taggable *bool `json:"taggable,omitempty"`
TypeName *string `json:"typeName,omitempty"`
WriteOnlyProperties PropertyJsonPointers `json:"writeOnlyProperties,omitempty"`
}
func (*Resource) Expand ¶
Expand replaces all Definition and Property JSON Pointer references with their content. This functionality removes the need for recursive logic when accessing Definitions and Properties. In unresolved form nested properties are not allowed, instead nested properties use a '$ref' JSON Pointer to reference a definition. See https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html#schema-properties-properties.
func (*Resource) IsCreateOnlyPropertyPath ¶
func (*Resource) IsRequired ¶
func (*Resource) ResolveProperties ¶ added in v0.6.0
ResolveProperties resolves all References in a top-level name-to-property map. In unresolved form nested properties are not allowed so we don't need to recurse.
func (*Resource) ResolveProperty ¶
ResolveProperty resolves any Reference (JSON Pointer) in a Property. Returns whether a Reference was resolved.
type ResourceJsonSchema ¶
type ResourceJsonSchema struct {
// contains filtered or unexported fields
}
ResourceJsonSchema represents the resource schema.
func NewResourceJsonSchemaDocument ¶
func NewResourceJsonSchemaDocument(document string) (*ResourceJsonSchema, error)
NewResourceJsonSchemaDocument returns a ResourceJsonSchema or any errors from the provided document.
func NewResourceJsonSchemaPath ¶
func NewResourceJsonSchemaPath(path string) (*ResourceJsonSchema, error)
NewResourceJsonSchemaPath returns a ResourceJsonSchema or any errors from the provided document at the file path.
func (*ResourceJsonSchema) Resource ¶
func (s *ResourceJsonSchema) Resource() (*Resource, error)
Resource parses the JSON Schema and returns Resource or an error.
func (*ResourceJsonSchema) ValidateConfigurationDocument ¶
func (s *ResourceJsonSchema) ValidateConfigurationDocument(document string) error
ValidateConfigurationDocument validates the provided document against the resource schema.
func (*ResourceJsonSchema) ValidateConfigurationPath ¶
func (s *ResourceJsonSchema) ValidateConfigurationPath(path string) error
ValidateConfigurationPath validates the provided document at the file path against the resource schema.