本文整理汇总了Golang中github.com/aws/aws-sdk-go/aws.StringValueSlice函数的典型用法代码示例。如果您正苦于以下问题:Golang StringValueSlice函数的具体用法?Golang StringValueSlice怎么用?Golang StringValueSlice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StringValueSlice函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: buildStackDetails
func (s *CloudFormationStack) buildStackDetails(stack *cloudformation.Stack) StackDetails {
stackDetails := StackDetails{
StackName: aws.StringValue(stack.StackName),
Capabilities: aws.StringValueSlice(stack.Capabilities),
DisableRollback: aws.BoolValue(stack.DisableRollback),
Description: aws.StringValue(stack.Description),
NotificationARNs: aws.StringValueSlice(stack.NotificationARNs),
StackID: aws.StringValue(stack.StackId),
StackStatus: s.stackStatus(aws.StringValue(stack.StackStatus)),
TimeoutInMinutes: aws.Int64Value(stack.TimeoutInMinutes),
}
if stack.Parameters != nil && len(stack.Parameters) > 0 {
stackDetails.Parameters = make(map[string]string)
for _, parameter := range stack.Parameters {
stackDetails.Parameters[aws.StringValue(parameter.ParameterKey)] = aws.StringValue(parameter.ParameterValue)
}
}
if stack.Outputs != nil && len(stack.Outputs) > 0 {
stackDetails.Outputs = make(map[string]string)
for _, output := range stack.Outputs {
stackDetails.Outputs[aws.StringValue(output.OutputKey)] = aws.StringValue(output.OutputValue)
}
}
return stackDetails
}
示例2: Marshal
// Marshal parses the response from the aws sdk into an awsm LoadBalancer
func (l *LoadBalancer) Marshal(balancer *elb.LoadBalancerDescription, region string, secGrpList *SecurityGroups, vpcList *Vpcs, subList *Subnets) {
// security groups
secGroupNames := secGrpList.GetSecurityGroupNames(aws.StringValueSlice(balancer.SecurityGroups))
secGroupNamesSorted := sort.StringSlice(secGroupNames[0:])
secGroupNamesSorted.Sort()
// subnets
subnetNames := subList.GetSubnetNames(aws.StringValueSlice(balancer.Subnets))
subnetNamesSorted := sort.StringSlice(subnetNames[0:])
subnetNamesSorted.Sort()
l.Name = aws.StringValue(balancer.LoadBalancerName)
l.DNSName = aws.StringValue(balancer.DNSName)
l.CreatedTime = aws.TimeValue(balancer.CreatedTime) // robots
l.CreatedHuman = humanize.Time(l.CreatedTime) // humans
l.VpcID = aws.StringValue(balancer.VPCId)
l.Vpc = vpcList.GetVpcName(l.VpcID)
l.SubnetIDs = aws.StringValueSlice(balancer.Subnets)
l.Subnets = strings.Join(subnetNamesSorted, ", ")
l.HealthCheckTarget = aws.StringValue(balancer.HealthCheck.Target)
l.HealthCheckInterval = fmt.Sprintf("%d seconds", *balancer.HealthCheck.Interval)
l.Scheme = aws.StringValue(balancer.Scheme)
l.SecurityGroups = strings.Join(secGroupNamesSorted, ", ")
l.AvailabilityZones = strings.Join(aws.StringValueSlice(balancer.AvailabilityZones), ", ") // TODO
l.Region = region
}
示例3: flattenEc2Attributes
func flattenEc2Attributes(ia *emr.Ec2InstanceAttributes) []map[string]interface{} {
attrs := map[string]interface{}{}
result := make([]map[string]interface{}, 0)
if ia.Ec2KeyName != nil {
attrs["key_name"] = *ia.Ec2KeyName
}
if ia.Ec2SubnetId != nil {
attrs["subnet_id"] = *ia.Ec2SubnetId
}
if ia.IamInstanceProfile != nil {
attrs["instance_profile"] = *ia.IamInstanceProfile
}
if ia.EmrManagedMasterSecurityGroup != nil {
attrs["emr_managed_master_security_group"] = *ia.EmrManagedMasterSecurityGroup
}
if ia.EmrManagedSlaveSecurityGroup != nil {
attrs["emr_managed_slave_security_group"] = *ia.EmrManagedSlaveSecurityGroup
}
if len(ia.AdditionalMasterSecurityGroups) > 0 {
strs := aws.StringValueSlice(ia.AdditionalMasterSecurityGroups)
attrs["additional_master_security_groups"] = strings.Join(strs, ",")
}
if len(ia.AdditionalSlaveSecurityGroups) > 0 {
strs := aws.StringValueSlice(ia.AdditionalSlaveSecurityGroups)
attrs["additional_slave_security_groups"] = strings.Join(strs, ",")
}
result = append(result, attrs)
return result
}
示例4: TestConvertToTaskDefinitionWithDnsServers
func TestConvertToTaskDefinitionWithDnsServers(t *testing.T) {
dnsServer := "1.2.3.4"
serviceConfig := &libcompose.ServiceConfig{DNS: libcompose.NewStringorslice(dnsServer)}
taskDefinition := convertToTaskDefinitionInTest(t, "name", serviceConfig)
containerDef := *taskDefinition.ContainerDefinitions[0]
if !reflect.DeepEqual([]string{dnsServer}, aws.StringValueSlice(containerDef.DnsServers)) {
t.Errorf("Expected dnsServer [%s] But was [%v]", dnsServer, aws.StringValueSlice(containerDef.DnsServers))
}
}
示例5: TestConvertToTaskDefinitionWithDnsSearch
func TestConvertToTaskDefinitionWithDnsSearch(t *testing.T) {
dnsSearchDomains := []string{"search.example.com"}
serviceConfig := &libcompose.ServiceConfig{DNSSearch: libcompose.NewStringorslice(dnsSearchDomains...)}
taskDefinition := convertToTaskDefinitionInTest(t, "name", serviceConfig)
containerDef := *taskDefinition.ContainerDefinitions[0]
if !reflect.DeepEqual(dnsSearchDomains, aws.StringValueSlice(containerDef.DnsSearchDomains)) {
t.Errorf("Expected dnsSearchDomains [%v] But was [%v]", dnsSearchDomains,
aws.StringValueSlice(containerDef.DnsSearchDomains))
}
}
示例6: configChanged
// configChanged checks if function configuration differs from configuration stored in AWS Lambda
func (f *Function) configChanged(config *lambda.GetFunctionOutput) bool {
type diffConfig struct {
Description string
Memory int64
Timeout int64
Role string
Runtime string
Handler string
VPC vpc.VPC
}
localConfig := &diffConfig{
Description: f.Description,
Memory: f.Memory,
Timeout: f.Timeout,
Role: f.Role,
Runtime: f.Runtime,
Handler: f.Handler,
VPC: vpc.VPC{
Subnets: f.VPC.Subnets,
SecurityGroups: f.VPC.SecurityGroups,
},
}
remoteConfig := &diffConfig{
Description: *config.Configuration.Description,
Memory: *config.Configuration.MemorySize,
Timeout: *config.Configuration.Timeout,
Role: *config.Configuration.Role,
Runtime: *config.Configuration.Runtime,
Handler: *config.Configuration.Handler,
}
// SDK is inconsistent here. VpcConfig can be nil or empty struct.
remoteConfig.VPC = vpc.VPC{Subnets: []string{}, SecurityGroups: []string{}}
if config.Configuration.VpcConfig != nil {
remoteConfig.VPC = vpc.VPC{
Subnets: aws.StringValueSlice(config.Configuration.VpcConfig.SubnetIds),
SecurityGroups: aws.StringValueSlice(config.Configuration.VpcConfig.SecurityGroupIds),
}
}
// don't make any assumptions about the order AWS stores the subnets or security groups
sort.StringSlice(remoteConfig.VPC.Subnets).Sort()
sort.StringSlice(localConfig.VPC.Subnets).Sort()
sort.StringSlice(remoteConfig.VPC.SecurityGroups).Sort()
sort.StringSlice(localConfig.VPC.SecurityGroups).Sort()
localConfigJSON, _ := json.Marshal(localConfig)
remoteConfigJSON, _ := json.Marshal(remoteConfig)
return string(localConfigJSON) != string(remoteConfigJSON)
}
示例7: resourceAwsRDSClusterRead
func resourceAwsRDSClusterRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsconn
resp, err := conn.DescribeDBClusters(&rds.DescribeDBClustersInput{
DBClusterIdentifier: aws.String(d.Id()),
})
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
if "DBClusterNotFoundFault" == awsErr.Code() {
d.SetId("")
log.Printf("[DEBUG] RDS Cluster (%s) not found", d.Id())
return nil
}
}
log.Printf("[DEBUG] Error describing RDS Cluster (%s)", d.Id())
return err
}
var dbc *rds.DBCluster
for _, c := range resp.DBClusters {
if *c.DBClusterIdentifier == d.Id() {
dbc = c
}
}
if dbc == nil {
log.Printf("[WARN] RDS Cluster (%s) not found", d.Id())
d.SetId("")
return nil
}
if err := d.Set("availability_zones", aws.StringValueSlice(dbc.AvailabilityZones)); err != nil {
return fmt.Errorf("[DEBUG] Error saving AvailabilityZones to state for RDS Cluster (%s): %s", d.Id(), err)
}
d.Set("database_name", dbc.DatabaseName)
d.Set("db_subnet_group_name", dbc.DBSubnetGroup)
d.Set("endpoint", dbc.Endpoint)
d.Set("engine", dbc.Engine)
d.Set("master_username", dbc.MasterUsername)
d.Set("port", dbc.Port)
var vpcg []string
for _, g := range dbc.VpcSecurityGroups {
vpcg = append(vpcg, *g.VpcSecurityGroupId)
}
if err := d.Set("vpc_security_group_ids", vpcg); err != nil {
return fmt.Errorf("[DEBUG] Error saving VPC Security Group IDs to state for RDS Cluster (%s): %s", d.Id(), err)
}
var cm []string
for _, m := range dbc.DBClusterMembers {
cm = append(cm, *m.DBInstanceIdentifier)
}
if err := d.Set("cluster_members", cm); err != nil {
return fmt.Errorf("[DEBUG] Error saving RDS Cluster Members to state for RDS Cluster (%s): %s", d.Id(), err)
}
return nil
}
示例8: TestStringValueSlice
func TestStringValueSlice(t *testing.T) {
for idx, in := range testCasesStringValueSlice {
if in == nil {
continue
}
out := aws.StringValueSlice(in)
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
for i := range out {
if in[i] == nil {
assert.Empty(t, out[i], "Unexpected value at idx %d", idx)
} else {
assert.Equal(t, *(in[i]), out[i], "Unexpected value at idx %d", idx)
}
}
out2 := aws.StringSlice(out)
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
for i := range out2 {
if in[i] == nil {
assert.Empty(t, *(out2[i]), "Unexpected value at idx %d", idx)
} else {
assert.Equal(t, in[i], out2[i], "Unexpected value at idx %d", idx)
}
}
}
}
示例9: dataSourceAwsVpcEndpointServiceRead
func dataSourceAwsVpcEndpointServiceRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn
service := d.Get("service").(string)
log.Printf("[DEBUG] Reading VPC Endpoint Services.")
request := &ec2.DescribeVpcEndpointServicesInput{}
resp, err := conn.DescribeVpcEndpointServices(request)
if err != nil {
return fmt.Errorf("Error fetching VPC Endpoint Services: %s", err)
}
names := aws.StringValueSlice(resp.ServiceNames)
for _, name := range names {
if strings.HasSuffix(name, "."+service) {
d.SetId(strconv.Itoa(hashcode.String(name)))
d.Set("service_name", name)
return nil
}
}
return fmt.Errorf("VPC Endpoint Service (%s) not found", service)
}
示例10: testAccCheckAWSOpsworksCreateLayerAttributes
func testAccCheckAWSOpsworksCreateLayerAttributes(
opslayer *opsworks.Layer, stackName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
if *opslayer.Name != stackName {
return fmt.Errorf("Unexpected name: %s", *opslayer.Name)
}
if *opslayer.AutoAssignElasticIps {
return fmt.Errorf(
"Unexpected AutoAssignElasticIps: %t", *opslayer.AutoAssignElasticIps)
}
if !*opslayer.EnableAutoHealing {
return fmt.Errorf(
"Unexpected EnableAutoHealing: %t", *opslayer.EnableAutoHealing)
}
if !*opslayer.LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained {
return fmt.Errorf(
"Unexpected DelayUntilElbConnectionsDrained: %t",
*opslayer.LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained)
}
if *opslayer.LifecycleEventConfiguration.Shutdown.ExecutionTimeout != 300 {
return fmt.Errorf(
"Unexpected ExecutionTimeout: %d",
*opslayer.LifecycleEventConfiguration.Shutdown.ExecutionTimeout)
}
if v := len(opslayer.CustomSecurityGroupIds); v != 2 {
return fmt.Errorf("Expected 2 customSecurityGroupIds, got %d", v)
}
expectedPackages := []*string{
aws.String("git"),
aws.String("golang"),
}
if !reflect.DeepEqual(expectedPackages, opslayer.Packages) {
return fmt.Errorf("Unexpected Packages: %v", aws.StringValueSlice(opslayer.Packages))
}
expectedEbsVolumes := []*opsworks.VolumeConfiguration{
&opsworks.VolumeConfiguration{
VolumeType: aws.String("gp2"),
NumberOfDisks: aws.Int64(2),
MountPoint: aws.String("/home"),
Size: aws.Int64(100),
RaidLevel: aws.Int64(0),
},
}
if !reflect.DeepEqual(expectedEbsVolumes, opslayer.VolumeConfigurations) {
return fmt.Errorf("Unnexpected VolumeConfiguration: %s", opslayer.VolumeConfigurations)
}
return nil
}
}
示例11: testAccCheckAWSS3BucketLambdaFunctionConfiguration
func testAccCheckAWSS3BucketLambdaFunctionConfiguration(n, i, t string, events []string, filters *s3.KeyFilter) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, _ := s.RootModule().Resources[n]
funcArn := s.RootModule().Resources[t].Primary.Attributes["arn"]
conn := testAccProvider.Meta().(*AWSClient).s3conn
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
out, err := conn.GetBucketNotificationConfiguration(&s3.GetBucketNotificationConfigurationRequest{
Bucket: aws.String(rs.Primary.ID),
})
if err != nil {
return resource.NonRetryableError(fmt.Errorf("GetBucketNotification error: %v", err))
}
eventSlice := sort.StringSlice(events)
eventSlice.Sort()
outputFunctions := out.LambdaFunctionConfigurations
matched := false
for _, outputFunc := range outputFunctions {
if *outputFunc.Id == i {
matched = true
if *outputFunc.LambdaFunctionArn != funcArn {
return resource.RetryableError(fmt.Errorf("bad lambda function arn, expected: %s, got %#v", funcArn, *outputFunc.LambdaFunctionArn))
}
if filters != nil {
if !reflect.DeepEqual(filters, outputFunc.Filter.Key) {
return resource.RetryableError(fmt.Errorf("bad notification filters, expected: %#v, got %#v", filters, outputFunc.Filter.Key))
}
} else {
if outputFunc.Filter != nil {
return resource.RetryableError(fmt.Errorf("bad notification filters, expected: nil, got %#v", outputFunc.Filter))
}
}
outputEventSlice := sort.StringSlice(aws.StringValueSlice(outputFunc.Events))
outputEventSlice.Sort()
if !reflect.DeepEqual(eventSlice, outputEventSlice) {
return resource.RetryableError(fmt.Errorf("bad notification events, expected: %#v, got %#v", events, outputEventSlice))
}
}
}
if !matched {
return resource.RetryableError(fmt.Errorf("No match lambda function configurations: %#v", out))
}
return nil
})
return err
}
}
示例12: GetStreams
func (kin *Kinesumer) GetStreams() (streams []string, err error) {
streams = make([]string, 0)
err = kin.Kinesis.ListStreamsPages(&kinesis.ListStreamsInput{
Limit: &kin.Options.ListStreamsLimit,
}, func(sts *kinesis.ListStreamsOutput, _ bool) bool {
streams = append(streams, aws.StringValueSlice(sts.StreamNames)...)
return true
})
return
}
示例13: Marshal
// Marshal parses the response from the aws sdk into an awsm AutoScale Group
func (a *AutoScaleGroup) Marshal(autoscalegroup *autoscaling.Group, region string, subList *Subnets) {
a.Name = aws.StringValue(autoscalegroup.AutoScalingGroupName)
a.Class = GetTagValue("Class", autoscalegroup.Tags)
a.HealthCheckType = aws.StringValue(autoscalegroup.HealthCheckType)
a.HealthCheckGracePeriod = int(aws.Int64Value(autoscalegroup.HealthCheckGracePeriod))
a.LaunchConfig = aws.StringValue(autoscalegroup.LaunchConfigurationName)
a.LoadBalancers = aws.StringValueSlice(autoscalegroup.LoadBalancerNames)
a.InstanceCount = len(autoscalegroup.Instances)
a.DesiredCapacity = int(aws.Int64Value(autoscalegroup.DesiredCapacity))
a.MinSize = int(aws.Int64Value(autoscalegroup.MinSize))
a.MaxSize = int(aws.Int64Value(autoscalegroup.MaxSize))
a.DefaultCooldown = int(aws.Int64Value(autoscalegroup.DefaultCooldown))
a.AvailabilityZones = aws.StringValueSlice(autoscalegroup.AvailabilityZones)
a.SubnetID = aws.StringValue(autoscalegroup.VPCZoneIdentifier)
a.SubnetName = subList.GetSubnetName(a.SubnetID)
a.VpcID = subList.GetVpcIDBySubnetID(a.SubnetID)
a.VpcName = subList.GetVpcNameBySubnetID(a.SubnetID)
a.Region = region
}
示例14: flattenActiveTrustedSigners
// Convert *cloudfront.ActiveTrustedSigners to a flatmap.Map type, which ensures
// it can probably be inserted into the schema.TypeMap type used by the
// active_trusted_signers attribute.
func flattenActiveTrustedSigners(ats *cloudfront.ActiveTrustedSigners) flatmap.Map {
m := make(map[string]interface{})
s := []interface{}{}
m["enabled"] = *ats.Enabled
for _, v := range ats.Items {
signer := make(map[string]interface{})
signer["aws_account_number"] = *v.AwsAccountNumber
signer["key_pair_ids"] = aws.StringValueSlice(v.KeyPairIds.Items)
s = append(s, signer)
}
m["items"] = s
return flatmap.Flatten(m)
}
示例15: configChanged
// configChanged checks if function configuration differs from configuration stored in AWS Lambda
func (f *Function) configChanged(config *lambda.GetFunctionOutput) bool {
type diffConfig struct {
Description string
Memory int64
Timeout int64
Role string
Handler string
VPC vpc.VPC
}
localConfig, _ := json.Marshal(diffConfig{
Description: f.Description,
Memory: f.Memory,
Timeout: f.Timeout,
Role: f.Role,
Handler: f.Handler,
VPC: vpc.VPC{
Subnets: f.VPC.Subnets,
SecurityGroups: f.VPC.SecurityGroups,
},
})
remoteConfig, _ := json.Marshal(diffConfig{
Description: *config.Configuration.Description,
Memory: *config.Configuration.MemorySize,
Timeout: *config.Configuration.Timeout,
Role: *config.Configuration.Role,
Handler: *config.Configuration.Handler,
VPC: vpc.VPC{
Subnets: aws.StringValueSlice(config.Configuration.VpcConfig.SubnetIds),
SecurityGroups: aws.StringValueSlice(config.Configuration.VpcConfig.SecurityGroupIds),
},
})
return string(localConfig) != string(remoteConfig)
}