Fix HyperV loadMachineFromJSON function name

Re-names HyperV function that was copied from the applehv
implementation and not changed. Makes the function a method of
`HyperVMachine`.

[NO NEW TESTS NEEDED]

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
This commit is contained in:
Jake Correnti
2023-07-27 12:46:32 -04:00
parent 7496cbf0be
commit 837bc25681
2 changed files with 5 additions and 5 deletions

View File

@ -50,7 +50,7 @@ func (v HyperVVirtualization) IsValidVMName(name string) (bool, error) {
if err != nil { if err != nil {
return false, err return false, err
} }
if err := loadMacMachineFromJSON(configDir, &mm); err != nil { if err := mm.loadHyperVMachineFromJSON(configDir); err != nil {
return false, err return false, err
} }
// The name is valid for the local filesystem // The name is valid for the local filesystem
@ -257,7 +257,7 @@ func (v HyperVVirtualization) loadFromLocalJson() ([]*HyperVMachine, error) {
for _, jsonFile := range jsonFiles { for _, jsonFile := range jsonFiles {
mm := HyperVMachine{} mm := HyperVMachine{}
if err := loadMacMachineFromJSON(jsonFile, &mm); err != nil { if err := mm.loadHyperVMachineFromJSON(jsonFile); err != nil {
return nil, err return nil, err
} }
if err != nil { if err != nil {

View File

@ -520,7 +520,7 @@ func (m *HyperVMachine) loadFromFile() (*HyperVMachine, error) {
} }
mm := HyperVMachine{} mm := HyperVMachine{}
if err := loadMacMachineFromJSON(jsonPath, &mm); err != nil { if err := mm.loadHyperVMachineFromJSON(jsonPath); err != nil {
return nil, err return nil, err
} }
vmm := hypervctl.NewVirtualMachineManager() vmm := hypervctl.NewVirtualMachineManager()
@ -555,7 +555,7 @@ func getVMConfigPath(configDir, vmName string) string {
return filepath.Join(configDir, fmt.Sprintf("%s.json", vmName)) return filepath.Join(configDir, fmt.Sprintf("%s.json", vmName))
} }
func loadMacMachineFromJSON(fqConfigPath string, macMachine *HyperVMachine) error { func (m *HyperVMachine) loadHyperVMachineFromJSON(fqConfigPath string) error {
b, err := os.ReadFile(fqConfigPath) b, err := os.ReadFile(fqConfigPath)
if err != nil { if err != nil {
if errors.Is(err, fs.ErrNotExist) { if errors.Is(err, fs.ErrNotExist) {
@ -563,7 +563,7 @@ func loadMacMachineFromJSON(fqConfigPath string, macMachine *HyperVMachine) erro
} }
return err return err
} }
return json.Unmarshal(b, macMachine) return json.Unmarshal(b, m)
} }
func (m *HyperVMachine) startHostNetworking() (string, machine.APIForwardingState, error) { func (m *HyperVMachine) startHostNetworking() (string, machine.APIForwardingState, error) {