當前位置: 首頁>>代碼示例>>Golang>>正文


Golang schema.NewSet函數代碼示例

本文整理匯總了Golang中github.com/hashicorp/terraform/helper/schema.NewSet函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewSet函數的具體用法?Golang NewSet怎麽用?Golang NewSet使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewSet函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: flattenLambdaVpcConfigResponse

func flattenLambdaVpcConfigResponse(s *lambda.VpcConfigResponse) []map[string]interface{} {
	settings := make(map[string]interface{}, 0)

	if s == nil {
		return nil
	}

	settings["subnet_ids"] = schema.NewSet(schema.HashString, flattenStringList(s.SubnetIds))
	settings["security_group_ids"] = schema.NewSet(schema.HashString, flattenStringList(s.SecurityGroupIds))
	settings["vpc_id"] = *s.VpcId

	return []map[string]interface{}{settings}
}
開發者ID:fromonesrc,項目名稱:terraform,代碼行數:13,代碼來源:structure.go

示例2: dataSourceAwsCloudFormationStackRead

func dataSourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).cfconn
	name := d.Get("name").(string)
	input := cloudformation.DescribeStacksInput{
		StackName: aws.String(name),
	}

	out, err := conn.DescribeStacks(&input)
	if err != nil {
		return fmt.Errorf("Failed describing CloudFormation stack (%s): %s", name, err)
	}
	if l := len(out.Stacks); l != 1 {
		return fmt.Errorf("Expected 1 CloudFormation stack (%s), found %d", name, l)
	}
	stack := out.Stacks[0]
	d.SetId(*stack.StackId)

	d.Set("description", stack.Description)
	d.Set("disable_rollback", stack.DisableRollback)
	d.Set("timeout_in_minutes", stack.TimeoutInMinutes)

	if len(stack.NotificationARNs) > 0 {
		d.Set("notification_arns", schema.NewSet(schema.HashString, flattenStringList(stack.NotificationARNs)))
	}

	d.Set("parameters", flattenAllCloudFormationParameters(stack.Parameters))
	d.Set("tags", flattenCloudFormationTags(stack.Tags))
	d.Set("outputs", flattenCloudFormationOutputs(stack.Outputs))

	if len(stack.Capabilities) > 0 {
		d.Set("capabilities", schema.NewSet(schema.HashString, flattenStringList(stack.Capabilities)))
	}

	tInput := cloudformation.GetTemplateInput{
		StackName: aws.String(name),
	}
	tOut, err := conn.GetTemplate(&tInput)
	if err != nil {
		return err
	}

	template, err := normalizeJsonString(*tOut.TemplateBody)
	if err != nil {
		return errwrap.Wrapf("template body contains an invalid JSON: {{err}}", err)
	}
	d.Set("template_body", template)

	return nil
}
開發者ID:paultyng,項目名稱:terraform,代碼行數:49,代碼來源:data_source_aws_cloudformation_stack.go

示例3: resourceDigitalOceanVolumeRead

func resourceDigitalOceanVolumeRead(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*godo.Client)

	volume, resp, err := client.Storage.GetVolume(d.Id())
	if err != nil {
		// If the volume is somehow already destroyed, mark as
		// successfully gone
		if resp.StatusCode == 404 {
			d.SetId("")
			return nil
		}

		return fmt.Errorf("Error retrieving volume: %s", err)
	}

	d.Set("id", volume.ID)

	dids := make([]interface{}, 0, len(volume.DropletIDs))
	for _, did := range volume.DropletIDs {
		dids = append(dids, did)
	}
	d.Set("droplet_ids", schema.NewSet(
		func(dropletID interface{}) int { return dropletID.(int) },
		dids,
	))

	return nil
}
開發者ID:Originate,項目名稱:terraform,代碼行數:28,代碼來源:resource_digitalocean_volume.go

示例4: TestBuildTriggerConfigs

func TestBuildTriggerConfigs(t *testing.T) {
	input := []interface{}{
		map[string]interface{}{
			"trigger_events": schema.NewSet(schema.HashString, []interface{}{
				"DeploymentFailure",
			}),
			"trigger_name":       "foo-trigger",
			"trigger_target_arn": "arn:aws:sns:us-west-2:123456789012:foo-topic",
		},
	}

	expected := []*codedeploy.TriggerConfig{
		&codedeploy.TriggerConfig{
			TriggerEvents: []*string{
				aws.String("DeploymentFailure"),
			},
			TriggerName:      aws.String("foo-trigger"),
			TriggerTargetArn: aws.String("arn:aws:sns:us-west-2:123456789012:foo-topic"),
		},
	}

	actual := buildTriggerConfigs(input)

	if !reflect.DeepEqual(actual, expected) {
		t.Fatalf("buildTriggerConfigs output is not correct.\nGot:\n%#v\nExpected:\n%#v\n",
			actual, expected)
	}
}
開發者ID:srikalyan,項目名稱:terraform,代碼行數:28,代碼來源:resource_aws_codedeploy_deployment_group_test.go

