本文整理汇总了Golang中github.com/applikatoni/applikatoni/models.Deployment类的典型用法代码示例。如果您正苦于以下问题:Golang Deployment类的具体用法?Golang Deployment怎么用?Golang Deployment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Deployment类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: buildDeploymentEvent
func (hub *DeploymentEventHub) buildDeploymentEvent(s models.DeploymentState, d *models.Deployment) (*DeploymentEvent, error) {
user, err := getUser(hub.db, d.UserId)
if err != nil {
return nil, err
}
d.User = user
application, err := findApplication(d.ApplicationName)
if err != nil {
return nil, err
}
target, err := findTarget(application, d.TargetName)
if err != nil {
return nil, err
}
event := &DeploymentEvent{
State: s,
Deployment: d,
Application: application,
Target: target,
User: user,
}
return event, nil
}
示例2: updateDeploymentState
func updateDeploymentState(db *sql.DB, d *models.Deployment, state models.DeploymentState) error {
_, err := db.Exec(deploymentUpdateStateStmt, string(state), d.Id)
if err != nil {
return err
}
d.State = state
return nil
}
示例3: createDeployment
func createDeployment(db *sql.DB, d *models.Deployment) error {
var id int64
var state models.DeploymentState = models.DEPLOYMENT_NEW
var createdAt time.Time = time.Now()
tx, err := db.Begin()
if err != nil {
return err
}
exists, err := activeDeploymentExists(tx, d.TargetName)
if err != nil {
tx.Rollback()
return err
}
if exists {
tx.Rollback()
return ErrDeployInProgress
}
result, err := tx.Exec(deploymentInsertStmt, d.UserId, d.ApplicationName,
d.TargetName, d.CommitSha, d.Branch, d.Comment, string(state), createdAt)
if err != nil {
tx.Rollback()
return err
}
id, err = result.LastInsertId()
if err != nil {
tx.Rollback()
return err
}
d.Id = int(id)
d.State = state
d.CreatedAt = createdAt
tx.Commit()
return nil
}