Skip to content

Commit 1acde29

Browse files
Merge pull request docker-archive-public#2413 from dgageot/simpler-code
Simpler code
2 parents 3ddea9f + 79efe19 commit 1acde29

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

libmachine/persist/plugin_store.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package persist
33
import (
44
"fmt"
55

6+
"encoding/json"
7+
68
"github.com/docker/machine/drivers/errdriver"
79
"github.com/docker/machine/libmachine/drivers"
810
"github.com/docker/machine/libmachine/drivers/plugin/localbinary"
@@ -46,24 +48,12 @@ func NewPluginStore(path, caCertPath, caPrivateKeyPath string) *PluginStore {
4648
}
4749

4850
func (ps PluginStore) Save(host *host.Host) error {
49-
if serialDriver, ok := host.Driver.(*drivers.SerialDriver); ok {
50-
// Unwrap Driver
51-
host.Driver = serialDriver.Driver
52-
53-
// Re-wrap Driver when done
54-
defer func() {
55-
host.Driver = serialDriver
56-
}()
51+
data, err := json.Marshal(host.Driver)
52+
if err != nil {
53+
return fmt.Errorf("Error getting raw config for driver: %s", err)
5754
}
5855

59-
// TODO: Does this belong here?
60-
if rpcClientDriver, ok := host.Driver.(*rpcdriver.RPCClientDriver); ok {
61-
data, err := rpcClientDriver.GetConfigRaw()
62-
if err != nil {
63-
return fmt.Errorf("Error getting raw config for driver: %s", err)
64-
}
65-
host.RawDriver = data
66-
}
56+
host.RawDriver = data
6757

6858
return ps.Filestore.Save(host)
6959
}

0 commit comments

Comments
 (0)