-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudflared.go
85 lines (74 loc) · 1.76 KB
/
cloudflared.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
83
84
85
package cloudflared
import (
"fmt"
"github.com/AlecAivazis/survey/v2"
"github.com/techsquidtv/uhs-cli/models/services"
)
type Cloudflared struct {
services.Service `yaml:",inline"`
CloudflaredOptions `yaml:",inline"`
}
type CloudflaredOptions struct {
Tunnel string `yaml:"tunnel"`
Domain string `yaml:"domain"`
URL string `yaml:"url"`
Target string `yaml:"target"`
}
// Return default values for service
func (s *Cloudflared) Default() services.ServiceInterface {
p := &Cloudflared{
Service: services.Service{
Enabled: false,
ReplicaCount: 1,
Image: services.Image{
Repository: "cloudflare/cloudflared",
Tag: "latest",
PullPolicy: "IfNotPresent", // For stability
},
Ports: services.Ports{},
},
CloudflaredOptions: CloudflaredOptions{
Tunnel: "example-tunnel",
Domain: "example.com",
URL: "http://foo.example.com",
Target: "localhost:8080",
},
}
return p
}
func (s *Cloudflared) Configure() services.ServiceInterface {
s.Enabled = true
inputTunnel := &survey.Input{
Message: "Enter the name of your tunnel:",
Default: s.Tunnel,
}
err := survey.AskOne(inputTunnel, &s.Tunnel)
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())
}
inputURL := &survey.Input{
Message: "Enter the URL you want to use:",
Default: s.URL,
}
err = survey.AskOne(inputURL, &s.URL)
if err != nil {
fmt.Println(err.Error())
}
inputTarget := &survey.Input{
Message: "Enter the target you want to use:",
Default: s.Target,
}
err = survey.AskOne(inputTarget, &s.Target)
if err != nil {
fmt.Println(err.Error())
}
return s
}