本文整理汇总了Golang中github.com/tsuru/tsuru/event.Event.StartData方法的典型用法代码示例。如果您正苦于以下问题:Golang Event.StartData方法的具体用法?Golang Event.StartData怎么用?Golang Event.StartData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/tsuru/event.Event
的用法示例。
在下文中一共展示了Event.StartData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: toHealingEvt
func toHealingEvt(evt *event.Event) (HealingEvent, error) {
healingEvt := HealingEvent{
ID: evt.UniqueID,
StartTime: evt.StartTime,
EndTime: evt.EndTime,
Action: fmt.Sprintf("%s-healing", evt.Target.Type),
Successful: evt.Error == "",
Error: evt.Error,
}
switch evt.Target.Type {
case event.TargetTypeContainer:
err := evt.StartData(&healingEvt.FailingContainer)
if err != nil {
return healingEvt, err
}
err = evt.EndData(&healingEvt.CreatedContainer)
if err != nil {
return healingEvt, err
}
case event.TargetTypeNode:
var data healer.NodeHealerCustomData
err := evt.StartData(&data)
if err != nil {
return healingEvt, err
}
if data.LastCheck != nil {
healingEvt.Extra = data.LastCheck
}
healingEvt.Reason = data.Reason
healingEvt.FailingNode = data.Node
var createdNode provision.NodeSpec
err = evt.EndData(&createdNode)
if err != nil {
return healingEvt, err
}
healingEvt.CreatedNode = createdNode
}
return healingEvt, nil
}
示例2: eventToDeployData
func eventToDeployData(evt *event.Event, validImages set.Set, full bool) *DeployData {
data := &DeployData{
ID: evt.UniqueID,
App: evt.Target.Value,
Timestamp: evt.StartTime,
Duration: evt.EndTime.Sub(evt.StartTime),
Error: evt.Error,
User: evt.Owner.Name,
}
var startOpts DeployOptions
err := evt.StartData(&startOpts)
if err == nil {
data.Commit = startOpts.Commit
data.Origin = startOpts.GetOrigin()
}
if full {
data.Log = evt.Log
var otherData map[string]string
err = evt.OtherData(&otherData)
if err == nil {
data.Diff = otherData["diff"]
}
}
var endData map[string]string
err = evt.EndData(&endData)
if err == nil {
data.Image = endData["image"]
if validImages != nil {
data.CanRollback = validImages.Includes(data.Image)
if reImageVersion.MatchString(data.Image) {
parts := reImageVersion.FindAllStringSubmatch(data.Image, -1)
data.Image = parts[0][0]
}
}
}
return data
}