-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqs.go
82 lines (66 loc) · 1.79 KB
/
sqs.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
78
79
80
81
82
package services
import (
"fmt"
"os"
"strconv"
"github.com/AlecAivazis/survey/v2"
)
type SqsService struct{}
func (s *SqsService) GetName() string {
return "Sqs"
}
func (s *SqsService) GetDefaultPort() int {
return 9324
}
func (s *SqsService) GetOrganization() string {
return "roribio16"
}
func (s *SqsService) GetImageName() string {
return "alpine-sqs"
}
func (s *SqsService) GetDefaults() map[string]string {
values := map[string]string{
"volume": "sqs_data",
"port": strconv.Itoa(s.GetDefaultPort()),
"management_port": "9325",
}
// merge base defaults with service defaults
for key, value := range DefaultOptions() {
values[key] = value
}
return values
}
func (s *SqsService) Prompt() (map[string]string, error) {
defaults := s.GetDefaults()
prompts := []*survey.Question{
{
Name: "volume",
Prompt: &survey.Input{Message: "What is the Docker volume name?", Default: defaults["volume"]},
Validate: survey.Required,
},
{
Name: "management_port",
Prompt: &survey.Input{Message: "What will the management port be?", Default: defaults["management_port"]},
Validate: survey.Required,
},
}
prompts = append(DefaultPrompts(s.GetDefaultPort()), prompts...)
var answers = make(map[string]interface{})
err := survey.Ask(prompts, &answers)
if err != nil {
os.Exit(1)
}
var mapped = make(map[string]string)
// convert all answers into strings and add to mapped
for key, value := range answers {
mapped[key] = value.(string)
}
return mapped, nil
}
func (s *SqsService) GetDockerCommandArgs(options map[string]string) []string {
return []string{
fmt.Sprintf("--publish=%s:9324", options["port"]),
fmt.Sprintf("--volume=%s:/data", options["volume"]),
fmt.Sprintf("--publish=%s:9325", options["management_port"]),
}
}