From 79efe19887c1537fd9077fa99b1c2d2d8d5b79e9 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Wed, 25 Nov 2015 19:01:12 +0100 Subject: [PATCH] Simpler code Signed-off-by: David Gageot --- libmachine/persist/plugin_store.go | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/libmachine/persist/plugin_store.go b/libmachine/persist/plugin_store.go index e7c5366479..41107a2ee1 100644 --- a/libmachine/persist/plugin_store.go +++ b/libmachine/persist/plugin_store.go @@ -3,6 +3,8 @@ package persist import ( "fmt" + "encoding/json" + "github.com/docker/machine/drivers/errdriver" "github.com/docker/machine/libmachine/drivers" "github.com/docker/machine/libmachine/drivers/plugin/localbinary" @@ -46,24 +48,12 @@ func NewPluginStore(path, caCertPath, caPrivateKeyPath string) *PluginStore { } 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 - }() + data, err := json.Marshal(host.Driver) + if err != nil { + return fmt.Errorf("Error getting raw config for driver: %s", err) } - // 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 - } + host.RawDriver = data return ps.Filestore.Save(host) }