本文整理汇总了Golang中github.com/jagregory/cfval/constraints.PropertyNotExists函数的典型用法代码示例。如果您正苦于以下问题:Golang PropertyNotExists函数的具体用法?Golang PropertyNotExists怎么用?Golang PropertyNotExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PropertyNotExists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestResourcePropertyRequiredUnlessValidation
func TestResourcePropertyRequiredUnlessValidation(t *testing.T) {
template := &parse.Template{}
res := Resource{
Properties: Properties{
"Option1": Schema{
Type: ValueString,
Required: constraints.PropertyNotExists("Option2"),
},
"Option2": Schema{
Type: ValueString,
},
},
}
ctx := NewInitialContext(template, NewResourceDefinitions(map[string]Resource{
"TestResource": res,
}), ValidationOptions{})
nothingSet := ResourceWithDefinition{
parse.NewTemplateResource("TestResource", map[string]interface{}{}),
res,
}
option1Set := ResourceWithDefinition{
parse.NewTemplateResource("TestResource", map[string]interface{}{
"Option1": "value",
}),
res,
}
option2Set := ResourceWithDefinition{
parse.NewTemplateResource("TestResource", map[string]interface{}{
"Option2": "value",
}),
res,
}
bothSet := ResourceWithDefinition{
parse.NewTemplateResource("TestResource", map[string]interface{}{
"Option1": "value",
"Option2": "value",
}),
res,
}
if _, errs := res.Validate(NewResourceContext(ctx, nothingSet)); errs == nil {
t.Error("Resource should fail if neither Option1 or Option2 are set")
}
if _, errs := res.Validate(NewResourceContext(ctx, option1Set)); errs != nil {
t.Error("Resource should pass if only Option1 set", errs)
}
if _, errs := res.Validate(NewResourceContext(ctx, option2Set)); errs != nil {
t.Error("Resource should pass if only Option2 set", errs)
}
if _, errs := res.Validate(NewResourceContext(ctx, bothSet)); errs != nil {
t.Error("Resource should pass if both Option1 and Option2 are set", errs)
}
}
示例2:
"github.com/jagregory/cfval/constraints"
. "github.com/jagregory/cfval/schema"
)
// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-healthcheck-healthcheckconfig.html
var healthCheckConfig = NestedResource{
Description: "Route 53 HealthCheckConfig",
Properties: Properties{
"FailureThreshold": Schema{
Type: ValueNumber,
},
"FullyQualifiedDomainName": Schema{
Type: ValueString,
Required: constraints.PropertyNotExists("IPAddress"),
},
"IPAddress": Schema{
Type: IPAddress,
Required: constraints.PropertyNotExists("FullyQualifiedDomainName"),
},
"Port": Schema{
Type: ValueNumber,
Required: constraints.PropertyIs("Type", "TCP"),
},
"RequestInterval": Schema{
Type: ValueNumber,
},
示例3:
package cloud_front
import (
"github.com/jagregory/cfval/constraints"
. "github.com/jagregory/cfval/schema"
)
var viewerCertificate = NestedResource{
Description: "CloudFront DistributionConfiguration ViewerCertificate",
Properties: Properties{
"CloudFrontDefaultCertificate": Schema{
Type: ValueBool,
Conflicts: constraints.PropertyExists("IamCertificateId"),
Required: constraints.PropertyNotExists("IamCertificateId"),
},
"IamCertificateId": Schema{
Type: ValueString,
Conflicts: constraints.PropertyExists("CloudFrontDefaultCertificate"),
Required: constraints.PropertyNotExists("CloudFrontDefaultCertificate"),
},
"MinimumProtocolVersion": Schema{
Type: ValueString,
// TODO: If you specify the IamCertificateId property and specify SNI only
// for the SslSupportMethod property, you must use TLSv1 for the
// minimum protocol version. If you don't specify a value, AWS
// CloudFormation specifies SSLv3.
},
"SslSupportMethod": Schema{
示例4:
. "github.com/jagregory/cfval/schema"
)
// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-security-group-egress.html
var SecurityGroupEgress = Resource{
AwsType: "AWS::EC2::SecurityGroupEgress",
// Name
ReturnValue: Schema{
Type: ValueString,
},
Properties: Properties{
"CidrIp": Schema{
Type: CIDR,
Required: constraints.PropertyNotExists("DestinationSecurityGroupId"),
Conflicts: constraints.PropertyExists("DestinationSecurityGroupId"),
},
"DestinationSecurityGroupId": Schema{
Type: SecurityGroupID,
Required: constraints.PropertyNotExists("CidrIp"),
Conflicts: constraints.PropertyExists("CidrIp"),
},
"FromPort": Schema{
Type: ValueNumber,
Required: constraints.Always,
},
"GroupId": Schema{
示例5:
"Description": Schema{
Type: ValueString,
},
"EnvironmentName": Schema{
Type: ValueString,
},
"OptionSettings": Schema{
Type: Multiple(optionsSettings),
},
"SolutionStackName": Schema{
Type: ValueString,
Required: constraints.PropertyNotExists("TemplateName"),
},
"Tags": Schema{
Type: Multiple(common.ResourceTag),
},
"TemplateName": Schema{
Type: ValueString,
Required: constraints.PropertyNotExists("SolutionStackName"),
},
"Tier": Schema{
Type: tier,
},
示例6:
"CidrIp": Schema{
Type: CIDR,
Conflicts: constraints.Any{
constraints.PropertyExists("SourceSecurityGroupName"),
constraints.PropertyExists("SourceSecurityGroupId"),
},
},
"FromPort": Schema{
Type: ValueNumber,
Required: constraints.Always,
},
"GroupId": Schema{
Type: SecurityGroupID,
Required: constraints.PropertyNotExists("GroupName"),
},
"GroupName": Schema{
Type: SecurityGroupName,
Required: constraints.PropertyNotExists("GroupId"),
},
"IpProtocol": Schema{
Required: constraints.Always,
Type: ipProtocol,
},
"SourceSecurityGroupId": Schema{
Type: SecurityGroupID,
Conflicts: constraints.PropertyExists("CidrIp"),
示例7:
. "github.com/jagregory/cfval/schema"
)
// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html
var AutoScalingGroup = Resource{
AwsType: "AWS::AutoScaling::AutoScalingGroup",
// Name
ReturnValue: Schema{
Type: ValueString,
},
Properties: Properties{
"AvailabilityZones": Schema{
Type: Multiple(AvailabilityZone),
Required: constraints.PropertyNotExists("VPCZoneIdentifier"),
},
"Cooldown": Schema{
Type: ValueString,
},
"DesiredCapacity": Schema{
Type: ValueString,
},
"HealthCheckGracePeriod": Schema{
Type: ValueNumber,
},
"HealthCheckType": Schema{
示例8:
. "github.com/jagregory/cfval/schema"
)
// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpc-gateway-attachment.html
var VPCGatewayAttachment = Resource{
AwsType: "AWS::EC2::VPCGatewayAttachment",
// Name
ReturnValue: Schema{
Type: ValueString,
},
Properties: Properties{
"InternetGatewayId": Schema{
Type: InternetGatewayID,
Required: constraints.PropertyNotExists("VpnGatewayId"),
Conflicts: constraints.PropertyExists("VpnGatewayId"),
},
"VpcId": Schema{
Required: constraints.Always,
Type: VpcID,
},
"VpnGatewayId": Schema{
Type: VpnGatewayID,
Required: constraints.PropertyNotExists("InternetGatewayId"),
Conflicts: constraints.PropertyExists("InternetGatewayId"),
},
},
}
示例9:
Required: constraints.PropertyExists("KmsKeyId"),
},
"Iops": Schema{
Type: ValueNumber,
Required: constraints.PropertyIs("VolumeType", "io1"),
ValidateFunc: IntegerRangeValidate(1, 4000),
},
"KmsKeyId": Schema{
Type: ARN,
},
"Size": Schema{
Type: ValueString,
Required: constraints.PropertyNotExists("SnapshotId"),
},
"SnapshotId": Schema{
Type: ValueString,
},
"Tags": Schema{
Type: Multiple(common.ResourceTag),
},
"VolumeType": Schema{
Type: common.EbsVolumeType,
},
},
}
示例10:
"EngineVersion": Schema{
Type: ValueString,
},
"KmsKeyId": Schema{
Type: ARN,
},
"MasterUsername": Schema{
Type: ValueString,
ValidateFunc: RegexpValidate(
`^[a-zA-Z][a-zA-Z0-9]{1,15}$`,
"Must be 1 to 16 alphanumeric characters. First character must be a letter.",
),
Required: constraints.PropertyNotExists("SnapshotIdentifier"),
Conflicts: constraints.PropertyExists("SnapshotIdentifier"),
},
"MasterUserPassword": Schema{
Type: ValueString,
ValidateFunc: RegexpValidate(
`^[^\/"@]{8,41}$`,
`This password can contain any printable ASCII character except "/", """, or "@". Must contain from 8 to 41 characters.`,
),
Required: constraints.PropertyNotExists("SnapshotIdentifier"),
Conflicts: constraints.PropertyExists("SnapshotIdentifier"),
},
"Port": Schema{
Type: ValueNumber,
示例11:
package cloud_front
import (
"github.com/jagregory/cfval/constraints"
. "github.com/jagregory/cfval/schema"
)
// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-origin.html
var origin = NestedResource{
Description: "CloudFront DistributionConfig Origin",
Properties: Properties{
"CustomOriginConfig": Schema{
Type: customOriginConfig,
Conflicts: constraints.PropertyExists("S3OriginConfig"),
Required: constraints.PropertyNotExists("S3OriginConfig"),
},
"DomainName": Schema{
Type: ValueString,
Required: constraints.Always,
},
"Id": Schema{
Type: ValueString,
Required: constraints.Always,
},
"OriginPath": Schema{
Type: ValueString,
ValidateFunc: RegexpValidate(`^\/.*?[^\/]$`, "The value must start with a slash mark (/) and cannot end with a slash mark."),
},
示例12:
package s3
import (
"github.com/jagregory/cfval/constraints"
. "github.com/jagregory/cfval/schema"
)
// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig-rule-transition.html
var lifecycleRuleTransition = NestedResource{
Description: "S3 Lifecycle Rule Transition",
Properties: Properties{
"StorageClass": Schema{
Type: storageClass,
Required: constraints.Always,
},
"TransitionDate": Schema{
Type: ValueString,
Required: constraints.PropertyNotExists("TransitionInDays"),
},
"TransitionInDays": Schema{
Type: ValueNumber,
Required: constraints.PropertyNotExists("TransitionDate"),
},
},
}
示例13:
package s3
import (
"github.com/jagregory/cfval/constraints"
. "github.com/jagregory/cfval/schema"
)
// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-routingrules-routingrulecondition.html
var websiteConfigurationRoutingRuleCondition = NestedResource{
Description: "S3 Website Configuration Routing Rules Routing Rule Condition",
Properties: Properties{
"HttpErrorCodeReturnedEquals": Schema{
Type: ValueString,
Required: constraints.PropertyNotExists("KeyPrefixEquals"),
},
"KeyPrefixEquals": Schema{
Type: ValueString,
Required: constraints.PropertyNotExists("HttpErrorCodeReturnedEquals"),
},
},
}
示例14:
)
// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-policy.html
var Policy = Resource{
AwsType: "AWS::IAM::Policy",
// Name
ReturnValue: Schema{
Type: ValueString,
},
Properties: Properties{
"Groups": Schema{
Type: Multiple(ValueString),
Required: constraints.All{
constraints.PropertyNotExists("Roles"),
constraints.PropertyNotExists("Users"),
},
},
"PolicyDocument": Schema{
Type: JSON,
Required: constraints.Always,
},
"PolicyName": Schema{
Type: ValueString,
Required: constraints.Always,
},
"Roles": Schema{
示例15:
package s3
import (
"github.com/jagregory/cfval/constraints"
. "github.com/jagregory/cfval/schema"
)
// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig-rule.html
var lifecycleRule = NestedResource{
Description: "AWS::S3::LifecycleRule",
Properties: Properties{
"ExpirationDate": Schema{
Type: ValueString,
Required: constraints.All{
constraints.PropertyNotExists("ExpirationInDays"),
constraints.PropertyNotExists("NoncurrentVersionExpirationInDays"),
constraints.PropertyNotExists("NoncurrentVersionTransition"),
constraints.PropertyNotExists("Transition"),
},
},
"ExpirationInDays": Schema{
Type: ValueNumber,
Required: constraints.All{
constraints.PropertyNotExists("ExpirationDate"),
constraints.PropertyNotExists("NoncurrentVersionExpirationInDays"),
constraints.PropertyNotExists("NoncurrentVersionTransition"),
constraints.PropertyNotExists("Transition"),
},
},