This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager_factory.go
48 lines (42 loc) · 1.79 KB
/
manager_factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package deployment
import (
biagentclient "github.com/cloudfoundry/bosh-agent/agentclient"
biblobstore "github.com/cloudfoundry/bosh-cli/blobstore"
bicloud "github.com/cloudfoundry/bosh-cli/cloud"
bidisk "github.com/cloudfoundry/bosh-cli/deployment/disk"
biinstance "github.com/cloudfoundry/bosh-cli/deployment/instance"
bivm "github.com/cloudfoundry/bosh-cli/deployment/vm"
bistemcell "github.com/cloudfoundry/bosh-cli/stemcell"
)
type ManagerFactory interface {
NewManager(bicloud.Cloud, biagentclient.AgentClient, biblobstore.Blobstore) Manager
}
type managerFactory struct {
vmManagerFactory bivm.ManagerFactory
instanceManagerFactory biinstance.ManagerFactory
diskManagerFactory bidisk.ManagerFactory
stemcellManagerFactory bistemcell.ManagerFactory
deploymentFactory Factory
}
func NewManagerFactory(
vmManagerFactory bivm.ManagerFactory,
instanceManagerFactory biinstance.ManagerFactory,
diskManagerFactory bidisk.ManagerFactory,
stemcellManagerFactory bistemcell.ManagerFactory,
deploymentFactory Factory,
) ManagerFactory {
return &managerFactory{
vmManagerFactory: vmManagerFactory,
instanceManagerFactory: instanceManagerFactory,
diskManagerFactory: diskManagerFactory,
stemcellManagerFactory: stemcellManagerFactory,
deploymentFactory: deploymentFactory,
}
}
func (f *managerFactory) NewManager(cloud bicloud.Cloud, agentClient biagentclient.AgentClient, blobstore biblobstore.Blobstore) Manager {
vmManager := f.vmManagerFactory.NewManager(cloud, agentClient)
instanceManager := f.instanceManagerFactory.NewManager(cloud, vmManager, blobstore)
diskManager := f.diskManagerFactory.NewManager(cloud)
stemcellManager := f.stemcellManagerFactory.NewManager(cloud)
return NewManager(instanceManager, diskManager, stemcellManager, f.deploymentFactory)
}