Skip to content

Commit dddb5c9

Browse files
committed
Renames address filtering methods to indicate explicitly that they utilise space *name*.
This is in preparation for address filtering based on space subnets.
1 parent a18891e commit dddb5c9

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

agent/agentbootstrap/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func initAPIHostPorts(c agent.ConfigSetter, st *state.State, addrs []network.Add
330330
var hostPorts []network.HostPort
331331
// First try to select the correct address using the default space where all
332332
// API servers should be accessible on.
333-
spaceAddr, ok := network.SelectAddressBySpaces(addrs)
333+
spaceAddr, ok := network.SelectAddressBySpaceNames(addrs)
334334
if ok {
335335
logger.Debugf("selected %q as API address", spaceAddr.Value)
336336
hostPorts = network.AddressesWithPort([]network.Address{spaceAddr}, apiPort)

mongo/mongo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func SelectPeerHostPortBySpace(hostPorts []network.HostPort, space network.Space
300300
logger.Debugf("selecting mongo peer hostPort in space %s from %+v", space, hostPorts)
301301
// ScopeMachineLocal addresses are OK if we can't pick by space.
302302
suitableHostPorts, foundHostPortsInSpaces :=
303-
network.SelectMongoHostPortsBySpaces(hostPorts, []network.SpaceName{space})
303+
network.SelectMongoHostPortsBySpaceNames(hostPorts, []network.SpaceName{space})
304304

305305
if !foundHostPortsInSpaces {
306306
logger.Debugf("Failed to select hostPort by space - trying by scope from %+v", hostPorts)

network/address.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ func ExactScopeMatch(addr Address, addrScopes ...Scope) bool {
275275
return false
276276
}
277277

278-
// SelectAddressBySpaces picks the first address from the given slice that has
278+
// SelectAddressBySpaceNames picks the first address from the given slice that has
279279
// the given space name associated.
280-
func SelectAddressBySpaces(addresses []Address, spaceNames ...SpaceName) (Address, bool) {
280+
func SelectAddressBySpaceNames(addresses []Address, spaceNames ...SpaceName) (Address, bool) {
281281
for _, addr := range addresses {
282282
if spaceNameList(spaceNames).IndexOf(addr.SpaceName) >= 0 {
283283
logger.Debugf("selected %q as first address in space %q", addr.Value, addr.SpaceName)
@@ -293,9 +293,9 @@ func SelectAddressBySpaces(addresses []Address, spaceNames ...SpaceName) (Addres
293293
return Address{}, false
294294
}
295295

296-
// SelectHostPortsBySpaces filters the input slice of HostPorts down to
296+
// SelectHostPortsBySpaceNames filters the input slice of HostPorts down to
297297
// those in the inpu space name.
298-
func SelectHostPortsBySpaces(hps []HostPort, spaceNames ...SpaceName) ([]HostPort, bool) {
298+
func SelectHostPortsBySpaceNames(hps []HostPort, spaceNames ...SpaceName) ([]HostPort, bool) {
299299
if len(spaceNames) == 0 {
300300
logger.Errorf("host ports not filtered - no spaces given.")
301301
return hps, false
@@ -331,15 +331,15 @@ func SelectControllerAddress(addresses []Address, machineLocal bool) (Address, b
331331
return internalAddress, ok
332332
}
333333

334-
// SelectMongoHostPortsBySpaces returns the most suitable HostPort (as string) to
334+
// SelectMongoHostPortsBySpaceNames returns the most suitable HostPort (as string) to
335335
// use as a Juju Controller (API/state server) endpoint given the list of
336336
// hostPorts. It first tries to find the first HostPort bound to the
337337
// spaces provided, then, if that fails, uses the older selection method based on scope.
338338
// When machineLocal is true and an address can't be selected by space both
339339
// ScopeCloudLocal and ScopeMachineLocal addresses are considered during the
340340
// selection, otherwise just ScopeCloudLocal are.
341-
func SelectMongoHostPortsBySpaces(hostPorts []HostPort, spaces []SpaceName) ([]string, bool) {
342-
filteredHostPorts, ok := SelectHostPortsBySpaces(hostPorts, spaces...)
341+
func SelectMongoHostPortsBySpaceNames(hostPorts []HostPort, spaces []SpaceName) ([]string, bool) {
342+
filteredHostPorts, ok := SelectHostPortsBySpaceNames(hostPorts, spaces...)
343343
if ok {
344344
logger.Debugf(
345345
"selected %q as controller host:port, using spaces %q",

state/address.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (st *State) filterHostPortsForManagementSpace(apiHostPorts [][]network.Host
198198
hostPortsForAgents = make([][]network.HostPort, len(apiHostPorts))
199199
sp := network.SpaceName(mgmtSpace)
200200
for i := range apiHostPorts {
201-
if filtered, ok := network.SelectHostPortsBySpaces(apiHostPorts[i], sp); ok {
201+
if filtered, ok := network.SelectHostPortsBySpaceNames(apiHostPorts[i], sp); ok {
202202
hostPortsForAgents[i] = filtered
203203
} else {
204204
hostPortsForAgents[i] = apiHostPorts[i]

0 commit comments

Comments
 (0)