Skip to content

Commit

Permalink
Remove NewProviderAddresses constructors
Browse files Browse the repository at this point in the history
Instead use the cleaner NewMachineAddresses().AsProviderAddresses
  • Loading branch information
jack-w-shaw committed Jan 5, 2022
1 parent b990d0c commit 9c5bc6a
Show file tree
Hide file tree
Showing 28 changed files with 144 additions and 87 deletions.
4 changes: 2 additions & 2 deletions agent/agentbootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ LXC_BRIDGE="ignored"`[1:])
expectBootstrapConstraints := constraints.MustParse("mem=1024M")
expectModelConstraints := constraints.MustParse("mem=512M")
expectHW := instance.MustParseHardware("mem=2048M")
initialAddrs := corenetwork.NewProviderAddresses(
initialAddrs := corenetwork.NewMachineAddresses([]string{
"zeroonetwothree",
"0.1.2.3",
"10.0.3.1", // lxc bridge address filtered.
Expand All @@ -134,7 +134,7 @@ LXC_BRIDGE="ignored"`[1:])
"10.0.4.1", // lxd bridge address filtered.
"10.0.4.4", // lxd bridge address filtered.
"10.0.4.5", // not an lxd bridge address
)
}).AsProviderAddresses()
filteredAddrs := corenetwork.NewSpaceAddresses(
"zeroonetwothree",
"0.1.2.3",
Expand Down
2 changes: 1 addition & 1 deletion api/provisioner/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ func (s *provisionerContainerSuite) TestPrepareContainerInterfaceInfoSingleNIC(c
Addresses: corenetwork.ProviderAddresses{corenetwork.NewMachineAddress(
"192.168.0.6", corenetwork.WithCIDR("192.168.0.5/24"), corenetwork.WithConfigType(corenetwork.ConfigStatic),
).AsProviderAddress()},
DNSServers: corenetwork.NewProviderAddresses("8.8.8.8"),
DNSServers: corenetwork.NewMachineAddresses([]string{"8.8.8.8"}).AsProviderAddresses(),
DNSSearchDomains: []string{"mydomain"},
GatewayAddress: corenetwork.NewMachineAddress("192.168.0.1").AsProviderAddress(),
Routes: []corenetwork.Route{{
Expand Down
2 changes: 1 addition & 1 deletion apiserver/facades/client/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ func (s *clientSuite) TestClientAddMachinesSomeErrors(c *gc.C) {

func (s *clientSuite) TestClientAddMachinesWithInstanceIdSomeErrors(c *gc.C) {
apiParams := make([]params.AddMachineParams, 3)
addrs := network.NewProviderAddresses("1.2.3.4")
addrs := network.NewMachineAddresses([]string{"1.2.3.4"}).AsProviderAddresses()
hc := instance.MustParseHardware("mem=4G")
for i := 0; i < 3; i++ {
apiParams[i] = params.AddMachineParams{
Expand Down
2 changes: 1 addition & 1 deletion apiserver/params/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func InterfaceInfoFromNetworkConfig(configs []NetworkConfig) network.InterfaceIn
ConfigType: configType,
Addresses: ToProviderAddresses(v.Addresses...),
ShadowAddresses: ToProviderAddresses(v.ShadowAddresses...),
DNSServers: network.NewProviderAddresses(v.DNSServers...),
DNSServers: network.NewMachineAddresses(v.DNSServers).AsProviderAddresses(),
DNSSearchDomains: v.DNSSearchDomains,
GatewayAddress: network.NewMachineAddress(v.GatewayAddress).AsProviderAddress(),
Routes: routes,
Expand Down
4 changes: 2 additions & 2 deletions cloudconfig/cloudinit/network_ubuntu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *NetworkUbuntuSuite) SetUpTest(c *gc.C) {
NoAutoStart: false,
Addresses: corenetwork.ProviderAddresses{
corenetwork.NewMachineAddress("0.1.2.3", corenetwork.WithCIDR("0.1.2.0/24")).AsProviderAddress()},
DNSServers: corenetwork.NewProviderAddresses("ns1.invalid", "ns2.invalid"),
DNSServers: corenetwork.NewMachineAddresses([]string{"ns1.invalid", "ns2.invalid"}).AsProviderAddresses(),
DNSSearchDomains: []string{"foo", "bar"},
GatewayAddress: corenetwork.NewMachineAddress("0.1.2.1").AsProviderAddress(),
MACAddress: "aa:bb:cc:dd:ee:f0",
Expand All @@ -80,7 +80,7 @@ func (s *NetworkUbuntuSuite) SetUpTest(c *gc.C) {
NoAutoStart: false,
Addresses: corenetwork.ProviderAddresses{
corenetwork.NewMachineAddress("0.2.2.4", corenetwork.WithCIDR("0.2.2.0/24")).AsProviderAddress()},
DNSServers: corenetwork.NewProviderAddresses("ns1.invalid", "ns2.invalid"),
DNSServers: corenetwork.NewMachineAddresses([]string{"ns1.invalid", "ns2.invalid"}).AsProviderAddresses(),
DNSSearchDomains: []string{"foo", "bar"},
GatewayAddress: corenetwork.NewMachineAddress("0.2.2.1").AsProviderAddress(),
MACAddress: "aa:bb:cc:dd:ee:f1",
Expand Down
2 changes: 1 addition & 1 deletion cmd/jujud/agent/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func getAddressesForMongo(
args instancecfg.StateInitializationParams,
) (network.ProviderAddresses, error) {
if isCAAS {
return network.NewProviderAddresses("localhost"), nil
return network.NewMachineAddresses([]string{"localhost"}).AsProviderAddresses(), nil
}

instanceLister, ok := env.(environs.InstanceLister)
Expand Down
2 changes: 1 addition & 1 deletion cmd/jujud/agent/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (s *commonMachineSuite) setFakeMachineAddresses(c *gc.C, machine *state.Mac
c.Assert(err, jc.ErrorIsNil)
insts, err := s.Environ.Instances(context.NewEmptyCloudCallContext(), []instance.Id{instId})
c.Assert(err, jc.ErrorIsNil)
dummy.SetInstanceAddresses(insts[0], network.NewProviderAddresses("0.1.2.3"))
dummy.SetInstanceAddresses(insts[0], network.NewMachineAddresses([]string{"0.1.2.3"}).AsProviderAddresses())
}

type mockLoopDeviceManager struct {
Expand Down
2 changes: 1 addition & 1 deletion container/broker/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ var fakeInterfaceInfo = corenetwork.InterfaceInfo{
// Explicitly set only DNSServers, but not DNSSearchDomains to test this is
// detected and the latter populated by parsing the fake resolv.conf created
// by patchResolvConf(). See LP bug http://pad.lv/1575940 for more info.
DNSServers: corenetwork.NewProviderAddresses("ns1.dummy"),
DNSServers: corenetwork.NewMachineAddresses([]string{"ns1.dummy"}).AsProviderAddresses(),
DNSSearchDomains: nil,
}

Expand Down
48 changes: 26 additions & 22 deletions core/network/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ func (a MachineAddress) ValueWithMask() (string, error) {
return ipNet.String(), nil
}

// AsProviderAddress is used to construct a ProviderAddress out
// out of a MachineAddress
// AsProviderAddress is used to construct a ProviderAddress
// from a MachineAddress
func (a MachineAddress) AsProviderAddress(options ...func(mutator ProviderAddressMutator)) ProviderAddress {
addr := ProviderAddress{MachineAddress: a}

Expand Down Expand Up @@ -319,6 +319,30 @@ func NewMachineAddress(value string, options ...func(AddressMutator)) MachineAdd
return addr
}

// MachineAddresses is a slice of MachineAddress
type MachineAddresses []MachineAddress

// AsProviderAddresses is used to construct ProviderAddresses
// element-wise from MachineAddresses
func (as MachineAddresses) AsProviderAddresses(options ...func(mutator ProviderAddressMutator)) ProviderAddresses {
addrs := make(ProviderAddresses, len(as))
for i, addr := range as {
addrs[i] = addr.AsProviderAddress(options...)
}
return addrs
}

// NewMachineAddresses is a convenience function to create addresses
// from a variable number of string arguments, applying any supplied
// options to each address
func NewMachineAddresses(values []string, options ...func(AddressMutator)) MachineAddresses {
addrs := make(MachineAddresses, len(values))
for i, value := range values {
addrs[i] = NewMachineAddress(value, options...)
}
return addrs
}

// deriveScope attempts to derive the network scope from an address'
// type and value, returning the original network scope if no
// deduction can be made.
Expand Down Expand Up @@ -421,26 +445,6 @@ func (a ProviderAddress) String() string {
// supporting conversion to SpaceAddresses.
type ProviderAddresses []ProviderAddress

// NewProviderAddresses is a convenience function to create addresses
// from a variable number of string arguments.
func NewProviderAddresses(inAddresses ...string) (outAddresses ProviderAddresses) {
outAddresses = make(ProviderAddresses, len(inAddresses))
for i, address := range inAddresses {
outAddresses[i] = NewMachineAddress(address).AsProviderAddress()
}
return outAddresses
}

// NewProviderAddressesInSpace is a convenience function to create addresses
// in the same space, from a a variable number of string arguments.
func NewProviderAddressesInSpace(spaceName string, inAddresses ...string) (outAddresses ProviderAddresses) {
outAddresses = make(ProviderAddresses, len(inAddresses))
for i, address := range inAddresses {
outAddresses[i] = NewMachineAddress(address).AsProviderAddress(WithSpaceName(spaceName))
}
return outAddresses
}

// ToIPAddresses transforms the ProviderAddresses to a string slice containing
// their raw IP values.
func (pas ProviderAddresses) ToIPAddresses() []string {
Expand Down
4 changes: 2 additions & 2 deletions core/network/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ func (s *AddressSuite) TestAsProviderAddress(c *gc.C) {
})
}

func (s *AddressSuite) TestNewProviderAddressesInSpace(c *gc.C) {
addrs := network.NewProviderAddressesInSpace("bar", "0.2.3.4", "fc00::1")
func (s *AddressSuite) TestAsProviderAddresses(c *gc.C) {
addrs := network.NewMachineAddresses([]string{"0.2.3.4", "fc00::1"}).AsProviderAddresses(network.WithSpaceName("bar"))
c.Check(addrs, jc.DeepEquals, network.ProviderAddresses{{
MachineAddress: network.MachineAddress{
Value: "0.2.3.4",
Expand Down
2 changes: 1 addition & 1 deletion core/network/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func ParseResolvConf(path string) (*DNSConfig, error) {
}

return &DNSConfig{
Nameservers: NewProviderAddresses(nameservers...),
Nameservers: NewMachineAddresses(nameservers).AsProviderAddresses(),
SearchDomains: searchDomains,
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion core/network/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ nameserver 8.8.8.8 #comment #still the same comment
result, err := network.ParseResolvConf(fakeConf)
c.Check(err, jc.ErrorIsNil)
c.Check(result, jc.DeepEquals, &network.DNSConfig{
Nameservers: network.NewProviderAddresses("8.8.8.8"),
Nameservers: network.NewMachineAddresses([]string{"8.8.8.8"}).AsProviderAddresses(),
SearchDomains: []string{"foo", "example.com", "bar."},
})
}
Expand Down
4 changes: 2 additions & 2 deletions core/network/nic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s *nicSuite) SetUpTest(_ *gc.C) {
{VLANTag: 42, DeviceIndex: 2, InterfaceName: "br2"},
{ConfigType: network.ConfigDHCP, NoAutoStart: true},
{Addresses: network.ProviderAddresses{network.NewMachineAddress("0.1.2.3").AsProviderAddress()}},
{DNSServers: network.NewProviderAddresses("1.1.1.1", "2.2.2.2")},
{DNSServers: network.NewMachineAddresses([]string{"1.1.1.1", "2.2.2.2"}).AsProviderAddresses()},
{GatewayAddress: network.NewMachineAddress("4.3.2.1").AsProviderAddress()},
{AvailabilityZones: []string{"foo", "bar"}},
{Routes: []network.Route{{
Expand Down Expand Up @@ -61,7 +61,7 @@ func (s *nicSuite) TestAdditionalFields(c *gc.C) {
c.Check(s.info[3].ConfigType, gc.Equals, network.ConfigDHCP)
c.Check(s.info[3].NoAutoStart, jc.IsTrue)
c.Check(s.info[4].Addresses, jc.DeepEquals, network.ProviderAddresses{network.NewMachineAddress("0.1.2.3").AsProviderAddress()})
c.Check(s.info[5].DNSServers, jc.DeepEquals, network.NewProviderAddresses("1.1.1.1", "2.2.2.2"))
c.Check(s.info[5].DNSServers, jc.DeepEquals, network.NewMachineAddresses([]string{"1.1.1.1", "2.2.2.2"}).AsProviderAddresses())
c.Check(s.info[6].GatewayAddress, jc.DeepEquals, network.NewMachineAddress("4.3.2.1").AsProviderAddress())
c.Check(s.info[7].AvailabilityZones, jc.DeepEquals, []string{"foo", "bar"})
c.Check(s.info[8].Routes, jc.DeepEquals, []network.Route{{
Expand Down
8 changes: 4 additions & 4 deletions network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ LXC_BRIDGE="ignored"`[1:])
})
s.PatchValue(&network.LXCNetDefaultConfig, lxcFakeNetConfig)

inputAddresses := corenetwork.NewProviderAddresses(
inputAddresses := corenetwork.NewMachineAddresses([]string{
"127.0.0.1",
"2001:db8::1",
"10.0.0.1",
Expand All @@ -165,15 +165,15 @@ LXC_BRIDGE="ignored"`[1:])
"192.168.122.1", // filtered (from virbr0 bridge, 192.168.122.1)
"192.168.123.42",
"localhost", // unfiltered because it isn't an IP address
)
filteredAddresses := corenetwork.NewProviderAddresses(
}).AsProviderAddresses()
filteredAddresses := corenetwork.NewMachineAddresses([]string{
"127.0.0.1",
"2001:db8::1",
"10.0.0.1",
"10.0.6.10",
"192.168.123.42",
"localhost",
)
}).AsProviderAddresses()
c.Assert(network.FilterBridgeAddresses(inputAddresses), jc.DeepEquals, filteredAddresses)
}

Expand Down
12 changes: 6 additions & 6 deletions provider/azure/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ func (s *instanceSuite) TestInstanceAddresses(c *gc.C) {
}
addresses, err := s.getInstance(c, "machine-0").Addresses(s.callCtx)
c.Assert(err, jc.ErrorIsNil)
c.Assert(addresses, jc.DeepEquals, corenetwork.NewProviderAddresses(
c.Assert(addresses, jc.DeepEquals, corenetwork.NewMachineAddresses([]string{
"10.0.0.4", "10.0.0.5", "1.2.3.4", "1.2.3.5",
))
}).AsProviderAddresses())
}

func (s *instanceSuite) TestMultipleInstanceAddresses(c *gc.C) {
Expand All @@ -289,15 +289,15 @@ func (s *instanceSuite) TestMultipleInstanceAddresses(c *gc.C) {

inst0Addresses, err := instances[0].Addresses(s.callCtx)
c.Assert(err, jc.ErrorIsNil)
c.Assert(inst0Addresses, jc.DeepEquals, corenetwork.NewProviderAddresses(
c.Assert(inst0Addresses, jc.DeepEquals, corenetwork.NewMachineAddresses([]string{
"10.0.0.4", "1.2.3.4",
))
}).AsProviderAddresses())

inst1Addresses, err := instances[1].Addresses(s.callCtx)
c.Assert(err, jc.ErrorIsNil)
c.Assert(inst1Addresses, jc.DeepEquals, corenetwork.NewProviderAddresses(
c.Assert(inst1Addresses, jc.DeepEquals, corenetwork.NewMachineAddresses([]string{
"10.0.0.5", "1.2.3.5",
))
}).AsProviderAddresses())
}

func (s *instanceSuite) TestIngressRulesEmpty(c *gc.C) {
Expand Down
10 changes: 5 additions & 5 deletions provider/common/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func (s *BootstrapSuite) TestSuccess(c *gc.C) {
var innerInstanceConfig *instancecfg.InstanceConfig
inst := &mockInstance{
id: checkInstanceId,
addresses: network.NewProviderAddresses("testing.invalid"),
addresses: network.NewMachineAddresses([]string{"testing.invalid"}).AsProviderAddresses(),
}
startInstance := func(ctx envcontext.ProviderCallContext, args environs.StartInstanceParams) (
instances.Instance,
Expand Down Expand Up @@ -683,7 +683,7 @@ func (s *BootstrapSuite) TestBootstrapFinalizeCloudInitUserData(c *gc.C) {
var innerInstanceConfig *instancecfg.InstanceConfig
inst := &mockInstance{
id: "i-success",
addresses: network.NewProviderAddresses("testing.invalid"),
addresses: network.NewMachineAddresses([]string{"testing.invalid"}).AsProviderAddresses(),
}
startInstance := func(ctx envcontext.ProviderCallContext, args environs.StartInstanceParams) (
instances.Instance,
Expand Down Expand Up @@ -839,7 +839,7 @@ type neverOpensPort struct {
}

func (n *neverOpensPort) Addresses(ctx envcontext.ProviderCallContext) (network.ProviderAddresses, error) {
return network.NewProviderAddresses(n.addr), nil
return network.NewMachineAddresses([]string{n.addr}).AsProviderAddresses(), nil
}

func (s *BootstrapSuite) TestWaitSSHTimesOutWaitingForDial(c *gc.C) {
Expand Down Expand Up @@ -873,7 +873,7 @@ func (c *cancelOnDial) Addresses(ctx envcontext.ProviderCallContext) (network.Pr
c.cancel = nil
}
}
return network.NewProviderAddresses(c.name), nil
return network.NewMachineAddresses([]string{c.name}).AsProviderAddresses(), nil
}

func (s *BootstrapSuite) TestWaitSSHKilledWaitingForDial(c *gc.C) {
Expand Down Expand Up @@ -908,7 +908,7 @@ func (ac *addressesChange) Status(ctx envcontext.ProviderCallContext) instance.S
}

func (ac *addressesChange) Addresses(ctx envcontext.ProviderCallContext) (network.ProviderAddresses, error) {
return network.NewProviderAddresses(ac.addrs[0]...), nil
return network.NewMachineAddresses(ac.addrs[0]).AsProviderAddresses(), nil
}

func (s *BootstrapSuite) TestWaitSSHRefreshAddresses(c *gc.C) {
Expand Down
6 changes: 3 additions & 3 deletions provider/dummy/environs.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ func (e *environ) Bootstrap(ctx environs.BootstrapContext, callCtx context.Provi
series := config.PreferredSeries(e.Config())
i := &dummyInstance{
id: BootstrapInstanceId,
addresses: network.NewProviderAddresses("localhost"),
addresses: network.NewMachineAddresses([]string{"localhost"}).AsProviderAddresses(),
machineId: agent.BootstrapControllerId,
series: series,
firewallMode: e.Config().FirewallMode(),
Expand Down Expand Up @@ -1216,7 +1216,7 @@ func (e *environ) StartInstance(ctx context.ProviderCallContext, args environs.S
idString := fmt.Sprintf("%s-%d", e.name, estate.maxId)
// Add the addresses we want to see in the machine doc. This means both
// IPv4 and IPv6 loopback, as well as the DNS name.
addrs := network.NewProviderAddresses(idString+".dns", "127.0.0.1", "::1")
addrs := network.NewMachineAddresses([]string{idString + ".dns", "127.0.0.1", "::1"}).AsProviderAddresses()
logger.Debugf("StartInstance addresses: %v", addrs)
i := &dummyInstance{
id: instance.Id(idString),
Expand Down Expand Up @@ -1486,7 +1486,7 @@ func (env *environ) NetworkInterfaces(ctx context.ProviderCallContext, ids []ins
network.WithConfigType(network.ConfigDHCP),
).AsProviderAddress(),
},
DNSServers: network.NewProviderAddresses("ns1.dummy", "ns2.dummy"),
DNSServers: network.NewMachineAddresses([]string{"ns1.dummy", "ns2.dummy"}).AsProviderAddresses(),
GatewayAddress: network.NewMachineAddress(
fmt.Sprintf("0.%d.0.1", (i+1)*10+idIndex),
).AsProviderAddress(),
Expand Down
6 changes: 3 additions & 3 deletions provider/dummy/environs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (s *suite) TestNetworkInterfaces(c *gc.C) {
Addresses: corenetwork.ProviderAddresses{corenetwork.NewMachineAddress(
"0.10.0.2", corenetwork.WithCIDR("0.10.0.0/24"), corenetwork.WithConfigType(corenetwork.ConfigDHCP),
).AsProviderAddress()},
DNSServers: corenetwork.NewProviderAddresses("ns1.dummy", "ns2.dummy"),
DNSServers: corenetwork.NewMachineAddresses([]string{"ns1.dummy", "ns2.dummy"}).AsProviderAddresses(),
GatewayAddress: corenetwork.NewMachineAddress("0.10.0.1").AsProviderAddress(),
Origin: corenetwork.OriginProvider,
}, {
Expand All @@ -268,7 +268,7 @@ func (s *suite) TestNetworkInterfaces(c *gc.C) {
Addresses: corenetwork.ProviderAddresses{corenetwork.NewMachineAddress(
"0.20.0.2", corenetwork.WithCIDR("0.20.0.0/24"), corenetwork.WithConfigType(corenetwork.ConfigDHCP),
).AsProviderAddress()},
DNSServers: corenetwork.NewProviderAddresses("ns1.dummy", "ns2.dummy"),
DNSServers: corenetwork.NewMachineAddresses([]string{"ns1.dummy", "ns2.dummy"}).AsProviderAddresses(),
GatewayAddress: corenetwork.NewMachineAddress("0.20.0.1").AsProviderAddress(),
Origin: corenetwork.OriginProvider,
}, {
Expand All @@ -284,7 +284,7 @@ func (s *suite) TestNetworkInterfaces(c *gc.C) {
Addresses: corenetwork.ProviderAddresses{corenetwork.NewMachineAddress(
"0.30.0.2", corenetwork.WithCIDR("0.30.0.0/24"), corenetwork.WithConfigType(corenetwork.ConfigDHCP),
).AsProviderAddress()},
DNSServers: corenetwork.NewProviderAddresses("ns1.dummy", "ns2.dummy"),
DNSServers: corenetwork.NewMachineAddresses([]string{"ns1.dummy", "ns2.dummy"}).AsProviderAddresses(),
GatewayAddress: corenetwork.NewMachineAddress("0.30.0.1").AsProviderAddress(),
Origin: corenetwork.OriginProvider,
}}
Expand Down
9 changes: 6 additions & 3 deletions provider/maas/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,9 @@ func (env *maasEnviron) deviceInterfaceInfo(deviceID instance.Id, nameToParentNa
).AsProviderAddress(corenetwork.WithSpaceName(link.Subnet.Space))
}
if len(link.Subnet.DNSServers) > 0 {
nicInfo.DNSServers = corenetwork.NewProviderAddressesInSpace(
link.Subnet.Space, link.Subnet.DNSServers...)
nicInfo.DNSServers = corenetwork.NewMachineAddresses(
link.Subnet.DNSServers,
).AsProviderAddresses(corenetwork.WithSpaceName(link.Subnet.Space))
}

interfaceInfo = append(interfaceInfo, nicInfo)
Expand Down Expand Up @@ -338,7 +339,9 @@ func (env *maasEnviron) deviceInterfaceInfo2(
).AsProviderAddress(corenetwork.WithSpaceName(subnet.Space()))
}
if len(subnet.DNSServers()) > 0 {
nicInfo.DNSServers = corenetwork.NewProviderAddressesInSpace(subnet.Space(), subnet.DNSServers()...)
nicInfo.DNSServers = corenetwork.NewMachineAddresses(
subnet.DNSServers(),
).AsProviderAddresses(corenetwork.WithSpaceName(subnet.Space()))
}

interfaceInfo = append(interfaceInfo, nicInfo)
Expand Down
Loading

0 comments on commit 9c5bc6a

Please sign in to comment.