Documentation
¶
Index ¶
- Constants
- Variables
- func TemplateValidate(template *parse.Template, definitions ResourceDefinitions) (bool, reporting.Reports)
- func ValidateBuiltinFns(value map[string]interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
- type Coercion
- type Context
- type EnumValue
- type FuncType
- func (from FuncType) CoercibleTo(to PropertyType) Coercion
- func (ft FuncType) Describe() string
- func (FuncType) PropertyDefault(string) (interface{}, bool)
- func (ft FuncType) String() string
- func (ft FuncType) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
- type GetAtt
- type NestedResource
- type Properties
- type PropertyContext
- type PropertyDefaults
- type PropertyType
- type Ref
- type RefTarget
- type Resource
- type ResourceContext
- type ResourceDefinitions
- type ResourceWithDefinition
- type Schema
- 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 ValueType
- func (from ValueType) CoercibleTo(to PropertyType) Coercion
- func (vt ValueType) Describe() string
- func (ValueType) PropertyDefault(string) (interface{}, 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 = FuncType{ Description: "CIDR", 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 } if ok, _ := regexp.MatchString(cidrPattern, value.(string)); !ok { return reporting.ValidateOK, reporting.Reports{reporting.NewFailure(ctx, "Cidr %s is invalid", value)} } return reporting.ValidateOK, nil }, }
View Source
var HostedZoneID = FuncType{ Description: "HostedZoneID", 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 IPAddress = FuncType{ Description: "IPAddress", 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 } if !ipAddressRegex.MatchString(value.(string)) { return reporting.ValidateOK, reporting.Reports{ reporting.NewFailure(ctx, "Value '%s' is not a valid IPv4 address", value), } } return reporting.ValidateOK, 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 = FuncType{ Description: "KeyName", 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 NetworkAclID = newResourceID("NetworkAclID", "acl", ShortID)
View Source
var NetworkInterfaceID = newResourceID("NetworkInterfaceID", "eni", ShortID)
View Source
var Period = FuncType{ Description: "Period", 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 } num, err := strconv.Atoi(value.(string)) if err != nil { return reporting.ValidateOK, reporting.Reports{reporting.NewFailure(ctx, "Period is not a number: %s", value)} } if num == 0 || num%60 != 0 { return reporting.ValidateOK, reporting.Reports{reporting.NewFailure(ctx, "Period is not a multiple of 60: %s", value)} } return reporting.ValidateOK, nil }, }
View Source
var RouteTableID = newResourceID("RouteTableID", "rtb", ShortID)
View Source
var SecurityGroupID = newResourceID("SecurityGroupID", "sg", ShortID)
View Source
var SecurityGroupName = FuncType{ Description: "SecurityGroupName", 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 SnapshotID = newResourceID("SnapshotID", "vol", LongID)
View Source
var SubnetID = newResourceID("SubnetID", "subnet", ShortID)
View Source
var Timestamp = FuncType{ Description: "Timestamp", Fn: RegexpValidate("^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$", "Not a valid Timestamp"), }
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 ValidateBuiltinFns ¶
func ValidateBuiltinFns(value map[string]interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
Types ¶
type Context ¶
type Context interface {
Definitions() ResourceDefinitions
Path() []string
Template() *parse.Template
}
func ContextAdd ¶
func NewInitialContext ¶
func NewInitialContext(template *parse.Template, definitions ResourceDefinitions) Context
type EnumValue ¶
func (EnumValue) CoercibleTo ¶
func (from EnumValue) CoercibleTo(to PropertyType) Coercion
func (EnumValue) PropertyDefault ¶
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) Validate ¶
func (ft FuncType) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
type GetAtt ¶
type GetAtt struct {
// contains filtered or unexported fields
}
func (GetAtt) Validate ¶
func (ga GetAtt) Validate(ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
type NestedResource ¶
type NestedResource struct {
Description string
Properties
}
func (NestedResource) CoercibleTo ¶
func (NestedResource) CoercibleTo(PropertyType) Coercion
func (NestedResource) Describe ¶
func (res NestedResource) Describe() string
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, map[string]bool)
type PropertyContext ¶
type PropertyContext interface {
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
// 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)
}
type Ref ¶
type Ref struct {
// contains filtered or unexported fields
}
func (Ref) Validate ¶
func (ref Ref) Validate(ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
type RefTarget ¶
type RefTarget interface {
TargetType() PropertyType
}
type Resource ¶
type Resource struct {
AwsType string
Attributes map[string]Schema
Properties
ReturnValue Schema
ValidateFunc func(ResourceContext) (reporting.ValidateResult, reporting.Reports)
}
func NewUnrecognisedResource ¶
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 {
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) PropertyValueOrDefault ¶
func (r ResourceWithDefinition) PropertyValueOrDefault(name string) (interface{}, bool)
type Schema ¶
type Schema struct {
// Array is true when the expected value is an array of Type
Array bool
// 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{}
// 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
}
func (Schema) TargetType ¶
func (s Schema) TargetType() PropertyType
func (Schema) Validate ¶
func (s Schema) Validate(value interface{}, ctx ResourceContext) (reporting.ValidateResult, reporting.Reports)
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 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) Validate ¶
func (vt ValueType) Validate(value interface{}, ctx PropertyContext) (reporting.ValidateResult, reporting.Reports)
Source Files
¶
- builtin_functions.go
- coercion.go
- context.go
- dsl.go
- empty_current_resource.go
- func_type.go
- get_att.go
- json.go
- nested_resource.go
- properties.go
- property_type.go
- ref.go
- resource.go
- resource_definitions.go
- resource_with_definition.go
- schema.go
- template.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_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.