Skip to content

Commit dbf56da

Browse files
committed
chore(controller-sdk-go): remove start/stop api
1 parent 7e05531 commit dbf56da

4 files changed

Lines changed: 62 additions & 213 deletions

File tree

api/ps.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ type ProcessType map[string]string
1010

1111
// Pods defines the structure of a process.
1212
type Pods struct {
13-
Release string `json:"release,omitempty"`
14-
Type string `json:"type,omitempty"`
15-
Name string `json:"name,omitempty"`
16-
State string `json:"state,omitempty"`
17-
Started time.Time `json:"started,omitempty"`
18-
Replicas string `json:"replicas,omitempty"`
13+
Release string `json:"release"`
14+
Type string `json:"type"`
15+
Name string `json:"name"`
16+
State string `json:"state"`
17+
Started time.Time `json:"started"`
1918
}
2019

2120
// PodsList defines a collection of app pods.
@@ -29,8 +28,6 @@ func (p PodsList) Less(i, j int) bool { return p[i].Name < p[j].Name }
2928
type PodType struct {
3029
Type string
3130
PodsList PodsList
32-
Replicas string
33-
Status string
3431
}
3532

3633
// PodTypes holds groups of pods organized by type.

api/ps_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99

1010
func TestPodsListSorted(t *testing.T) {
1111
pods := PodsList{
12-
{"", "web", "web.fsdfgh4", "up", time.Time{}, "4"},
13-
{"", "web", "web.asdfgh1", "up", time.Time{}, "4"},
14-
{"", "web", "web.csdfgh3", "up", time.Time{}, "4"},
15-
{"", "web", "web.bsdfgh2", "up", time.Time{}, "4"},
12+
{"", "web", "web.fsdfgh4", "up", time.Time{}},
13+
{"", "web", "web.asdfgh1", "up", time.Time{}},
14+
{"", "web", "web.csdfgh3", "up", time.Time{}},
15+
{"", "web", "web.bsdfgh2", "up", time.Time{}},
1616
}
1717

1818
sort.Sort(pods)
@@ -28,9 +28,9 @@ func TestPodsListSorted(t *testing.T) {
2828

2929
func TestPodTypesSorted(t *testing.T) {
3030
podTypes := PodTypes{
31-
{"worker", PodsList{}, "4", "started"},
32-
{"web", PodsList{}, "4", "started"},
33-
{"clock", PodsList{}, "4", "started"},
31+
{"worker", PodsList{}},
32+
{"web", PodsList{}},
33+
{"clock", PodsList{}},
3434
}
3535

3636
sort.Sort(podTypes)

ps/ps.go

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -44,40 +44,6 @@ func Scale(c *drycc.Client, appID string, targets map[string]int) error {
4444
return err
4545
}
4646

47-
// Stop decreases an app's processes to 0. The processes are specified in the target argument
48-
func Stop(c *drycc.Client, appID string, targets map[string][]string) error {
49-
u := fmt.Sprintf("/v2/apps/%s/stop/", appID)
50-
51-
body, err := json.Marshal(targets)
52-
53-
if err != nil {
54-
return err
55-
}
56-
57-
res, err := c.Request("POST", u, body)
58-
if err == nil {
59-
return res.Body.Close()
60-
}
61-
return err
62-
}
63-
64-
// Start increases an app's processes to setting. The processes are specified in the target argument
65-
func Start(c *drycc.Client, appID string, targets map[string][]string) error {
66-
u := fmt.Sprintf("/v2/apps/%s/start/", appID)
67-
68-
body, err := json.Marshal(targets)
69-
70-
if err != nil {
71-
return err
72-
}
73-
74-
res, err := c.Request("POST", u, body)
75-
if err == nil {
76-
return res.Body.Close()
77-
}
78-
return err
79-
}
80-
8147
// Restart restarts an app's processes. To restart all app processes, pass empty strings for
8248
// procType and name. To restart an specific process, pass an procType by leave name empty.
8349
// To restart a specific instance, pass a procType and a name.
@@ -118,28 +84,16 @@ func ByType(processes api.PodsList) api.PodTypes {
11884
for i, pt := range pts {
11985
if pt.Type == process.Type {
12086
exists = true
121-
if process.Name != "" {
122-
pts[i].PodsList = append(pts[i].PodsList, process)
123-
}
87+
pts[i].PodsList = append(pts[i].PodsList, process)
12488
break
12589
}
12690
}
12791

12892
// Is processtype for process doesn't exist, create a new one
12993
if !exists {
130-
p := api.PodsList{process}
131-
status := "started"
132-
if process.State == "stopped" && process.Replicas != "0" {
133-
status = "stopped"
134-
}
135-
if process.Name == "" {
136-
p = api.PodsList{}
137-
}
13894
pts = append(pts, api.PodType{
13995
Type: process.Type,
140-
PodsList: p,
141-
Replicas: process.Replicas,
142-
Status: status,
96+
PodsList: api.PodsList{process},
14397
})
14498
}
14599
}

0 commit comments

Comments
 (0)