本文整理匯總了Golang中github.com/docker/machine/libmachine/host.Host.RawDriver方法的典型用法代碼示例。如果您正苦於以下問題:Golang Host.RawDriver方法的具體用法?Golang Host.RawDriver怎麽用?Golang Host.RawDriver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/machine/libmachine/host.Host
的用法示例。
在下文中一共展示了Host.RawDriver方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Save
func (s Filestore) Save(host *host.Host) error {
if serialDriver, ok := host.Driver.(*drivers.SerialDriver); ok {
// Unwrap Driver
host.Driver = serialDriver.Driver
// Re-wrap Driver when done
defer func() {
host.Driver = serialDriver
}()
}
// TODO: Does this belong here?
if rpcClientDriver, ok := host.Driver.(*rpcdriver.RPCClientDriver); ok {
data, err := rpcClientDriver.GetConfigRaw()
if err != nil {
return fmt.Errorf("Error getting raw config for driver: %s", err)
}
host.RawDriver = data
}
data, err := json.MarshalIndent(host, "", " ")
if err != nil {
return err
}
hostPath := filepath.Join(s.getMachinesDir(), host.Name)
// Ensure that the directory we want to save to exists.
if err := os.MkdirAll(hostPath, 0700); err != nil {
return err
}
return s.saveToFile(data, filepath.Join(hostPath, "config.json"))
}
示例2: Save
func (ps PluginStore) Save(host *host.Host) error {
if serialDriver, ok := host.Driver.(*drivers.SerialDriver); ok {
// Unwrap Driver
host.Driver = serialDriver.Driver
// Re-wrap Driver when done
defer func() {
host.Driver = serialDriver
}()
}
// TODO: Does this belong here?
if rpcClientDriver, ok := host.Driver.(*rpcdriver.RPCClientDriver); ok {
data, err := rpcClientDriver.GetConfigRaw()
if err != nil {
return fmt.Errorf("Error getting raw config for driver: %s", err)
}
host.RawDriver = data
}
return ps.Filestore.Save(host)
}