当前位置: 首页>>代码示例>>Golang>>正文


Golang constraints.PropertyNotExists函数代码示例

本文整理汇总了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)
	}
}
开发者ID:jagregory,项目名称:cfval,代码行数:58,代码来源:resource_test.go

示例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,
		},
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:health_check_config.go

示例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{
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:viewer_certificate.go

示例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{
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:security_group_egress.go

示例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,
		},
开发者ID:jagregory,项目名称:cfval,代码行数:29,代码来源:environment.go

示例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"),
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:security_group_ingress.go

示例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{
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:auto_scaling_group.go

示例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"),
		},
	},
}
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:vpc_gateway_attachment.go

示例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,
		},
	},
}
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:volume.go

示例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,
开发者ID:jagregory,项目名称:cfval,代码行数:30,代码来源:db_cluster.go

示例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."),
		},
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:origin.go

示例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"),
		},
	},
}
开发者ID:jagregory,项目名称:cfval,代码行数:27,代码来源:lifecycle_rule_transition.go

示例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"),
		},
	},
}
开发者ID:jagregory,项目名称:cfval,代码行数:22,代码来源:website_configuration_routing_rule_condition.go

示例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{
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:policy.go

示例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"),
			},
		},
开发者ID:jagregory,项目名称:cfval,代码行数:30,代码来源:lifecycle_rule.go


注:本文中的github.com/jagregory/cfval/constraints.PropertyNotExists函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。