-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
68 lines (60 loc) · 1.84 KB
/
main.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
package main
import (
"embed"
"github.com/dsieradzki/K4Prox/internal/app"
"github.com/dsieradzki/K4Prox/internal/collect"
"github.com/dsieradzki/K4Prox/internal/event"
"github.com/dsieradzki/K4Prox/internal/proxmox"
"github.com/dsieradzki/K4Prox/internal/ssh"
"github.com/dsieradzki/K4Prox/internal/tasklog"
"github.com/dsieradzki/K4Prox/pkg/service"
log "github.com/sirupsen/logrus"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
log.SetLevel(log.TraceLevel)
proxmoxClient := proxmox.NewProxmoxClient()
proxmoxSsh := ssh.NewSshClient()
eventCollector := event.NewEventCollector()
eventSourceForTaskLog := func() []tasklog.Event {
return collect.Map(eventCollector.Get(), func(e event.Event) tasklog.Event {
return tasklog.Event{
CorrelationId: e.CorrelationId,
CreateTime: e.CreateTime,
Name: e.Name,
Details: e.Details,
State: tasklog.EventState(e.State),
}
})
}
taskLogReader := tasklog.NewTaskLogReader(eventSourceForTaskLog)
// SERVICES
loginService := service.NewLoginService(proxmoxClient, proxmoxSsh)
projectService := service.NewProjectService(proxmoxClient)
provisionerService := service.NewProvisionerService(projectService, proxmoxClient, proxmoxSsh, eventCollector)
taskLogService := service.NewTaskLogService(eventCollector, taskLogReader)
application := app.NewApp([]service.WailsContext{
projectService,
})
// Create application with options
err := wails.Run(&options.App{
Title: "K4Prox",
Width: 1370,
Height: 850,
Assets: assets,
OnStartup: application.Startup,
OnShutdown: application.Shutdown,
Bind: []interface{}{
projectService,
loginService,
provisionerService,
taskLogService,
},
})
if err != nil {
println("Error:", err)
}
}