1 Star 0 Fork 0

powerpaas/machine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
store.go 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
Luther Monson 提交于 2019-11-15 16:06 . rancher-machine rename
package persist
import (
"github.com/rancher/machine/libmachine/host"
)
type Store interface {
// Exists returns whether a machine exists or not
Exists(name string) (bool, error)
// List returns a list of all hosts in the store
List() ([]string, error)
// Load loads a host by name
Load(name string) (*host.Host, error)
// Remove removes a machine from the store
Remove(name string) error
// Save persists a machine in the store
Save(host *host.Host) error
}
func LoadHosts(s Store, hostNames []string) ([]*host.Host, map[string]error) {
loadedHosts := []*host.Host{}
errors := map[string]error{}
for _, hostName := range hostNames {
h, err := s.Load(hostName)
if err != nil {
errors[hostName] = err
} else {
loadedHosts = append(loadedHosts, h)
}
}
return loadedHosts, errors
}
func LoadAllHosts(s Store) ([]*host.Host, map[string]error, error) {
hostNames, err := s.List()
if err != nil {
return nil, nil, err
}
loadedHosts, hostInError := LoadHosts(s, hostNames)
return loadedHosts, hostInError, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/powerpaas/machine.git
git@gitee.com:powerpaas/machine.git
powerpaas
machine
machine
v0.15.0-rancher22

搜索帮助