本文整理汇总了Golang中github.com/wallyworld/core/state/api.State.Provisioner方法的典型用法代码示例。如果您正苦于以下问题:Golang State.Provisioner方法的具体用法?Golang State.Provisioner怎么用?Golang State.Provisioner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/wallyworld/core/state/api.State
的用法示例。
在下文中一共展示了State.Provisioner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: updateSupportedContainers
// updateSupportedContainers records in state that a machine can run the specified containers.
// It starts a watcher and when a container of a given type is first added to the machine,
// the watcher is killed, the machine is set up to be able to start containers of the given type,
// and a suitable provisioner is started.
func (a *MachineAgent) updateSupportedContainers(
runner worker.Runner,
st *api.State,
tag string,
containers []instance.ContainerType,
agentConfig agent.Config,
) error {
pr := st.Provisioner()
machine, err := pr.Machine(tag)
if err != nil {
return fmt.Errorf("%s is not in state: %v", tag, err)
}
if len(containers) == 0 {
if err := machine.SupportsNoContainers(); err != nil {
return fmt.Errorf("clearing supported containers for %s: %v", tag, err)
}
return nil
}
if err := machine.SetSupportedContainers(containers...); err != nil {
return fmt.Errorf("setting supported containers for %s: %v", tag, err)
}
// Start the watcher to fire when a container is first requested on the machine.
watcherName := fmt.Sprintf("%s-container-watcher", machine.Id())
handler := provisioner.NewContainerSetupHandler(
runner,
watcherName,
containers,
machine,
pr,
agentConfig,
)
a.startWorkerAfterUpgrade(runner, watcherName, func() (worker.Worker, error) {
return worker.NewStringsWorker(handler), nil
})
return nil
}