@@ -4,10 +4,9 @@ import (
4
4
"context"
5
5
"sync"
6
6
7
- "github.com/docker/docker/pkg/plugingetter"
8
7
"github.com/docker/go-events"
9
8
"github.com/moby/swarmkit/v2/api"
10
- "github.com/moby/swarmkit/v2/manager/allocator/cnmallocator "
9
+ "github.com/moby/swarmkit/v2/manager/allocator/networkallocator "
11
10
"github.com/moby/swarmkit/v2/manager/state"
12
11
"github.com/moby/swarmkit/v2/manager/state/store"
13
12
)
@@ -31,11 +30,7 @@ type Allocator struct {
31
30
// doneChan is closed when the allocator is finished running.
32
31
doneChan chan struct {}
33
32
34
- // pluginGetter provides access to docker's plugin inventory.
35
- pluginGetter plugingetter.PluginGetter
36
-
37
- // networkConfig stores network related config for the cluster
38
- networkConfig * cnmallocator.NetworkConfig
33
+ nwkAllocator networkallocator.NetworkAllocator
39
34
}
40
35
41
36
// taskBallot controls how the voting for task allocation is
@@ -69,19 +64,19 @@ type allocActor struct {
69
64
70
65
// New returns a new instance of Allocator for use during allocation
71
66
// stage of the manager.
72
- func New (store * store.MemoryStore , pg plugingetter.PluginGetter , netConfig * cnmallocator.NetworkConfig ) (* Allocator , error ) {
73
- a := & Allocator {
67
+ func New (store * store.MemoryStore , na networkallocator.NetworkAllocator ) * Allocator {
68
+ if na == nil {
69
+ na = networkallocator.Inert {}
70
+ }
71
+ return & Allocator {
74
72
store : store ,
75
73
taskBallot : & taskBallot {
76
74
votes : make (map [string ][]string ),
77
75
},
78
- stopChan : make (chan struct {}),
79
- doneChan : make (chan struct {}),
80
- pluginGetter : pg ,
81
- networkConfig : netConfig ,
76
+ stopChan : make (chan struct {}),
77
+ doneChan : make (chan struct {}),
78
+ nwkAllocator : na ,
82
79
}
83
-
84
- return a , nil
85
80
}
86
81
87
82
// Run starts all allocator go-routines and waits for Stop to be called.
0 commit comments