本文整理匯總了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}
}
示例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
}
示例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
}
示例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)
}
}
示例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
}
示例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)
}
示例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})
}
示例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)
}
示例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)
}
示例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
}
示例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)
}
}
示例12: forwardedValuesConf
func forwardedValuesConf() map[string]interface{} {
return map[string]interface{}{
"query_string": true,
"cookies": schema.NewSet(cookiePreferenceHash, []interface{}{cookiePreferenceConf()}),
"headers": headersConf(),
}
}
示例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)
}
示例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
}
示例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)
}