-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
68 lines (63 loc) · 2.43 KB
/
models.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 zdap
import (
"fmt"
"github.com/modfin/zdap/internal"
"time"
)
type PublicResource struct {
Name string `json:"name"`
Alias string `json:"alias"`
Snaps []PublicSnap `json:"snaps"`
ClonePool internal.ClonePoolConfig `json:"pooled_clones"`
}
type PublicSnap struct {
Name string `json:"name"`
Resource string `json:"resource"`
CreatedAt time.Time `json:"created_at"`
Clones []PublicClone `json:"clones"`
}
type PublicClone struct {
Name string `json:"name"`
Resource string `json:"resource"`
Owner string `json:"owner"`
CreatedAt time.Time `json:"created_at"`
SnappedAt time.Time `json:"snapped_at"`
Server string `json:"server"`
APIPort int `json:"api_port"`
Port int `json:"port"`
ClonePooled bool `json:"clone_pooled"`
Healthy bool `json:"healthy"`
ExpiresAt *time.Time `json:"expires_at"`
}
func (c *PublicClone) YAML(listenPort int) string {
return fmt.Sprintf(`
%s:
image: modfin/zdap-proxy:latest
environment:
- LISTEN_PORT=%d
- TARGET_ADDRESS=%s:%d
ports:
- "%d:%d"
`, c.Resource, listenPort, c.Server, c.Port, listenPort, listenPort)
}
type ServerStatus struct {
Address string `json:"address"`
Resources []string `json:"resources"`
ResourceDetails map[string]ServerResourceDetails `json:"resource_details"`
Snaps int `json:"snaps"`
Clones int `json:"clones"`
FreeDisk uint64 `json:"free_disk"`
UsedDisk uint64 `json:"used_disk"`
TotalDisk uint64 `json:"total_disk"`
Load1 float64 `json:"load_1"`
Load5 float64 `json:"load_5"`
Load15 float64 `json:"load_15"`
FreeMem uint64 `json:"free_mem"`
CachedMem uint64 `json:"cached_mem"`
TotalMem uint64 `json:"total_mem"`
UsedMem uint64 `json:"used_mem"`
}
type ServerResourceDetails struct {
Name string `json:"name"`
PooledClonesAvailable int `json:"pooled_clones_available"`
}