-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.go
69 lines (59 loc) · 1.3 KB
/
nginx.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
package nginx
import (
"fmt"
"github.com/AlecAivazis/survey/v2"
"github.com/techsquidtv/uhs-cli/models/services"
)
type Nginx struct {
services.Service `yaml:",inline"`
NginxOptions `yaml:",inline"`
}
type NginxOptions struct {
Public_path string `yaml:"public_path"`
Domain string `yaml:"domain"`
}
// Return default values for service
func (s *Nginx) Default() services.ServiceInterface {
http := 80
https := 443
p := &Nginx{
Service: services.Service{
Enabled: false,
ReplicaCount: 1,
Image: services.Image{
Repository: "nginx",
Tag: "latest",
PullPolicy: "Always",
},
Ports: services.Ports{
Http: &http,
Https: &https,
},
},
NginxOptions: NginxOptions{
Public_path: "/opt/nginx/public",
Domain: "example.com",
},
}
return p
}
func (s *Nginx) Configure() services.ServiceInterface {
s.Enabled = true
inputPublicPath := &survey.Input{
Message: "Enter the path to your Nginx public folder:",
Default: s.Public_path,
}
err := survey.AskOne(inputPublicPath, &s.Public_path)
if err != nil {
fmt.Println(err.Error())
}
inputDomain := &survey.Input{
Message: "Enter the domain you want to use:",
Default: s.Domain,
}
err = survey.AskOne(inputDomain, &s.Domain)
if err != nil {
fmt.Println(err.Error())
}
return s
}