forked from bitcoin-software/nubectl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteractive.go
76 lines (58 loc) · 1.36 KB
/
interactive.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
package main
import (
"fmt"
"github.com/manifoldco/promptui"
"strconv"
)
func createJailDialogue(pubkey string, name string) {
prompt := promptui.Select{
Label: "Select disk size",
Items: []string{"10g", "20g", "40g", "80g", "160g"},
}
_, disksize, err := prompt.Run()
if err != nil {
fmt.Printf("Prompt failed %v\n", err)
return
}
createJail(disksize, pubkey, name)
}
func createVmDialogue(pubkey string, name string) {
prompt := promptui.Select{
Label: "Select how many CPUs you need",
Items: []int{1, 2, 4, 8},
}
_, cpus, err := prompt.Run()
if err != nil {
fmt.Printf("Prompt failed %v\n", err)
return
}
prompt = promptui.Select{
Label: "Select how much RAM you need",
Items: []string{"512m", "2g", "4g", "8g"},
}
_, ram, err := prompt.Run()
if err != nil {
fmt.Printf("Prompt failed %v\n", err)
return
}
prompt = promptui.Select{
Label: "Select disk size",
Items: []string{"20g", "60g", "180g", "300g"},
}
_, disksize, err := prompt.Run()
if err != nil {
fmt.Printf("Prompt failed %v\n", err)
return
}
prompt = promptui.Select{
Label: "Select VM image",
Items: []string{"centos7", "ubuntu20", "freebsd13", "docker"},
}
_, image, err := prompt.Run()
if err != nil {
fmt.Printf("Prompt failed %v\n", err)
return
}
cpucount, _ := strconv.Atoi(cpus)
createVM(image, cpucount, ram, disksize, pubkey, name)
}