/
driver_linux.go
45 lines (38 loc) · 1.26 KB
/
driver_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package machine
import (
"encoding/json"
"errors"
"github.com/code-ready/crc/pkg/crc/constants"
"github.com/code-ready/crc/pkg/crc/machine/config"
"github.com/code-ready/crc/pkg/crc/machine/libvirt"
"github.com/code-ready/crc/pkg/libmachine"
"github.com/code-ready/crc/pkg/libmachine/host"
machineLibvirt "github.com/code-ready/machine/drivers/libvirt"
)
func newHost(api libmachine.API, machineConfig config.MachineConfig) (*host.Host, error) {
json, err := json.Marshal(libvirt.CreateHost(machineConfig))
if err != nil {
return nil, errors.New("Failed to marshal driver options")
}
return api.NewHost("libvirt", constants.BinDir(), json)
}
/* FIXME: host.Host is only known here, and libvirt.Driver is only accessible
* in libvirt/driver_linux.go
*/
func loadDriverConfig(host *host.Host) (*machineLibvirt.Driver, error) {
var libvirtDriver machineLibvirt.Driver
err := json.Unmarshal(host.RawDriver, &libvirtDriver)
return &libvirtDriver, err
}
func updateDriverConfig(host *host.Host, driver *machineLibvirt.Driver) error {
driverData, err := json.Marshal(driver)
if err != nil {
return err
}
return host.UpdateConfig(driverData)
}
/*
func (r *RPCServerDriver) SetConfigRaw(data []byte, _ *struct{}) error {
return json.Unmarshal(data, &r.ActualDriver)
}
*/