本文整理汇总了Golang中github.com/wallyworld/core/agent.Config.SetUpgradedToVersion方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.SetUpgradedToVersion方法的具体用法?Golang Config.SetUpgradedToVersion怎么用?Golang Config.SetUpgradedToVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/wallyworld/core/agent.Config
的用法示例。
在下文中一共展示了Config.SetUpgradedToVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runUpgrades
// runUpgrades runs the upgrade operations for each job type and updates the updatedToVersion on success.
func (a *MachineAgent) runUpgrades(
st *state.State,
apiState *api.State,
jobs []params.MachineJob,
agentConfig agent.Config,
) error {
from := version.Current
from.Number = agentConfig.UpgradedToVersion()
if from == version.Current {
logger.Infof("upgrade to %v already completed.", version.Current)
return nil
}
var err error
writeErr := a.ChangeConfig(func(agentConfig agent.ConfigSetter) {
context := upgrades.NewContext(agentConfig, apiState, st)
for _, job := range jobs {
target := upgradeTarget(job)
if target == "" {
continue
}
logger.Infof("starting upgrade from %v to %v for %v %q", from, version.Current, target, a.Tag())
if err = upgrades.PerformUpgrade(from.Number, target, context); err != nil {
err = fmt.Errorf("cannot perform upgrade from %v to %v for %v %q: %v", from, version.Current, target, a.Tag(), err)
return
}
}
agentConfig.SetUpgradedToVersion(version.Current.Number)
})
if writeErr != nil {
return fmt.Errorf("cannot write updated agent configuration: %v", writeErr)
}
return nil
}