Skip to content

Commit b841f1f

Browse files
committed
feat(certs-auto): add certs-auto support
1 parent d9a5166 commit b841f1f

4 files changed

Lines changed: 108 additions & 18 deletions

File tree

Gopkg.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ type Commander interface {
8989
TLSInfo(string) error
9090
TLSEnable(string) error
9191
TLSDisable(string) error
92+
TLSAutoEnable(string) error
93+
TLSAutoDisable(string) error
9294
UsersList(results int) error
9395
WhitelistAdd(string, string) error
9496
WhitelistList(string) error

cmd/tls.go

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (d *DryccCmd) TLSEnable(appID string) error {
3232
d.Printf("Enabling https-only requests for %s... ", appID)
3333

3434
quit := progress(d.WOut)
35-
_, err = tls.Enable(s.Client, appID)
35+
_, err = tls.EnableHTTPSEnforced(s.Client, appID)
3636
quit <- true
3737
<-quit
3838
if d.checkAPICompatibility(s.Client, err) != nil {
@@ -54,7 +54,51 @@ func (d *DryccCmd) TLSDisable(appID string) error {
5454
d.Printf("Disabling https-only requests for %s... ", appID)
5555

5656
quit := progress(d.WOut)
57-
_, err = tls.Disable(s.Client, appID)
57+
_, err = tls.DisableHTTPSEnforced(s.Client, appID)
58+
quit <- true
59+
<-quit
60+
if d.checkAPICompatibility(s.Client, err) != nil {
61+
return err
62+
}
63+
64+
d.Println("done")
65+
return nil
66+
}
67+
68+
// TLSAutoEnable enables certs-auto requests to the application.
69+
func (d *DryccCmd) TLSAutoEnable(appID string) error {
70+
s, appID, err := load(d.ConfigFile, appID)
71+
72+
if err != nil {
73+
return err
74+
}
75+
76+
d.Printf("Enabling certs-auto requests for %s... ", appID)
77+
78+
quit := progress(d.WOut)
79+
_, err = tls.EnableCertsAutoEnabled(s.Client, appID)
80+
quit <- true
81+
<-quit
82+
if d.checkAPICompatibility(s.Client, err) != nil {
83+
return err
84+
}
85+
86+
d.Println("done")
87+
return nil
88+
}
89+
90+
// TLSAutoDisable disables certs-auto requests to the application.
91+
func (d *DryccCmd) TLSAutoDisable(appID string) error {
92+
s, appID, err := load(d.ConfigFile, appID)
93+
94+
if err != nil {
95+
return err
96+
}
97+
98+
d.Printf("Disabling certs-auto requests for %s... ", appID)
99+
100+
quit := progress(d.WOut)
101+
_, err = tls.DisableCertsAutoEnabled(s.Client, appID)
58102
quit <- true
59103
<-quit
60104
if d.checkAPICompatibility(s.Client, err) != nil {

parser/tls.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Use 'drycc help [command]' to learn more.
2424
return tlsEnable(argv, cmdr)
2525
case "tls:disable":
2626
return tlsDisable(argv, cmdr)
27+
case "tls:auto:enable":
28+
return tlsAutoEnable(argv, cmdr)
29+
case "tls:auto:disable":
30+
return tlsAutoDisable(argv, cmdr)
2731
default:
2832
if printHelp(argv, usage) {
2933
return nil
@@ -98,3 +102,43 @@ Options:
98102

99103
return cmdr.TLSDisable(safeGetValue(args, "--app"))
100104
}
105+
106+
func tlsAutoEnable(argv []string, cmdr cmd.Commander) error {
107+
usage := `
108+
Enable certs-auto requests to current application.
109+
110+
Usage: drycc tls:auto:enable [options]
111+
112+
Options:
113+
-a --app=<app>
114+
the uniquely identifiable name for the application.
115+
`
116+
117+
args, err := docopt.Parse(usage, argv, true, "", false, true)
118+
119+
if err != nil {
120+
return err
121+
}
122+
123+
return cmdr.TLSAutoEnable(safeGetValue(args, "--app"))
124+
}
125+
126+
func tlsAutoDisable(argv []string, cmdr cmd.Commander) error {
127+
usage := `
128+
Disable certs-auto requests to current application.
129+
130+
Usage: drycc tls:auto:disable [options]
131+
132+
Options:
133+
-a --app=<app>
134+
the uniquely identifiable name for the application.
135+
`
136+
137+
args, err := docopt.Parse(usage, argv, true, "", false, true)
138+
139+
if err != nil {
140+
return err
141+
}
142+
143+
return cmdr.TLSAutoDisable(safeGetValue(args, "--app"))
144+
}

0 commit comments

Comments
 (0)