-
Notifications
You must be signed in to change notification settings - Fork 221
/
plan.go
48 lines (37 loc) · 1.05 KB
/
plan.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
package plan
import (
"github.com/superfly/flyctl/api"
)
const descriptionNone = "<none>"
type LaunchPlan struct {
AppName string `json:"name"`
OrgSlug string `json:"org"`
RegionCode string `json:"region"`
HighAvailability bool `json:"ha"`
CPUKind string `json:"vm_cpukind,omitempty"`
CPUs int `json:"vm_cpus,omitempty"`
MemoryMB int `json:"vm_memory,omitempty"`
VmSize string `json:"vm_size,omitempty"`
HttpServicePort int `json:"http_service_port,omitempty"`
Postgres PostgresPlan `json:"postgres"`
Redis RedisPlan `json:"redis"`
ScannerFamily string `json:"scanner_family"`
}
func (p *LaunchPlan) Guest() *api.MachineGuest {
// TODO(Allison): Determine whether we should use VmSize or CPUKind/CPUs
guest := api.MachineGuest{
CPUs: p.CPUs,
CPUKind: p.CPUKind,
}
if false {
guest.SetSize(p.VmSize)
}
guest.MemoryMB = p.MemoryMB
return &guest
}
func (p *LaunchPlan) SetGuestFields(guest *api.MachineGuest) {
p.CPUs = guest.CPUs
p.CPUKind = guest.CPUKind
p.MemoryMB = guest.MemoryMB
p.VmSize = guest.ToSize()
}