示例5: resourceAwsDirectoryServiceDirectoryRead

func resourceAwsDirectoryServiceDirectoryRead(d *schema.ResourceData, meta interface{}) error {
	dsconn := meta.(*AWSClient).dsconn

	input := directoryservice.DescribeDirectoriesInput{
		DirectoryIds: []*string{aws.String(d.Id())},
	}
	out, err := dsconn.DescribeDirectories(&input)
	if err != nil {
		return err
	}

	dir := out.DirectoryDescriptions[0]
	log.Printf("[DEBUG] Received DS directory: %s", *dir)

	d.Set("access_url", *dir.AccessUrl)
	d.Set("alias", *dir.Alias)
	if dir.Description != nil {
		d.Set("description", *dir.Description)
	}
	d.Set("dns_ip_addresses", schema.NewSet(schema.HashString, flattenStringList(dir.DnsIpAddrs)))
	d.Set("name", *dir.Name)
	if dir.ShortName != nil {
		d.Set("short_name", *dir.ShortName)
	}
	d.Set("size", *dir.Size)
	d.Set("type", *dir.Type)
	d.Set("vpc_settings", flattenDSVpcSettings(dir.VpcSettings))
	d.Set("enable_sso", *dir.SsoEnabled)

	return nil
}
開發者ID:AssertSelenium,項目名稱:terraform,代碼行數:31,代碼來源:resource_aws_directory_service_directory.go

示例6: flattenCustomErrorResponses

func flattenCustomErrorResponses(ers *cloudfront.CustomErrorResponses) *schema.Set {
	s := []interface{}{}
	for _, v := range ers.Items {
		s = append(s, flattenCustomErrorResponse(v))
	}
	return schema.NewSet(customErrorResponseHash, s)
}
開發者ID:chandy,項目名稱:terraform,代碼行數:7,代碼來源:cloudfront_distribution_configuration_structure.go

示例7: flattenLoggingConfig

func flattenLoggingConfig(lc *cloudfront.LoggingConfig) *schema.Set {
	m := make(map[string]interface{})
	m["prefix"] = *lc.Prefix
	m["bucket"] = *lc.Bucket
	m["include_cookies"] = *lc.IncludeCookies
	return schema.NewSet(loggingConfigHash, []interface{}{m})
}
開發者ID:chandy,項目名稱:terraform,代碼行數:7,代碼來源:cloudfront_distribution_configuration_structure.go

示例8: flattenOrigins

func flattenOrigins(ors *cloudfront.Origins) *schema.Set {
	s := []interface{}{}
	for _, v := range ors.Items {
		s = append(s, flattenOrigin(v))
	}
	return schema.NewSet(originHash, s)
}
開發者ID:chandy,項目名稱:terraform,代碼行數:7,代碼來源:cloudfront_distribution_configuration_structure.go

示例9: flattenCustomHeaders

func flattenCustomHeaders(chs *cloudfront.CustomHeaders) *schema.Set {
	s := []interface{}{}
	for _, v := range chs.Items {
		s = append(s, flattenOriginCustomHeader(v))
	}
	return schema.NewSet(originCustomHeaderHash, s)
}
開發者ID:chandy,項目名稱:terraform,代碼行數:7,代碼來源:cloudfront_distribution_configuration_structure.go

示例10: flattenCacheBehavior

func flattenCacheBehavior(cb *cloudfront.CacheBehavior) map[string]interface{} {
	m := make(map[string]interface{})

	m["compress"] = *cb.Compress
	m["viewer_protocol_policy"] = *cb.ViewerProtocolPolicy
	m["target_origin_id"] = *cb.TargetOriginId
	m["forwarded_values"] = schema.NewSet(forwardedValuesHash, []interface{}{flattenForwardedValues(cb.ForwardedValues)})
	m["min_ttl"] = int(*cb.MinTTL)

	if len(cb.TrustedSigners.Items) > 0 {
		m["trusted_signers"] = flattenTrustedSigners(cb.TrustedSigners)
	}
	if cb.MaxTTL != nil {
		m["max_ttl"] = int(*cb.MaxTTL)
	}
	if cb.SmoothStreaming != nil {
		m["smooth_streaming"] = *cb.SmoothStreaming
	}
	if cb.DefaultTTL != nil {
		m["default_ttl"] = int(*cb.DefaultTTL)
	}
	if cb.AllowedMethods != nil {
		m["allowed_methods"] = flattenAllowedMethods(cb.AllowedMethods)
	}
	if cb.AllowedMethods.CachedMethods != nil {
		m["cached_methods"] = flattenCachedMethods(cb.AllowedMethods.CachedMethods)
	}
	if cb.PathPattern != nil {
		m["path_pattern"] = *cb.PathPattern
	}
	return m
}
開發者ID:chandy,項目名稱:terraform,代碼行數:32,代碼來源:cloudfront_distribution_configuration_structure.go

