Documentation
¶
Index ¶
- Constants
- Variables
- func TemplateValidate(template *parse.Template, definitions ResourceDefinitions, ...) (bool, reporting.Reports)
- func ValidateIntrinsicFunctions(value parse.IntrinsicFunction, ctx PropertyContext, ...) (reporting.ValidateResult, reporting.Reports)
- type ArrayPropertyType
- type Coercion
- type Context
- type EnumValue
- func (from EnumValue) CoercibleTo(to PropertyType) Coercion
- func (enum EnumValue) Describe() string
- func (EnumValue) IsArray() bool
- func (EnumValue) PropertyDefault(string) (interface{}, bool)
- func (from EnumValue) Same(to PropertyType) bool
- func (enum EnumValue) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
- type FuncType
- func (from FuncType) CoercibleTo(to PropertyType) Coercion
- func (ft FuncType) Describe() string
- func (FuncType) IsArray() bool
- func (FuncType) PropertyDefault(string) (interface{}, bool)
- func (from FuncType) Same(to PropertyType) bool
- func (ft FuncType) String() string
- func (ft FuncType) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
- type IntrinsicFunctionValidate
- type NestedResource
- func (res NestedResource) AwsType() string
- func (NestedResource) CoercibleTo(PropertyType) Coercion
- func (res NestedResource) Describe() string
- func (NestedResource) IsArray() bool
- func (res NestedResource) PropertyDefault(name string) (interface{}, bool)
- func (res NestedResource) Same(to PropertyType) bool
- func (res NestedResource) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
- type Properties
- type PropertyContext
- type PropertyDefaults
- type PropertyType
- type RefTarget
- type Resource
- type ResourceContext
- type ResourceDefinitions
- type ResourceWithDefinition
- type Schema
- type SupportedFunctions
- type UnsupportedProperties
- type ValidatableProperties
- type ValidateFunc
- func FixedArrayValidate(options ...[]string) ValidateFunc
- func IntegerRangeValidate(start, end float64) ValidateFunc
- func NumberOptions(numbers ...float64) ValidateFunc
- func RegexpValidate(pattern, message string) ValidateFunc
- func SingleValueValidate(expected interface{}) ValidateFunc
- func StringLengthValidate(min, max int) ValidateFunc
- type ValidateOption
- type ValidationOptions
- type ValueType
- func (from ValueType) CoercibleTo(to PropertyType) Coercion
- func (vt ValueType) Describe() string
- func (t ValueType) IsArray() bool
- func (ValueType) PropertyDefault(string) (interface{}, bool)
- func (from ValueType) Same(to PropertyType) bool
- func (i ValueType) String() string
- func (vt ValueType) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
Constants ¶
View Source
const ( LongID bool = true ShortID = false )
Variables ¶
View Source
var ARN = FuncType{ Description: "ARN", Fn: func(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports) { if result, errs := ValueString.Validate(value, ctx); result == reporting.ValidateAbort || errs != nil { return reporting.ValidateOK, errs } return reporting.ValidateOK, nil }, }
View Source
var AllocationID = newResourceID("EipAllocationID", "eipalloc", ShortID)
View Source
var AvailabilityZone = EnumValue{ Description: "Availability Zone", Options: []string{ "ap-northeast-1a", "ap-northeast-1b", "ap-northeast-1c", "ap-northeast-2a", "ap-northeast-2c", "ap-southeast-1a", "ap-southeast-1b", "ap-southeast-2a", "ap-southeast-2b", "eu-central-1a", "eu-central-1b", "eu-west-1a", "eu-west-1b", "eu-west-1c", "sa-east-1a", "sa-east-1b", "sa-east-1c", "us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e", "us-west-1a", "us-west-1c", "us-west-2a", "us-west-2b", "us-west-2c", }, }
View Source
var CIDR = ConstrainedString( "CIDR", func(value string, ctx PropertyContext) reporting.Reports { if ok, _ := regexp.MatchString(cidrPattern, value); !ok { return reporting.Reports{reporting.NewFailure(ctx, "Cidr %s is invalid", value)} } return nil }, )
View Source
var HostedZoneID = ConstrainedString( "HostedZoneID", func(value string, ctx PropertyContext) reporting.Reports { return nil }, )
View Source
var IPAddress = ConstrainedString( "IPAddress", func(value string, ctx PropertyContext) reporting.Reports { if !ipAddressRegex.MatchString(value) { return reporting.Reports{ reporting.NewFailure(ctx, "Value '%s' is not a valid IPv4 address", value), } } return nil }, )
View Source
var ImageID = newResourceID("AMI", "ami", ShortID)
View Source
var InstanceID = newResourceID("InstanceID", "i", LongID)
View Source
var InternetGatewayID = newResourceID("InternetGatewayID", "igw", ShortID)
View Source
var KeyName = ConstrainedString( "KeyName", func(value string, ctx PropertyContext) reporting.Reports { return nil }, )
View Source
var NatGatewayID = newResourceID("NatGatewayID", "nat", LongID)
View Source
var NetworkAclID = newResourceID("NetworkAclID", "acl", ShortID)
View Source
var NetworkInterfaceID = newResourceID("NetworkInterfaceID", "eni", ShortID)
View Source
var Period = ConstrainedString( "Period", func(value string, ctx PropertyContext) reporting.Reports { num, err := strconv.Atoi(value) if err != nil { return reporting.Reports{reporting.NewFailure(ctx, "Period is not a number: %s", value)} } if num == 0 || num%60 != 0 { return reporting.Reports{reporting.NewFailure(ctx, "Period is not a multiple of 60: %s", value)} } return nil }, )
View Source
var RouteTableID = newResourceID("RouteTableID", "rtb", ShortID)
View Source
var SecurityGroupID = newResourceID("SecurityGroupID", "sg", ShortID)
View Source
var SecurityGroupName = ConstrainedString( "SecurityGroupName", func(value string, ctx PropertyContext) reporting.Reports { return nil }, )
View Source
var SnapshotID = newResourceID("SnapshotID", "vol", LongID)
View Source
var SubnetID = newResourceID("SubnetID", "subnet", ShortID)
View Source
var SupportedFunctionsAll = SupportedFunctions{ parse.FnAnd: true, parse.FnBase64: true, parse.FnEquals: true, parse.FnFindInMap: true, parse.FnGetAtt: true, parse.FnGetAZs: true, parse.FnIf: true, parse.FnJoin: true, parse.FnNot: true, parse.FnOr: true, parse.FnRef: true, parse.FnSelect: true, }
SupportedFunctionsAll deliberately excludes Condition, because it isn't valid anywhere except nested in other conditions (and they cater for it explicitly)
View Source
var Timestamp = ConstrainedString( "Timestamp", func(value string, ctx PropertyContext) reporting.Reports { if ok, _ := regexp.MatchString(cidrPattern, value); !ok { return reporting.Reports{reporting.NewFailure(ctx, "Timestamp %s is invalid", value)} } return nil }, )
View Source
var VolumeID = newResourceID("VolumeID", "vol", LongID)
View Source
var VpcID = newResourceID("VpcID", "vpc", ShortID)
View Source
var VpcPeeringConnectionID = newResourceID("VpcPeeringConnectionID", "pcx", ShortID)
View Source
var VpnConnectionID = newResourceID("VpnConnectionID", "vpn", ShortID)
View Source
var VpnGatewayID = newResourceID("VpnGatewayID", "vgw", ShortID)
Functions ¶
func TemplateValidate ¶
func TemplateValidate(template *parse.Template, definitions ResourceDefinitions, options ValidationOptions) (bool, reporting.Reports)
func ValidateIntrinsicFunctions ¶ added in v0.2.0
func ValidateIntrinsicFunctions(value parse.IntrinsicFunction, ctx PropertyContext, supportedFunctions SupportedFunctions) (reporting.ValidateResult, reporting.Reports)
Types ¶
type ArrayPropertyType ¶ added in v0.2.0
type ArrayPropertyType struct {
PropertyType
}
func (ArrayPropertyType) CoercibleTo ¶ added in v0.2.0
func (pt ArrayPropertyType) CoercibleTo(to PropertyType) Coercion
func (ArrayPropertyType) Describe ¶ added in v0.2.0
func (pt ArrayPropertyType) Describe() string
func (ArrayPropertyType) Same ¶ added in v0.2.0
func (pt ArrayPropertyType) Same(to PropertyType) bool
func (ArrayPropertyType) Unwrap ¶ added in v0.2.0
func (apt ArrayPropertyType) Unwrap() PropertyType
type Context ¶
type Context interface {
Options() ValidationOptions
Definitions() ResourceDefinitions
Path() []string
Template() *parse.Template
}
func ContextAdd ¶
func NewInitialContext ¶
func NewInitialContext(template *parse.Template, definitions ResourceDefinitions, options ValidationOptions) Context
type EnumValue ¶
func (EnumValue) CoercibleTo ¶
func (from EnumValue) CoercibleTo(to PropertyType) Coercion
func (EnumValue) PropertyDefault ¶
func (EnumValue) Same ¶ added in v0.2.0
func (from EnumValue) Same(to PropertyType) bool
func (EnumValue) Validate ¶
func (enum EnumValue) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
type FuncType ¶
type FuncType struct {
Description string
Fn func(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
CoercibleFn func(PropertyType) Coercion
}
var JSON FuncType
func (FuncType) CoercibleTo ¶
func (from FuncType) CoercibleTo(to PropertyType) Coercion
func (FuncType) PropertyDefault ¶
func (FuncType) Same ¶ added in v0.2.0
func (from FuncType) Same(to PropertyType) bool
func (FuncType) Validate ¶
func (ft FuncType) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
type IntrinsicFunctionValidate ¶ added in v0.2.0
type IntrinsicFunctionValidate func(value parse.IntrinsicFunction, ctx PropertyContext) reporting.Reports
type NestedResource ¶
type NestedResource struct {
Description string
Properties ValidatableProperties
}
func (NestedResource) AwsType ¶ added in v0.2.0
func (res NestedResource) AwsType() string
func (NestedResource) CoercibleTo ¶
func (NestedResource) CoercibleTo(PropertyType) Coercion
func (NestedResource) Describe ¶
func (res NestedResource) Describe() string
func (NestedResource) IsArray ¶ added in v0.2.0
func (NestedResource) IsArray() bool
func (NestedResource) PropertyDefault ¶ added in v0.2.0
func (res NestedResource) PropertyDefault(name string) (interface{}, bool)
func (NestedResource) Same ¶ added in v0.2.0
func (res NestedResource) Same(to PropertyType) bool
func (NestedResource) Validate ¶
func (res NestedResource) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
TODO: This is all a bit hairy. We shouldn't need to be creating the
TemplateNestedResource here, ideally `self` should already refer to
one and value should already be a map[string]inteface{}
type Properties ¶
func (Properties) PropertyDefault ¶
func (p Properties) PropertyDefault(name string) (interface{}, bool)
func (Properties) Validate ¶
func (p Properties) Validate(ctx ResourceContext) reporting.Reports
type PropertyContext ¶
type PropertyContext interface {
Options() ValidationOptions
CurrentResource() constraints.CurrentResource
Definitions() ResourceDefinitions
Path() []string
Property() Schema
Template() *parse.Template
}
func NewPropertyContext ¶
func NewPropertyContext(ctx ResourceContext, property Schema) PropertyContext
func PropertyContextAdd ¶
func PropertyContextAdd(ctx PropertyContext, path ...string) PropertyContext
type PropertyDefaults ¶
type PropertyType ¶
type PropertyType interface {
// Describe returns a human-readable description of the type in AWS, which
// could be the AWS Resource Type or just any arbitrary description.
Describe() string
// Same returns true when two PropertyTypes represent the same AWS type.
Same(PropertyType) bool
// Validate checks that the property is valid, including any built-in function
// calls and stuff within the property.
Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
// CoercibleTo will return true for types which the value of this property can
// be coerced into. e.g. A number can be coerced to a string
// CoercionAlways means a type is always coercible to another
// e.g. all numbers are valid strings
// CoercionNever means a type is never coercible to another
// e.g. a number is never a valid bool
// CoercionBegrudgingly means a type can be coerced but results may vary
// e.g. a string can be coerced to a number, but only if it is numerically
// valid.
//
// CoerceAlways and CoercionBegrudgingly are equivalent right now, but in
// future a warning may be issued for begrudging conversions.
CoercibleTo(PropertyType) Coercion
// PropertyDefault returns the default value for a property, if one is set.
PropertyDefault(name string) (interface{}, bool)
}
func ConstrainedString ¶ added in v0.3.0
func ConstrainedString(description string, fn constrainedStringValidate) PropertyType
func Multiple ¶ added in v0.2.0
func Multiple(pt PropertyType) PropertyType
type RefTarget ¶
type RefTarget interface {
TargetType() PropertyType
}
type Resource ¶
type Resource struct {
AwsType string
Attributes map[string]Schema
Properties ValidatableProperties
ReturnValue Schema
ValidateFunc func(ResourceContext) (reporting.ValidateResult, reporting.Reports)
}
func NewUnrecognisedResource ¶
func (Resource) PropertyDefault ¶ added in v0.2.0
func (Resource) TargetType ¶
func (rd Resource) TargetType() PropertyType
func (Resource) Validate ¶
func (rd Resource) Validate(ctx ResourceContext) (reporting.ValidateResult, reporting.Reports)
type ResourceContext ¶
type ResourceContext interface {
Options() ValidationOptions
CurrentResource() constraints.CurrentResource
Definitions() ResourceDefinitions
Path() []string
Template() *parse.Template
}
func NewResourceContext ¶
func NewResourceContext(ctx Context, currentResource constraints.CurrentResource) ResourceContext
func ResourceContextAdd ¶
func ResourceContextAdd(ctx ResourceContext, path ...string) ResourceContext
type ResourceDefinitions ¶
type ResourceDefinitions interface {
Lookup(awsType string) Resource
LookupParameter(awsType string) Schema
}
func NewResourceDefinitions ¶
func NewResourceDefinitions(definitions map[string]Resource) ResourceDefinitions
type ResourceWithDefinition ¶
type ResourceWithDefinition struct {
parse.TemplateResource
PropertyDefaults
}
func (ResourceWithDefinition) AwsType ¶ added in v0.2.0
func (r ResourceWithDefinition) AwsType() string
func (ResourceWithDefinition) Id ¶ added in v0.2.0
func (r ResourceWithDefinition) Id() string
func (ResourceWithDefinition) PropertyValueOrDefault ¶
func (r ResourceWithDefinition) PropertyValueOrDefault(name string) (interface{}, bool)
type Schema ¶
type Schema struct {
// Conflicts is an array of property names which cannot also be specified when
// this property is too.
Conflicts constraints.Constraint
// Default is the AWS default value for this property; this is used for
// validations when the property isn't specified
//
// e.g. prop X must be set to false when prop Y is true, if prop Y unspecified
// but has a Default of true then this validation can safely fail.
Default interface{}
// Deprecated indicates that this property has been deprecated and should no
// longer be used (although may still work for an indeterimate amount of time)
// Some properties are replaced by others, or separate resources.
Deprecated deprecations.Deprecation
// Required is set to true if this property must have a value in the template
Required constraints.Constraint
// Type is the type of the Value this property is expected to contain. For
// example "String", "Number", "JSON", or nested resources such as Tags.
Type PropertyType
// ValidateFunc can be used to supply a custom validation function for a
// property for applying further validation on top of basic type checks.
//
// e.g. prop X must be set to false when prop Y is true
ValidateFunc ValidateFunc
}
A Schema defines the qualities and behaviour of a property.
func (Schema) TargetType ¶
func (s Schema) TargetType() PropertyType
func (Schema) Validate ¶
func (s Schema) Validate(value interface{}, ctx ResourceContext) (reporting.ValidateResult, reporting.Reports)
type SupportedFunctions ¶ added in v0.2.0
type SupportedFunctions map[parse.IntrinsicFunctionSignature]bool
type UnsupportedProperties ¶ added in v0.2.0
type UnsupportedProperties struct{}
UnsupportedProperties is a convinience type to give less intrusive errors for resource types we haven't implemented yet. People will get one "unsupported" warning per-resource, rather than lots of "unknown property" errors.
func (UnsupportedProperties) PropertyDefault ¶ added in v0.2.0
func (UnsupportedProperties) PropertyDefault(name string) (interface{}, bool)
func (UnsupportedProperties) Validate ¶ added in v0.2.0
func (UnsupportedProperties) Validate(ctx ResourceContext) reporting.Reports
type ValidatableProperties ¶ added in v0.2.0
type ValidatableProperties interface {
PropertyDefault(string) (interface{}, bool)
Validate(ResourceContext) reporting.Reports
// contains filtered or unexported methods
}
ValidatableProperties is a wrapper around Properties to allow us to support undefined or unsupported properties
type ValidateFunc ¶
type ValidateFunc func(interface{}, PropertyContext) (reporting.ValidateResult, reporting.Reports)
func IntegerRangeValidate ¶
func IntegerRangeValidate(start, end float64) ValidateFunc
func NumberOptions ¶
func NumberOptions(numbers ...float64) ValidateFunc
func RegexpValidate ¶
func RegexpValidate(pattern, message string) ValidateFunc
func SingleValueValidate ¶
func SingleValueValidate(expected interface{}) ValidateFunc
func StringLengthValidate ¶
func StringLengthValidate(min, max int) ValidateFunc
type ValidateOption ¶ added in v0.2.0
type ValidateOption int
const (
OptionExperimentDisableObjectArrayCoercion ValidateOption = iota
)
func (ValidateOption) String ¶ added in v0.2.0
func (i ValidateOption) String() string
type ValidationOptions ¶ added in v0.2.0
type ValidationOptions map[ValidateOption]bool
type ValueType ¶
type ValueType int
func (ValueType) CoercibleTo ¶
func (from ValueType) CoercibleTo(to PropertyType) Coercion
TODO: This really feels like it can be simplified
func (ValueType) PropertyDefault ¶
func (ValueType) Same ¶ added in v0.2.0
func (from ValueType) Same(to PropertyType) bool
func (ValueType) Validate ¶
func (vt ValueType) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
Source Files
¶
- array_property_type.go
- coercion.go
- context.go
- empty_current_resource.go
- func_type.go
- if_and.go
- if_and_or.go
- if_base_64.go
- if_basics.go
- if_condition.go
- if_equals.go
- if_find_in_map.go
- if_get_att.go
- if_get_azs.go
- if_if.go
- if_join.go
- if_not.go
- if_or.go
- if_ref.go
- if_select.go
- if_validate.go
- nested_resource.go
- properties.go
- property_type.go
- resource.go
- resource_definitions.go
- resource_with_definition.go
- schema.go
- template.go
- validate_options.go
- validateoption_string.go
- validations.go
- value_arn.go
- value_availability_zone.go
- value_cidr.go
- value_enum.go
- value_hosted_zone_id.go
- value_id.go
- value_ip_address.go
- value_json.go
- value_key_name.go
- value_period.go
- value_security_group_name.go
- value_timestamp.go
- valuetype.go
- valuetype_string.go
Click to show internal directories.
Click to hide internal directories.