Skip to content

Commit f5eae01

Browse files
committed
feat(workflow-cli): remove start/stop api
1 parent 6a0fc03 commit f5eae01

8 files changed

Lines changed: 29 additions & 168 deletions

File tree

cmd/apps_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ func TestAppsInfo(t *testing.T) {
141141
"started": "2016-08-22T17:42:16Z",
142142
"name": "lorem-ipsum-cmd-1911796442-48b58",
143143
"release": "v2",
144-
"type": "cmd",
145-
"replicas": "1"
144+
"type": "cmd"
146145
}
147146
]
148147
}`)
@@ -205,7 +204,7 @@ owner: dolar-sit-amet
205204
id: lorem-ipsum
206205
207206
=== lorem-ipsum Processes
208-
--- cmd (started): 1
207+
--- cmd:
209208
lorem-ipsum-cmd-1911796442-48b58 up (v2)
210209
211210
=== lorem-ipsum Domains

cmd/cmd.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ type Commander interface {
6666
PsList(string, int) error
6767
PsScale(string, []string) error
6868
PsRestart(string, string) error
69-
PsStop(string, []string) error
70-
PsStart(string, []string) error
7169
RegistryList(string) error
7270
RegistrySet(string, []string) error
7371
RegistryUnset(string, []string) error

cmd/ps.go

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99
"time"
1010

11-
"github.com/drycc/controller-sdk-go"
11+
drycc "github.com/drycc/controller-sdk-go"
1212
"github.com/drycc/controller-sdk-go/api"
1313
"github.com/drycc/controller-sdk-go/ps"
1414
)
@@ -68,65 +68,6 @@ func (d *DryccCmd) PsScale(appID string, targets []string) error {
6868
return nil
6969
}
7070

71-
// PsStop stop an app's processes.
72-
func (d *DryccCmd) PsStop(appID string, targets []string) error {
73-
s, appID, err := load(d.ConfigFile, appID)
74-
if err != nil {
75-
return err
76-
}
77-
78-
d.Printf("Stopping processes... but first, %s!\n", drinkOfChoice())
79-
startTime := time.Now()
80-
quit := progress(d.WOut)
81-
tps := map[string][]string{"types": targets}
82-
err = ps.Stop(s.Client, appID, tps)
83-
quit <- true
84-
<-quit
85-
if d.checkAPICompatibility(s.Client, err) != nil {
86-
return err
87-
}
88-
89-
d.Printf("done in %ds\n", int(time.Since(startTime).Seconds()))
90-
91-
processes, _, err := ps.List(s.Client, appID, s.Limit)
92-
if err != nil {
93-
return err
94-
}
95-
96-
printProcesses(appID, processes, d.WOut)
97-
return nil
98-
}
99-
100-
// PsStart start an app's processes.
101-
func (d *DryccCmd) PsStart(appID string, targets []string) error {
102-
s, appID, err := load(d.ConfigFile, appID)
103-
if err != nil {
104-
return err
105-
}
106-
107-
d.Printf("Starting processes... but first, %s!\n", drinkOfChoice())
108-
startTime := time.Now()
109-
quit := progress(d.WOut)
110-
111-
tps := map[string][]string{"types": targets}
112-
err = ps.Start(s.Client, appID, tps)
113-
quit <- true
114-
<-quit
115-
if d.checkAPICompatibility(s.Client, err) != nil {
116-
return err
117-
}
118-
119-
d.Printf("done in %ds\n", int(time.Since(startTime).Seconds()))
120-
121-
processes, _, err := ps.List(s.Client, appID, s.Limit)
122-
if err != nil {
123-
return err
124-
}
125-
126-
printProcesses(appID, processes, d.WOut)
127-
return nil
128-
}
129-
13071
// PsRestart restarts an app's processes.
13172
func (d *DryccCmd) PsRestart(appID, target string) error {
13273
s, appID, err := load(d.ConfigFile, appID)
@@ -168,7 +109,7 @@ func printProcesses(appID string, input []api.Pods, wOut io.Writer) {
168109
fmt.Fprintf(wOut, "=== %s Processes\n", appID)
169110

170111
for _, process := range processes {
171-
fmt.Fprintf(wOut, "--- %s (%s): %s\n", process.Type, process.Status, process.Replicas)
112+
fmt.Fprintf(wOut, "--- %s:\n", process.Type)
172113

173114
for _, pod := range process.PodsList {
174115
fmt.Fprintf(wOut, "%s %s (%s)\n", pod.Name, pod.State, pod.Release)

cmd/ps_test.go

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,27 @@ func TestPrintProcesses(t *testing.T) {
5454

5555
pods := []api.Pods{
5656
{
57-
Release: "v3",
58-
Name: "benign-quilting-web-4084101150-c871y",
59-
Type: "web",
60-
State: "up",
61-
Started: time.Time{},
62-
Replicas: "1",
57+
Release: "v3",
58+
Name: "benign-quilting-web-4084101150-c871y",
59+
Type: "web",
60+
State: "up",
61+
Started: time.Time{},
6362
},
6463
{
65-
Release: "v3",
66-
Name: "benign-quilting-worker-4084101150-c871y",
67-
Type: "worker",
68-
State: "up",
69-
Started: time.Time{},
70-
Replicas: "1",
64+
Release: "v3",
65+
Name: "benign-quilting-worker-4084101150-c871y",
66+
Type: "worker",
67+
State: "up",
68+
Started: time.Time{},
7169
},
7270
}
7371

7472
printProcesses("appname", pods, &b)
7573

7674
assert.Equal(t, b.String(), `=== appname Processes
77-
--- web (started): 1
75+
--- web:
7876
benign-quilting-web-4084101150-c871y up (v3)
79-
--- worker (started): 1
77+
--- worker:
8078
benign-quilting-worker-4084101150-c871y up (v3)
8179
`, "output")
8280
}
@@ -103,8 +101,7 @@ func TestPsList(t *testing.T) {
103101
"type": "web",
104102
"name": "foo-web-4084101150-c871y",
105103
"state": "up",
106-
"started": "2016-02-13T00:47:52",
107-
"replicas": "1"
104+
"started": "2016-02-13T00:47:52"
108105
}
109106
]
110107
}`)
@@ -114,7 +111,7 @@ func TestPsList(t *testing.T) {
114111
assert.NoErr(t, err)
115112

116113
assert.Equal(t, b.String(), `=== foo Processes
117-
--- web (started): 1
114+
--- web:
118115
foo-web-4084101150-c871y up (v2)
119116
`, "output")
120117
}
@@ -174,8 +171,7 @@ func TestPsScale(t *testing.T) {
174171
"type": "web",
175172
"name": "foo-web-4084101150-c871y",
176173
"state": "up",
177-
"started": "2016-02-13T00:47:52",
178-
"replicas": "1"
174+
"started": "2016-02-13T00:47:52"
179175
}
180176
]
181177
}`)
@@ -193,7 +189,7 @@ func TestPsScale(t *testing.T) {
193189
assert.Equal(t, testutil.StripProgress(b.String()), `Scaling processes... but first, coffee!
194190
done in 0s
195191
=== foo Processes
196-
--- web (started): 1
192+
--- web:
197193
foo-web-4084101150-c871y up (v2)
198194
`, "output")
199195
}
@@ -216,8 +212,7 @@ func TestPsRestart(t *testing.T) {
216212
"type": "web",
217213
"name": "foo-web-4084101150-c871y",
218214
"state": "up",
219-
"started": "2016-02-13T00:47:52",
220-
"replicas": "1"
215+
"started": "2016-02-13T00:47:52"
221216
}
222217
]`)
223218
})
@@ -228,7 +223,7 @@ func TestPsRestart(t *testing.T) {
228223
assert.Equal(t, testutil.StripProgress(b.String()), `Restarting processes... but first, coffee!
229224
done in 0s
230225
=== foo Processes
231-
--- web (started): 1
226+
--- web:
232227
foo-web-4084101150-c871y up (v2)
233228
`, "output")
234229

@@ -253,8 +248,7 @@ Could not find any processes to restart
253248
"type": "web",
254249
"name": "testapp-web-4084101150-c871y",
255250
"state": "up",
256-
"started": "2016-02-13T00:47:52",
257-
"replicas": "1"
251+
"started": "2016-02-13T00:47:52"
258252
}
259253
]`)
260254
})
@@ -266,7 +260,7 @@ Could not find any processes to restart
266260
assert.Equal(t, testutil.StripProgress(b.String()), `Restarting processes... but first, coffee!
267261
done in 0s
268262
=== testapp Processes
269-
--- web (started): 1
263+
--- web:
270264
testapp-web-4084101150-c871y up (v2)
271265
`, "output")
272266

@@ -278,8 +272,7 @@ testapp-web-4084101150-c871y up (v2)
278272
"type": "web",
279273
"name": "newapp-web-4084101150-c871y",
280274
"state": "up",
281-
"started": "2016-02-13T00:47:52",
282-
"replicas": "1"
275+
"started": "2016-02-13T00:47:52"
283276
}
284277
]`)
285278
})
@@ -291,7 +284,7 @@ testapp-web-4084101150-c871y up (v2)
291284
assert.Equal(t, testutil.StripProgress(b.String()), `Restarting processes... but first, coffee!
292285
done in 0s
293286
=== newapp Processes
294-
--- web (started): 1
287+
--- web:
295288
newapp-web-4084101150-c871y up (v2)
296289
`, "output")
297290

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.17
55
require (
66
github.com/arschles/assert v1.0.1-0.20191213221312-71f210f9375a
77
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
8-
github.com/drycc/controller-sdk-go v0.0.0-20210826011521-d57f3c75935a
8+
github.com/drycc/controller-sdk-go v0.0.0-20211124095117-dbf56da8c5a8
99
github.com/drycc/pkg v0.0.0-20210826011456-c60b87108840
1010
github.com/olekukonko/tablewriter v0.0.5
1111
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh
5151
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
5252
github.com/drycc/controller-sdk-go v0.0.0-20210826011521-d57f3c75935a h1:TKz7m1cwN3ktK9bGWorLVSSmkLrDO4qALhdGUxTRToo=
5353
github.com/drycc/controller-sdk-go v0.0.0-20210826011521-d57f3c75935a/go.mod h1:DmVcssrb6yJMWI8sGT+8Xy3caVR5kSlsctD3a7Zn6FA=
54+
github.com/drycc/controller-sdk-go v0.0.0-20211124095117-dbf56da8c5a8 h1:cddNthWLhOdgvpF5S78Fc7j8I5ESDRUtTZhHIFTLcC0=
55+
github.com/drycc/controller-sdk-go v0.0.0-20211124095117-dbf56da8c5a8/go.mod h1:aGxL2AkmmG7d5afWiUGy93/+UPDnIxgsWSwxuznjteE=
5456
github.com/drycc/pkg v0.0.0-20210826011456-c60b87108840 h1:0OhP9AQ0mh3q0TMxK4PJTPSFwD/wj0xugiaZ3lnLcNA=
5557
github.com/drycc/pkg v0.0.0-20210826011456-c60b87108840/go.mod h1:KX1FLm7Fq6FLCsjjRsgfI/bMQuHZXqYf1ZXU9fzJhDw=
5658
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=

parser/ps.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ Use 'drycc help [command]' to learn more.
2626
return psRestart(argv, cmdr)
2727
case "ps:scale":
2828
return psScale(argv, cmdr)
29-
case "ps:stop":
30-
return psStop(argv, cmdr)
31-
case "ps:start":
32-
return psStart(argv, cmdr)
3329
default:
3430
if printHelp(argv, usage) {
3531
return nil
@@ -119,55 +115,3 @@ Options:
119115
apps := safeGetValue(args, "--app")
120116
return cmdr.PsScale(apps, args["<type>=<num>"].([]string))
121117
}
122-
123-
func psStop(argv []string, cmdr cmd.Commander) error {
124-
usage := `
125-
Stop an application's processes by type.
126-
127-
Usage: drycc ps:stop <type>... [options]
128-
129-
Arguments:
130-
<type>
131-
the process name as defined in your Procfile, such as 'web' or 'worker'.
132-
Note that Dockerfile apps have a default 'cmd' process type.
133-
134-
Options:
135-
-a --app=<app>
136-
the uniquely identifiable name for the application.
137-
`
138-
139-
args, err := docopt.Parse(usage, argv, true, "", false, true)
140-
141-
if err != nil {
142-
return err
143-
}
144-
145-
apps := safeGetValue(args, "--app")
146-
return cmdr.PsStop(apps, args["<type>"].([]string))
147-
}
148-
149-
func psStart(argv []string, cmdr cmd.Commander) error {
150-
usage := `
151-
Start an application's processes by type.
152-
153-
Usage: drycc ps:start <type>... [options]
154-
155-
Arguments:
156-
<type>
157-
the process name as defined in your Procfile, such as 'web' or 'worker'.
158-
Note that Dockerfile apps have a default 'cmd' process type.
159-
160-
Options:
161-
-a --app=<app>
162-
the uniquely identifiable name for the application.
163-
`
164-
165-
args, err := docopt.Parse(usage, argv, true, "", false, true)
166-
167-
if err != nil {
168-
return err
169-
}
170-
171-
apps := safeGetValue(args, "--app")
172-
return cmdr.PsStart(apps, args["<type>"].([]string))
173-
}

parser/ps_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ func (d FakeDryccCmd) PsRestart(string, string) error {
2424
return errors.New("ps:restart")
2525
}
2626

27-
func (d FakeDryccCmd) PsStop(string, []string) error {
28-
return errors.New("ps:stop")
29-
}
30-
31-
func (d FakeDryccCmd) PsStart(string, []string) error {
32-
return errors.New("ps:start")
33-
}
34-
3527
func TestPs(t *testing.T) {
3628
t.Parallel()
3729

@@ -69,14 +61,6 @@ func TestPs(t *testing.T) {
6961
args: []string{"ps"},
7062
expected: "ps:list",
7163
},
72-
{
73-
args: []string{"ps:stop", "web"},
74-
expected: "",
75-
},
76-
{
77-
args: []string{"ps:start", "web"},
78-
expected: "",
79-
},
8064
}
8165

8266
// For each case, check that calling the route with the arguments

0 commit comments

Comments
 (0)