-
Notifications
You must be signed in to change notification settings - Fork 2
/
service_factory.go
40 lines (35 loc) · 960 Bytes
/
service_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
package client
import (
boshsys "github.com/cloudfoundry/bosh-utils/system"
"github.com/dpb587/ssoca/client"
svc "github.com/dpb587/ssoca/service/openvpn"
"github.com/sirupsen/logrus"
)
type ServiceFactory struct {
svc.ServiceType
runtime client.Runtime
fs boshsys.FileSystem
cmdRunner boshsys.CmdRunner
executableFinder client.ExecutableFinder
}
func NewServiceFactory(runtime client.Runtime, fs boshsys.FileSystem, cmdRunner boshsys.CmdRunner, executableFinder client.ExecutableFinder) ServiceFactory {
return ServiceFactory{
runtime: runtime,
fs: fs,
cmdRunner: cmdRunner,
executableFinder: executableFinder,
}
}
func (sf ServiceFactory) New(name string) *Service {
return NewService(
name,
sf.runtime,
sf.runtime.GetLogger().WithFields(logrus.Fields{
"service.type": sf.Type(),
"service.name": name,
}),
sf.fs,
sf.cmdRunner,
sf.executableFinder,
)
}