本文整理匯總了Golang中github.com/docker/machine/libmachine/persist.Store.Load方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.Load方法的具體用法?Golang Store.Load怎麽用?Golang Store.Load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/machine/libmachine/persist.Store
的用法示例。
在下文中一共展示了Store.Load方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getInfoForScpArg
func getInfoForScpArg(hostAndPath string, store persist.Store) (*host.Host, string, []string, error) {
// TODO: What to do about colon in filepath?
splitInfo := strings.Split(hostAndPath, ":")
// Host path. e.g. "/tmp/foo"
if len(splitInfo) == 1 {
return nil, splitInfo[0], nil, nil
}
// Remote path. e.g. "machinename:/usr/bin/cmatrix"
if len(splitInfo) == 2 {
path := splitInfo[1]
host, err := store.Load(splitInfo[0])
if err != nil {
return nil, "", nil, fmt.Errorf("Error loading host: %s", err)
}
args := []string{
"-i",
host.Driver.GetSSHKeyPath(),
}
return host, path, args, nil
}
return nil, "", nil, ErrMalformedInput
}
示例2: loadHost
func loadHost(store persist.Store, hostName string) (*host.Host, error) {
h, err := store.Load(hostName)
if err != nil {
return nil, fmt.Errorf("Loading host from store failed: %s", err)
}
d, err := newPluginDriver(h.DriverName, h.RawDriver)
if err != nil {
return nil, fmt.Errorf("Error attempting to invoke binary for plugin: %s", err)
}
h.Driver = d
return h, nil
}
示例3: loadHost
func loadHost(store persist.Store, hostName string, storePath string) (*host.Host, error) {
h, err := store.Load(hostName)
if err != nil {
return nil, fmt.Errorf("Loading host from store failed: %s", err)
}
d, err := driverfactory.NewDriver(h.DriverName, h.Name, storePath)
if err != nil {
return nil, err
}
err = json.Unmarshal(h.RawDriver, &d)
if err != nil {
return nil, err
}
h.Driver = d
return h, nil
}
示例4: 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")
}