forked from mazrean/ssh-separator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wire_gen.go
77 lines (68 loc) · 2.32 KB
/
wire_gen.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
69
70
71
72
73
74
75
76
77
// Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire
//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"
)
// Injectors from wire.go:
func InjectServer() (*Server, func(), error) {
workspace, err := docker.NewWorkspace()
if err != nil {
return nil, nil, err
}
gomapWorkspace := gomap.NewWorkspace()
db, cleanup, err := badger.NewDB()
if err != nil {
return nil, nil, err
}
transaction := badger.NewTransaction(db)
user := badger.NewUser(db)
setup := service.NewSetup(workspace, gomapWorkspace, transaction, user)
serviceUser := service.NewUser(workspace, gomapWorkspace, user, transaction)
apiUser := api.NewUser(serviceUser)
apiAPI := api.NewAPI(apiUser)
workspaceConnection := docker.NewWorkspaceConnection()
pipe := service.NewPipe(gomapWorkspace, workspaceConnection, workspace)
sshSSH := ssh.NewSSH(serviceUser, pipe)
server, err := NewServer(setup, apiAPI, sshSSH)
if err != nil {
cleanup()
return nil, nil, err
}
return server, func() {
cleanup()
}, nil
}
// wire.go:
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
}