本文整理汇总了Golang中github.com/docker/machine/libmachine/persist.Store.List方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.List方法的具体用法?Golang Store.List怎么用?Golang Store.List使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/docker/machine/libmachine/persist.Store
的用法示例。
在下文中一共展示了Store.List方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: listHosts
func listHosts(store persist.Store, storePath string) ([]*host.Host, error) {
cliHosts := []*host.Host{}
hosts, err := store.List()
if err != nil {
return nil, fmt.Errorf("Error attempting to list hosts from store: %s", err)
}
for _, h := range hosts {
h, err = loadHost(store, h.Name, storePath)
if err != nil {
return nil, err
}
cliHosts = append(cliHosts, h)
}
return cliHosts, nil
}
示例2: getActiveHost
func getActiveHost(store persist.Store) (*host.Host, error) {
hosts, err := store.List()
if err != nil {
return nil, err
}
hostListItems := getHostListItems(hosts)
for _, item := range hostListItems {
if item.Active {
h, err := store.Load(item.Name)
if err != nil {
return nil, err
}
return h, nil
}
}
return nil, errors.New("Active host not found")
}
示例3: listHosts
func listHosts(store persist.Store) ([]*host.Host, error) {
cliHosts := []*host.Host{}
hosts, err := store.List()
if err != nil {
return nil, fmt.Errorf("Error attempting to list hosts from store: %s", err)
}
for _, h := range hosts {
d, err := newPluginDriver(h.DriverName, h.RawDriver)
if err != nil {
return nil, fmt.Errorf("Error attempting to invoke binary for plugin '%s': %s", h.DriverName, err)
}
h.Driver = d
cliHosts = append(cliHosts, h)
}
return cliHosts, nil
}