本文整理汇总了Golang中launchpad/net/juju-core/worker/uniter/hook.Info.Kind方法的典型用法代码示例。如果您正苦于以下问题:Golang Info.Kind方法的具体用法?Golang Info.Kind怎么用?Golang Info.Kind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/juju-core/worker/uniter/hook.Info
的用法示例。
在下文中一共展示了Info.Kind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: deploy
// deploy deploys the supplied charm, and sets follow-up hook operation state
// as indicated by reason.
func (u *Uniter) deploy(sch *state.Charm, reason Op) error {
if reason != Install && reason != Upgrade {
panic(fmt.Errorf("%q is not a deploy operation", reason))
}
var hi *hook.Info
if u.s != nil && (u.s.Op == RunHook || u.s.Op == Upgrade) {
// If this upgrade interrupts a RunHook, we need to preserve the hook
// info so that we can return to the appropriate error state. However,
// if we're resuming (or have force-interrupted) an Upgrade, we also
// need to preserve whatever hook info was preserved when we initially
// started upgrading, to ensure we still return to the correct state.
hi = u.s.Hook
}
url := sch.URL()
if u.s == nil || u.s.OpStep != Done {
log.Printf("worker/uniter: fetching charm %q", url)
bun, err := u.bundles.Read(sch, u.tomb.Dying())
if err != nil {
return err
}
if err = u.deployer.Stage(bun, url); err != nil {
return err
}
log.Printf("worker/uniter: deploying charm %q", url)
if err = u.writeState(reason, Pending, hi, url); err != nil {
return err
}
if err = u.deployer.Deploy(u.charm); err != nil {
return err
}
if err = u.writeState(reason, Done, hi, url); err != nil {
return err
}
}
log.Printf("worker/uniter: charm %q is deployed", url)
if err := u.unit.SetCharm(sch); err != nil {
return err
}
status := Queued
if hi != nil {
// If a hook operation was interrupted, restore it.
status = Pending
} else {
// Otherwise, queue the relevant post-deploy hook.
hi = &hook.Info{}
switch reason {
case Install:
hi.Kind = hook.Install
case Upgrade:
hi.Kind = hook.UpgradeCharm
}
}
return u.writeState(RunHook, status, hi, nil)
}
示例2: deploy
// deploy deploys the supplied charm URL, and sets follow-up hook operation state
// as indicated by reason.
func (u *Uniter) deploy(curl *corecharm.URL, reason Op) error {
if reason != Install && reason != Upgrade {
panic(fmt.Errorf("%q is not a deploy operation", reason))
}
var hi *hook.Info
if u.s != nil && (u.s.Op == RunHook || u.s.Op == Upgrade) {
// If this upgrade interrupts a RunHook, we need to preserve the hook
// info so that we can return to the appropriate error state. However,
// if we're resuming (or have force-interrupted) an Upgrade, we also
// need to preserve whatever hook info was preserved when we initially
// started upgrading, to ensure we still return to the correct state.
hi = u.s.Hook
}
if u.s == nil || u.s.OpStep != Done {
// Get the new charm bundle before announcing intention to use it.
log.Infof("worker/uniter: fetching charm %q", curl)
sch, err := u.st.Charm(curl)
if err != nil {
return err
}
bun, err := u.bundles.Read(sch, u.tomb.Dying())
if err != nil {
return err
}
if err = u.deployer.Stage(bun, curl); err != nil {
return err
}
// Set the new charm URL - this returns when the operation is complete,
// at which point we can refresh the local copy of the unit to get a
// version with the correct charm URL, and can go ahead and deploy
// the charm proper.
if err := u.f.SetCharm(curl); err != nil {
return err
}
if err := u.unit.Refresh(); err != nil {
return err
}
log.Infof("worker/uniter: deploying charm %q", curl)
if err = u.writeState(reason, Pending, hi, curl); err != nil {
return err
}
if err = u.deployer.Deploy(u.charm); err != nil {
return err
}
if err = u.writeState(reason, Done, hi, curl); err != nil {
return err
}
}
log.Infof("worker/uniter: charm %q is deployed", curl)
status := Queued
if hi != nil {
// If a hook operation was interrupted, restore it.
status = Pending
} else {
// Otherwise, queue the relevant post-deploy hook.
hi = &hook.Info{}
switch reason {
case Install:
hi.Kind = hooks.Install
case Upgrade:
hi.Kind = hooks.UpgradeCharm
}
}
return u.writeState(RunHook, status, hi, nil)
}