forked from mazrean/ssh-separator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wire.go
68 lines (61 loc) · 1.82 KB
/
wire.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//go:build wireinject
// +build wireinject
package main
import (
"github.com/google/wire"
"github.com/mazrean/separated-webshell/api"
"github.com/mazrean/separated-webshell/repository"
"github.com/mazrean/separated-webshell/repository/badger"
"github.com/mazrean/separated-webshell/service"
"github.com/mazrean/separated-webshell/ssh"
"github.com/mazrean/separated-webshell/store"
"github.com/mazrean/separated-webshell/store/gomap"
"github.com/mazrean/separated-webshell/workspace"
"github.com/mazrean/separated-webshell/workspace/docker"
)
var (
transactionBind = wire.Bind(new(repository.ITransaction), new(*badger.Transaction))
storeWorkspaceBind = wire.Bind(new(store.IWorkspace), new(*gomap.Workspace))
repositoryUserBind = wire.Bind(new(repository.IUser), new(*badger.User))
workspaceBind = wire.Bind(new(workspace.IWorkspace), new(*docker.Workspace))
workspaceConnectionBind = wire.Bind(new(workspace.IWorkspaceConnection), new(*docker.WorkspaceConnection))
serviceUserBind = wire.Bind(new(service.IUser), new(*service.User))
servicePipeBind = wire.Bind(new(service.IPipe), new(*service.Pipe))
)
type Server struct {
*service.Setup
*api.API
*ssh.SSH
}
func NewServer(setup *service.Setup, a *api.API, s *ssh.SSH) (*Server, error) {
return &Server{
Setup: setup,
API: a,
SSH: s,
}, nil
}
func InjectServer() (*Server, func(), error) {
wire.Build(
NewServer,
api.NewAPI,
api.NewUser,
gomap.NewWorkspace,
badger.NewDB,
badger.NewTransaction,
badger.NewUser,
service.NewSetup,
service.NewUser,
service.NewPipe,
ssh.NewSSH,
docker.NewWorkspace,
docker.NewWorkspaceConnection,
transactionBind,
storeWorkspaceBind,
repositoryUserBind,
workspaceBind,
workspaceConnectionBind,
serviceUserBind,
servicePipeBind,
)
return nil, nil, nil
}