本文整理汇总了Golang中github.com/convox/rack/api/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws.String函数的典型用法代码示例。如果您正苦于以下问题:Golang String函数的具体用法?Golang String怎么用?Golang String使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了String函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UpdateParamsAndTemplate
func (a *App) UpdateParamsAndTemplate(changes map[string]string, template string) error {
req := &cloudformation.UpdateStackInput{
StackName: aws.String(a.Name),
Capabilities: []*string{aws.String("CAPABILITY_IAM")},
}
if template != "" {
req.TemplateURL = aws.String(template)
} else {
req.UsePreviousTemplate = aws.Bool(true)
}
params := a.Parameters
for key, val := range changes {
params[key] = val
}
for key, val := range params {
req.Parameters = append(req.Parameters, &cloudformation.Parameter{
ParameterKey: aws.String(key),
ParameterValue: aws.String(val),
})
}
_, err := CloudFormation().UpdateStack(req)
return err
}
示例2: ListReleases
func ListReleases(app string) (Releases, error) {
req := &dynamodb.QueryInput{
KeyConditions: map[string]*dynamodb.Condition{
"app": &dynamodb.Condition{
AttributeValueList: []*dynamodb.AttributeValue{
&dynamodb.AttributeValue{S: aws.String(app)},
},
ComparisonOperator: aws.String("EQ"),
},
},
IndexName: aws.String("app.created"),
Limit: aws.Int64(20),
ScanIndexForward: aws.Bool(false),
TableName: aws.String(releasesTable(app)),
}
res, err := DynamoDB().Query(req)
if err != nil {
return nil, err
}
releases := make(Releases, len(res.Items))
for i, item := range res.Items {
releases[i] = *releaseFromItem(item)
}
return releases, nil
}
示例3: UpdatePapertrail
func (s *Service) UpdatePapertrail(arns map[string]string) error {
input := struct {
ARNs map[string]string
}{
arns,
}
formation, err := buildTemplate(fmt.Sprintf("service/%s", s.Type), "service", input)
if err != nil {
return err
}
// Update stack with all linked ARNs and EventSourceMappings
_, err = CloudFormation().UpdateStack(&cloudformation.UpdateStackInput{
StackName: aws.String(s.Name),
Capabilities: []*string{aws.String("CAPABILITY_IAM")},
Parameters: []*cloudformation.Parameter{
&cloudformation.Parameter{
ParameterKey: aws.String("Url"),
ParameterValue: aws.String(s.Parameters["Url"]),
},
},
TemplateBody: aws.String(formation),
})
return err
}
示例4: log
func (b *Build) log(line string) {
b.Logs += fmt.Sprintf("%s\n", line)
if b.kinesis == "" {
app, err := GetApp(b.App)
if err != nil {
panic(err)
}
b.kinesis = app.Outputs["Kinesis"]
}
_, err := Kinesis().PutRecords(&kinesis.PutRecordsInput{
StreamName: aws.String(b.kinesis),
Records: []*kinesis.PutRecordsRequestEntry{
&kinesis.PutRecordsRequestEntry{
Data: []byte(fmt.Sprintf("build: %s", line)),
PartitionKey: aws.String(string(time.Now().UnixNano())),
},
},
})
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
}
}
示例5: Retrieve
// Retrieve generates a new set of temporary credentials using STS.
func (p *AssumeRoleProvider) Retrieve() (credentials.Value, error) {
// Apply defaults where parameters are not set.
if p.Client == nil {
p.Client = sts.New(nil)
}
if p.RoleSessionName == "" {
// Try to work out a role name that will hopefully end up unique.
p.RoleSessionName = fmt.Sprintf("%d", time.Now().UTC().UnixNano())
}
if p.Duration == 0 {
// Expire as often as AWS permits.
p.Duration = 15 * time.Minute
}
roleOutput, err := p.Client.AssumeRole(&sts.AssumeRoleInput{
DurationSeconds: aws.Int64(int64(p.Duration / time.Second)),
RoleArn: aws.String(p.RoleARN),
RoleSessionName: aws.String(p.RoleSessionName),
ExternalId: p.ExternalID,
})
if err != nil {
return credentials.Value{}, err
}
// We will proactively generate new credentials before they expire.
p.SetExpiration(*roleOutput.Credentials.Expiration, p.ExpiryWindow)
return credentials.Value{
AccessKeyID: *roleOutput.Credentials.AccessKeyId,
SecretAccessKey: *roleOutput.Credentials.SecretAccessKey,
SessionToken: *roleOutput.Credentials.SessionToken,
}, nil
}
示例6: Promote
func (r *Release) Promote() error {
formation, err := r.Formation()
if err != nil {
return err
}
existing, err := formationParameters(formation)
if err != nil {
return err
}
app, err := GetApp(r.App)
if err != nil {
return err
}
manifest, err := LoadManifest(r.Manifest)
if err != nil {
return err
}
for _, me := range manifest {
app.Parameters[fmt.Sprintf("%sCommand", UpperName(me.Name))] = me.CommandString()
app.Parameters[fmt.Sprintf("%sImage", UpperName(me.Name))] = fmt.Sprintf("%s/%s-%s:%s", os.Getenv("REGISTRY_HOST"), r.App, me.Name, r.Build)
}
app.Parameters["Environment"] = r.EnvironmentUrl()
app.Parameters["Kernel"] = CustomTopic
app.Parameters["Release"] = r.Id
app.Parameters["Version"] = os.Getenv("RELEASE")
if os.Getenv("ENCRYPTION_KEY") != "" {
app.Parameters["Key"] = os.Getenv("ENCRYPTION_KEY")
}
params := []*cloudformation.Parameter{}
for key, value := range app.Parameters {
if _, ok := existing[key]; ok {
params = append(params, &cloudformation.Parameter{ParameterKey: aws.String(key), ParameterValue: aws.String(value)})
}
}
req := &cloudformation.UpdateStackInput{
Capabilities: []*string{aws.String("CAPABILITY_IAM")},
StackName: aws.String(r.App),
TemplateBody: aws.String(formation),
Parameters: params,
}
_, err = CloudFormation().UpdateStack(req)
return err
}
示例7: Region
func Region(req *Request) *string {
if req != nil {
if region, ok := req.ResourceProperties["Region"].(string); ok && region != "" {
return aws.String(region)
}
}
return aws.String(os.Getenv("AWS_REGION"))
}
示例8: s3Delete
func s3Delete(bucket, key string) error {
req := &s3.DeleteObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(key),
}
_, err := S3().DeleteObject(req)
return err
}
示例9: ListDeployments
func ListDeployments(app string) (Deployments, error) {
a, err := GetApp(app)
if err != nil {
return nil, err
}
res, err := ECS().DescribeServices(&ecs.DescribeServicesInput{
Cluster: aws.String(os.Getenv("CLUSTER")),
Services: []*string{aws.String(a.TaskDefinitionFamily())},
})
if err != nil {
return nil, err
}
// no service yet, so no deployments
if len(res.Services) != 1 {
return Deployments{}, nil
}
service := res.Services[0]
deployments := make(Deployments, len(service.Deployments))
for i, d := range service.Deployments {
deployments[i] = Deployment{
Status: *d.Status,
Desired: *d.DesiredCount,
Pending: *d.PendingCount,
Running: *d.RunningCount,
Created: *d.CreatedAt,
}
tres, err := ECS().DescribeTaskDefinition(&ecs.DescribeTaskDefinitionInput{
TaskDefinition: d.TaskDefinition,
})
if err != nil {
return nil, err
}
if len(tres.TaskDefinition.ContainerDefinitions) > 0 {
for _, kp := range tres.TaskDefinition.ContainerDefinitions[0].Environment {
if *kp.Name == "RELEASE" {
deployments[i].Release = *kp.Value
break
}
}
}
}
return deployments, nil
}
示例10: KMSKeyCreate
func KMSKeyCreate(req Request) (string, map[string]string, error) {
res, err := KMS(req).CreateKey(&kms.CreateKeyInput{
Description: aws.String(req.ResourceProperties["Description"].(string)),
KeyUsage: aws.String(req.ResourceProperties["KeyUsage"].(string)),
})
if err != nil {
return "", nil, err
}
return *res.KeyMetadata.Arn, nil, nil
}
示例11: cleanupBucketObject
func cleanupBucketObject(bucket, key, version string, S3 *s3.S3) {
req := &s3.DeleteObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(key),
VersionId: aws.String(version),
}
_, err := S3.DeleteObject(req)
if err != nil {
fmt.Printf("error: %s\n", err)
}
}
示例12: Stop
func (p *Process) Stop() error {
req := &ecs.StopTaskInput{
Cluster: aws.String(os.Getenv("CLUSTER")),
Task: aws.String(p.taskArn),
}
_, err := ECS().StopTask(req)
if err != nil {
return err
}
return nil
}
示例13: s3Get
func s3Get(bucket, key string) ([]byte, error) {
req := &s3.GetObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(key),
}
res, err := S3().GetObject(req)
if err != nil {
return nil, err
}
return ioutil.ReadAll(res.Body)
}
示例14: dequeueMessage
func dequeueMessage() ([]Message, error) {
req := &sqs.ReceiveMessageInput{
MaxNumberOfMessages: aws.Int64(10),
QueueUrl: aws.String(MessageQueueUrl),
WaitTimeSeconds: aws.Int64(10),
}
res, err := SQS().ReceiveMessage(req)
if err != nil {
return nil, err
}
messages := make([]Message, len(res.Messages))
var message Message
for i, m := range res.Messages {
err = json.Unmarshal([]byte(*m.Body), &message)
if err != nil {
return nil, err
}
message.MessageID = m.MessageId
message.ReceiptHandle = m.ReceiptHandle
messages[i] = message
}
return messages, nil
}
示例15: LinkPapertrail
func (s *Service) LinkPapertrail(app App) error {
// build map of app name -> arn of all linked services
arns := map[string]string{}
for k, v := range s.Outputs {
if strings.HasSuffix(k, "Link") {
n := DashName(k)
arns[n[:len(n)-5]] = v
}
}
// get full Kinesis ARN for app
req, err := Kinesis().DescribeStream(&kinesis.DescribeStreamInput{
StreamName: aws.String(app.Outputs["Kinesis"]),
})
arn := *req.StreamDescription.StreamARN
if err != nil {
return err
}
// append new ARN and update
arns[app.Name] = arn
return s.UpdatePapertrail(arns)
}