本文整理汇总了Golang中github.com/convox/rack/api/structs.Build.Ended方法的典型用法代码示例。如果您正苦于以下问题:Golang Build.Ended方法的具体用法?Golang Build.Ended怎么用?Golang Build.Ended使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/convox/rack/api/structs.Build
的用法示例。
在下文中一共展示了Build.Ended方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: BuildSave
// BuildSave creates or updates a build item in DynamoDB. It takes an optional
// bucket argument, which if set indicates to PUT Log data into S3
func (p *AWSProvider) BuildSave(b *structs.Build) error {
_, err := p.AppGet(b.App)
if err != nil {
return err
}
if b.Id == "" {
return fmt.Errorf("Id can not be blank")
}
if b.Started.IsZero() {
b.Started = time.Now()
}
if p.IsTest() {
b.Started = time.Unix(1473028693, 0).UTC()
b.Ended = time.Unix(1473028892, 0).UTC()
}
req := &dynamodb.PutItemInput{
Item: map[string]*dynamodb.AttributeValue{
"id": {S: aws.String(b.Id)},
"app": {S: aws.String(b.App)},
"status": {S: aws.String(b.Status)},
"created": {S: aws.String(b.Started.Format(sortableTime))},
},
TableName: aws.String(p.DynamoBuilds),
}
if b.Description != "" {
req.Item["description"] = &dynamodb.AttributeValue{S: aws.String(b.Description)}
}
if b.Manifest != "" {
req.Item["manifest"] = &dynamodb.AttributeValue{S: aws.String(b.Manifest)}
}
if b.Logs != "" {
req.Item["logs"] = &dynamodb.AttributeValue{S: aws.String(b.Logs)}
}
if b.Reason != "" {
req.Item["reason"] = &dynamodb.AttributeValue{S: aws.String(b.Reason)}
}
if b.Release != "" {
req.Item["release"] = &dynamodb.AttributeValue{S: aws.String(b.Release)}
}
if !b.Ended.IsZero() {
req.Item["ended"] = &dynamodb.AttributeValue{S: aws.String(b.Ended.Format(sortableTime))}
}
if len(b.Tags) > 0 {
tags, err := json.Marshal(b.Tags)
if err != nil {
return err
}
req.Item["tags"] = &dynamodb.AttributeValue{B: tags}
}
_, err = p.dynamodb().PutItem(req)
return err
}