• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang constraints.PropertyNotExists函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/jagregory/cfval/constraints.PropertyNotExists函数的典型用法代码示例。如果您正苦于以下问题:Golang PropertyNotExists函数的具体用法?Golang PropertyNotExists怎么用?Golang PropertyNotExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PropertyNotExists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: recordSetProperties

func recordSetProperties(includeComment bool) Properties {
	properties := Properties{
		"AliasTarget": Schema{
			Type: aliasTarget,
			Conflicts: constraints.Any{
				constraints.PropertyExists("ResourceRecords"),
				constraints.PropertyExists("TTL"),
			},
		},

		"Failover": Schema{
			Type: EnumValue{
				Description: "Failover",
				Options:     []string{"PRIMARY", "SECONDARY"},
			},
		},

		"GeoLocation": Schema{
			Type: geoLocation,
		},

		"HealthCheckId": Schema{
			Type: ValueString,
		},

		"HostedZoneId": Schema{
			Type:      HostedZoneID,
			Conflicts: constraints.PropertyExists("HostedZoneName"),
		},

		"HostedZoneName": Schema{
			Type:      ValueString,
			Conflicts: constraints.PropertyExists("HostedZoneId"),
		},

		"Name": Schema{
			Type:     ValueString,
			Required: constraints.Always,
		},

		// TODO: Region validation: http://docs.aws.amazon.com/general/latest/gr/rande.html
		"Region": Schema{
			Type: ValueString,
		},

		"ResourceRecords": Schema{
			Type:      Multiple(ValueString),
			Conflicts: constraints.PropertyExists("AliasTarget"),
			Required:  constraints.PropertyNotExists("AliasTarget"),
		},

		"SetIdentifier": Schema{
			Type: ValueString,
			Required: constraints.Any{
				constraints.PropertyExists("Weight"),
				constraints.PropertyExists("Latency"),
				constraints.PropertyExists("Failover"),
				constraints.PropertyExists("GeoLocation"),
			},
		},

		"TTL": Schema{
			Type:      ValueString,
			Conflicts: constraints.PropertyExists("AliasTarget"),
		},

		"Type": Schema{
			Type:     recordSetType,
			Required: constraints.Always,
		},

		"Weight": Schema{
			Type: ValueNumber,
		},
	}

	if includeComment {
		properties["Comment"] = Schema{
			Type: ValueString,
		}
	}

	return properties
}
开发者ID:jagregory,项目名称:cfval,代码行数:84,代码来源:record_set.go


示例17:

		"PrivateIpAddress": Schema{
			Type: IPAddress,
		},

		"PrivateIpAddresses": Schema{
			Type: Multiple(privateIPAddressSpecification),
		},

		"SecondaryPrivateIpAddressCount": Schema{
			Type: ValueNumber,
		},

		"SubnetId": Schema{
			Type:     SubnetID,
			Required: constraints.PropertyNotExists("NetworkInterfaceId"),
		},
	},
}

// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html
var Instance = Resource{
	AwsType: "AWS::EC2::Instance",

	Attributes: map[string]Schema{
		"AvailabilityZone": Schema{
			Type: AvailabilityZone,
		},

		"PrivateDnsName": Schema{
			Type: ValueString,
开发者ID:jagregory,项目名称:cfval,代码行数:30,代码来源:instance.go


示例18:

	},

	Properties: Properties{
		"ApplicationName": Schema{
			Type:     ValueString,
			Required: constraints.Always,
		},

		"Description": Schema{
			Type: ValueString,
		},

		"EnvironmentId": Schema{
			Type: ValueString,
			Required: constraints.All{
				constraints.PropertyNotExists("SolutionStackName"),
				constraints.PropertyNotExists("SourceConfiguration"),
			},
		},

		"OptionSettings": Schema{
			Type: Multiple(optionsSettings),
		},

		"SolutionStackName": Schema{
			Type: ValueString,
			Required: constraints.All{
				constraints.PropertyNotExists("EnvironmentId"),
				constraints.PropertyNotExists("SourceConfiguration"),
			},
		},
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:configuration_template.go


示例19:

	. "github.com/jagregory/cfval/schema"
)

// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-spotfleetrequestconfigdata-launchspecifications-blockdevicemappings.html
var spotFleetRequestConfigDataLaunchSpecificationBlockDeviceMapping = NestedResource{
	Description: "SpotFleet SpotFleetRequestConfigData LaunchSpecifications BlockDeviceMapping",

	Properties: Properties{
		"DeviceName": Schema{
			Type:     ValueString,
			Required: constraints.Always,
		},

		"Ebs": Schema{
			Type:      spotFleetRequestConfigDataLaunchSpecificationBlockDeviceMappingEbs,
			Required:  constraints.PropertyNotExists("VirtualName"),
			Conflicts: constraints.PropertyExists("VirtualName"),
		},

		"NoDevice": Schema{
			Type: ValueBool,
		},

		"VirtualName": Schema{
			Type:      ValueString,
			Required:  constraints.PropertyNotExists("Ebs"),
			Conflicts: constraints.PropertyExists("Ebs"),
			ValidateFunc: RegexpValidate(
				"^ephemeral\\d+$",
				"The name must be in the form ephemeralX where X is a number starting from zero (0), for example, ephemeral0",
			),
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:spot_fleet_request_config_data_launch_specification_block_device_mapping.go


示例20:

package route_53

import (
	"github.com/jagregory/cfval/constraints"
	"github.com/jagregory/cfval/reporting"
	"github.com/jagregory/cfval/resources/common"
	. "github.com/jagregory/cfval/schema"
)

// see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-geolocation.html
var geoLocation = NestedResource{
	Description: "Route 53 Record Set GeoLocation",
	Properties: Properties{
		"ContinentCode": Schema{
			Type:     continentCode,
			Required: constraints.PropertyNotExists("CountryCode"),
			Conflicts: constraints.Any{
				constraints.PropertyExists("CountryCode"),
				constraints.PropertyExists("SubdivisionCode"),
			},
		},

		"CountryCode": Schema{
			Type:      common.CountryCode,
			Required:  constraints.PropertyNotExists("ContinentCode"),
			Conflicts: constraints.PropertyExists("ContinentCode"),
		},

		"SubdivisionCode": Schema{
			Type:      subdivisionCode,
			Conflicts: constraints.PropertyExists("ContinentCode"),
开发者ID:jagregory,项目名称:cfval,代码行数:31,代码来源:geo_location.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang reporting.NewFailure函数代码示例发布时间:2022-05-23
下一篇:
Golang constraints.PropertyExists函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap