本文整理汇总了Golang中github.com/docker/machine/libmachine/host.Host.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang Host.Name方法的具体用法?Golang Host.Name怎么用?Golang Host.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/docker/machine/libmachine/host.Host
的用法示例。
在下文中一共展示了Host.Name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: loadConfig
func (s Filestore) loadConfig(h *host.Host) error {
data, err := ioutil.ReadFile(filepath.Join(s.GetMachinesDir(), h.Name, "config.json"))
if err != nil {
return err
}
// Remember the machine name so we don't have to pass it through each
// struct in the migration.
name := h.Name
migratedHost, migrationPerformed, err := host.MigrateHost(h, data)
if err != nil {
return fmt.Errorf("Error getting migrated host: %s", err)
}
*h = *migratedHost
h.Name = name
// If we end up performing a migration, we should save afterwards so we don't have to do it again on subsequent invocations.
if migrationPerformed {
if err := s.saveToFile(data, filepath.Join(s.GetMachinesDir(), h.Name, "config.json.bak")); err != nil {
return fmt.Errorf("Error attempting to save backup after migration: %s", err)
}
if err := s.Save(h); err != nil {
return fmt.Errorf("Error saving config after migration was performed: %s", err)
}
}
return nil
}