示例11: TestBuildAlarmConfig

func TestBuildAlarmConfig(t *testing.T) {
	input := []interface{}{
		map[string]interface{}{
			"alarms": schema.NewSet(schema.HashString, []interface{}{
				"foo-alarm",
			}),
			"enabled":                   true,
			"ignore_poll_alarm_failure": false,
		},
	}

	expected := &codedeploy.AlarmConfiguration{
		Alarms: []*codedeploy.Alarm{
			{
				Name: aws.String("foo-alarm"),
			},
		},
		Enabled:                aws.Bool(true),
		IgnorePollAlarmFailure: aws.Bool(false),
	}

	actual := buildAlarmConfig(input)

	if !reflect.DeepEqual(actual, expected) {
		t.Fatalf("buildAlarmConfig output is not correct.\nGot:\n%#v\nExpected:\n%#v\n",
			actual, expected)
	}
}
開發者ID:anthcor,項目名稱:terraform,代碼行數:28,代碼來源:resource_aws_codedeploy_deployment_group_test.go

示例12: forwardedValuesConf

func forwardedValuesConf() map[string]interface{} {
	return map[string]interface{}{
		"query_string": true,
		"cookies":      schema.NewSet(cookiePreferenceHash, []interface{}{cookiePreferenceConf()}),
		"headers":      headersConf(),
	}
}
開發者ID:mrjefftang,項目名稱:terraform,代碼行數:7,代碼來源:cloudfront_distribution_configuration_structure_test.go

示例13: flattenCacheBehaviors

func flattenCacheBehaviors(cbs *cloudfront.CacheBehaviors) *schema.Set {
	s := []interface{}{}
	for _, v := range cbs.Items {
		s = append(s, flattenCacheBehavior(v))
	}
	return schema.NewSet(cacheBehaviorHash, s)
}
開發者ID:chandy,項目名稱:terraform,代碼行數:7,代碼來源:cloudfront_distribution_configuration_structure.go

示例14: resourceAwsEfsMountTargetRead

func resourceAwsEfsMountTargetRead(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).efsconn
	resp, err := conn.DescribeMountTargets(&efs.DescribeMountTargetsInput{
		MountTargetId: aws.String(d.Id()),
	})
	if err != nil {
		return err
	}

	if len(resp.MountTargets) < 1 {
		return fmt.Errorf("EFS mount target %q not found", d.Id())
	}

	mt := resp.MountTargets[0]

	log.Printf("[DEBUG] Found EFS mount target: %#v", mt)

	d.SetId(*mt.MountTargetId)
	d.Set("file_system_id", *mt.FileSystemId)
	d.Set("ip_address", *mt.IpAddress)
	d.Set("subnet_id", *mt.SubnetId)
	d.Set("network_interface_id", *mt.NetworkInterfaceId)

	sgResp, err := conn.DescribeMountTargetSecurityGroups(&efs.DescribeMountTargetSecurityGroupsInput{
		MountTargetId: aws.String(d.Id()),
	})
	if err != nil {
		return err
	}

	d.Set("security_groups", schema.NewSet(schema.HashString, flattenStringList(sgResp.SecurityGroups)))

	return nil
}
開發者ID:AssertSelenium,項目名稱:terraform,代碼行數:34,代碼來源:resource_aws_efs_mount_target.go

示例15: makeStringSet

//Convert slice of strings to schema.Set
func makeStringSet(list *[]string) *schema.Set {
	ilist := make([]interface{}, len(*list))
	for i, v := range *list {
		ilist[i] = v
	}
	return schema.NewSet(schema.HashString, ilist)
}
開發者ID:DealerDotCom,項目名稱:terraform-provider-bigip,代碼行數:8,代碼來源:provider.go


注:本文中的github.com/hashicorp/terraform/helper/schema.NewSet函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。