Skip to content

Commit

Permalink
Keep names relevant and focused + Update comments to matche the reality
Browse files Browse the repository at this point in the history
  • Loading branch information
bgandon committed Feb 16, 2024
1 parent 880b3df commit be20acb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/bosh-virtualbox-cpi/vm/network/add_host_only.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (n Networks) createHostOnly(gateway, netmask string) (string, error) {
var errorMessage string
var expectedMatchesLen int

if systemInfo.IsMacOSXVBoxSpecial6or7Case() {
if systemInfo.IsMacOSVbox7() {
maskIP := net.ParseIP(netmask).To4()
if maskIP == nil {
return "", bosherr.Errorf("expected netmask to be valid IP v4 (got '%s')", netmask)
Expand Down Expand Up @@ -134,7 +134,7 @@ func (n Networks) configureHostOnly(name, gateway, netmask string) error {
return err
}

if systemInfo.IsMacOSXVBoxSpecial6or7Case() == false {
if systemInfo.IsMacOSVbox7() == false {
args := []string{"hostonlyif", "ipconfig", name}

if len(gateway) > 0 {
Expand Down Expand Up @@ -163,7 +163,7 @@ func (n Networks) cleanUpPartialHostOnlyCreate(name string) {
"remove",
name,
}
if systemInfo.IsMacOSXVBoxSpecial6or7Case() {
if systemInfo.IsMacOSVbox7() {
args = []string{
"hostonlynet",
"remove",
Expand Down
5 changes: 3 additions & 2 deletions src/bosh-virtualbox-cpi/vm/network/host_only.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package network
import (
"bosh-virtualbox-cpi/driver"
"fmt"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
"net"
"os"

boshlog "github.com/cloudfoundry/bosh-utils/logger"
)

type HostOnly struct {
Expand Down Expand Up @@ -43,7 +44,7 @@ func (n HostOnly) Enable() error {
}

var finalArgs []string
if systemInfo.IsMacOSXVBoxSpecial6or7Case() {
if systemInfo.IsMacOSVbox7() {
finalArgs = []string{"hostonlynet", "modify", fmt.Sprintf("--name=%s", n.name), "--enable"}
} else {
args := []string{"hostonlyif", "ipconfig", n.name}
Expand Down
4 changes: 2 additions & 2 deletions src/bosh-virtualbox-cpi/vm/network/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (n Networks) HostOnlys() ([]Network, error) {
}

commandName := "hostonlyifs"
if systemInfo.IsMacOSXVBoxSpecial6or7Case() {
if systemInfo.IsMacOSVbox7() {
commandName = "hostonlynets"
}

Expand Down Expand Up @@ -218,7 +218,7 @@ func (n Networks) outputChunks(output string) []string {
if err != nil {
return nil
}
if systemInfo.IsMacOSXVBoxSpecial6or7Case() {
if systemInfo.IsMacOSVbox7() {
output = strings.Replace(output, "\n\n", "\n", -1)
}

Expand Down
5 changes: 2 additions & 3 deletions src/bosh-virtualbox-cpi/vm/network/system_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ func (s SystemInfo) GetLastIP(subnet *net.IPNet) (net.IP, error) {
return getIndexedIP(subnet, int(size-1))
}

// IsMacOSXVBoxSpecial6or7Case Identify if you are system is running on MAC OS X and the used
// VirtualBox version is 6.1 or 7
func (s SystemInfo) IsMacOSXVBoxSpecial6or7Case() bool {
// IsMacOSVbox7 Identifies if you're running VirtualBox version 7 on macOS
func (s SystemInfo) IsMacOSVbox7() bool {
if s.osVersion == "darwin" && (s.vBoxMajorVersion == "7") {
return true
} else {
Expand Down
6 changes: 4 additions & 2 deletions src/bosh-virtualbox-cpi/vm/nics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package vm

import (
"fmt"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
"math/rand"
"os"
"strconv"
"strings"

boshlog "github.com/cloudfoundry/bosh-utils/logger"

network "bosh-virtualbox-cpi/vm/network"

apiv1 "github.com/cloudfoundry/bosh-cpi-go/apiv1"
bosherr "github.com/cloudfoundry/bosh-utils/errors"

Expand Down Expand Up @@ -76,7 +78,7 @@ func (n NICs) addNIC(nic string, net Network, host Host) (string, error) {
return "", err
}

if systemInfo.IsMacOSXVBoxSpecial6or7Case() {
if systemInfo.IsMacOSVbox7() {
args = append(args, []string{"hostonlynet", "--host-only-net" + nic, actualNet.Name()}...)
} else {
args = append(args, []string{"hostonly", "--hostonlyadapter" + nic, actualNet.Name()}...)
Expand Down

0 comments on commit be20acb

Please sign in to comment.