Skip to content

Commit 81d290b

Browse files
committed
feat(canary): remove canary api
1 parent ed968ff commit 81d290b

3 files changed

Lines changed: 2 additions & 127 deletions

File tree

api/appsettings.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ type AppSettings struct {
2323
Allowlist []string `json:"allowlist,omitempty"`
2424
Autoscale map[string]*Autoscale `json:"autoscale,omitempty"`
2525
Label Labels `json:"label,omitempty"`
26-
Canaries []string `json:"canaries,omitempty"`
2726
}
2827

2928
// NewRoutable returns a default value for the AppSettings.Routable field.

appsettings/appsettings.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -58,39 +58,3 @@ func Set(c *drycc.Client, app string, appSettings api.AppSettings) (api.AppSetti
5858

5959
return newAppSettings, reqErr
6060
}
61-
62-
// CanaryDelete remove an app's canary settings.
63-
func CanaryRemove(c *drycc.Client, app string, appSettings api.AppSettings) error {
64-
body, err := json.Marshal(appSettings)
65-
66-
if err != nil {
67-
return err
68-
}
69-
70-
u := fmt.Sprintf("/v2/apps/%s/settings/", app)
71-
res, err := c.Request("DELETE", u, body)
72-
if err == nil {
73-
res.Body.Close()
74-
}
75-
return err
76-
}
77-
78-
// CanaryRelease release an app's canary settings.
79-
func CanaryRelease(c *drycc.Client, app string) error {
80-
u := fmt.Sprintf("/v2/apps/%s/canary/release/", app)
81-
res, err := c.Request("POST", u, nil)
82-
if err == nil {
83-
res.Body.Close()
84-
}
85-
return nil
86-
}
87-
88-
// CanaryRollback rollback an app's canary settings.
89-
func CanaryRollback(c *drycc.Client, app string) error {
90-
u := fmt.Sprintf("/v2/apps/%s/canary/rollback/", app)
91-
res, err := c.Request("POST", u, nil)
92-
if err == nil {
93-
res.Body.Close()
94-
}
95-
return nil
96-
}

appsettings/appsettings_test.go

Lines changed: 2 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const appSettingsFixture string = `
1919
"routable": true,
2020
"allowlist": ["1.2.3.4", "0.0.0.0/0"],
2121
"autoscale": {"cmd": {"min": 3, "max": 8, "cpu_percent": 40}},
22-
"canaries": ["cmd"],
2322
"label": {"git_repo": "https://github.com/drycc/controller-sdk-go", "team" : "drycc"},
2423
"created": "2014-01-01T00:00:00UTC",
2524
"updated": "2014-01-01T00:00:00UTC",
@@ -34,16 +33,14 @@ const appSettingsUnsetFixture string = `
3433
"routable": true,
3534
"allowlist": ["1.2.3.4", "0.0.0.0/0"],
3635
"autoscale": {"cmd": {"min": 3, "max": 8, "cpu_percent": 40}},
37-
"canaries": ["cmd"],
3836
"label": {"git_repo": "https://github.com/drycc/controller-sdk-go", "team" : "drycc"},
3937
"created": "2014-01-01T00:00:00UTC",
4038
"updated": "2014-01-01T00:00:00UTC",
4139
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
4240
}
4341
`
44-
const appSettingsCanaryDeleteExpected string = `{"canaries":["cmd"]}`
45-
const appSettingsSetExpected string = `{"routable":true,"allowlist":["1.2.3.4","0.0.0.0/0"],"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}},"label":{"git_repo":"https://github.com/drycc/controller-sdk-go","team":"drycc"},"canaries":["cmd"]}`
46-
const appSettingsUnsetExpected string = `{"routable":true,"allowlist":["1.2.3.4","0.0.0.0/0"],"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}},"label":{"git_repo":"https://github.com/drycc/controller-sdk-go","team":"drycc"},"canaries":["cmd"]}`
42+
const appSettingsSetExpected string = `{"routable":true,"allowlist":["1.2.3.4","0.0.0.0/0"],"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}},"label":{"git_repo":"https://github.com/drycc/controller-sdk-go","team":"drycc"}}`
43+
const appSettingsUnsetExpected string = `{"routable":true,"allowlist":["1.2.3.4","0.0.0.0/0"],"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}},"label":{"git_repo":"https://github.com/drycc/controller-sdk-go","team":"drycc"}}`
4744

4845
type fakeHTTPServer struct{}
4946

@@ -97,25 +94,6 @@ func (f *fakeHTTPServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
9794
return
9895
}
9996

100-
if req.URL.Path == "/v2/apps/unset-test/settings/" && req.Method == "DELETE" {
101-
body, err := io.ReadAll(req.Body)
102-
103-
if err != nil {
104-
fmt.Println(err)
105-
res.WriteHeader(http.StatusInternalServerError)
106-
res.Write(nil)
107-
}
108-
if string(body) != appSettingsCanaryDeleteExpected {
109-
fmt.Printf("Expected '%s', Got '%s'\n", appSettingsCanaryDeleteExpected, body)
110-
res.WriteHeader(http.StatusInternalServerError)
111-
res.Write(nil)
112-
return
113-
}
114-
res.WriteHeader(http.StatusNoContent)
115-
res.Write(nil)
116-
return
117-
}
118-
11997
fmt.Printf("Unrecognized URL %s\n", req.URL)
12098
res.WriteHeader(http.StatusNotFound)
12199
res.Write(nil)
@@ -145,7 +123,6 @@ func TestAppSettingsSet(t *testing.T) {
145123
CPUPercent: 40,
146124
},
147125
},
148-
Canaries: []string{"cmd"},
149126
Label: map[string]interface{}{
150127
"git_repo": "https://github.com/drycc/controller-sdk-go",
151128
"team": "drycc",
@@ -165,7 +142,6 @@ func TestAppSettingsSet(t *testing.T) {
165142
CPUPercent: 40,
166143
},
167144
},
168-
Canaries: []string{"cmd"},
169145
Label: map[string]interface{}{
170146
"git_repo": "https://github.com/drycc/controller-sdk-go",
171147
"team": "drycc",
@@ -207,7 +183,6 @@ func TestAppSettingsUnset(t *testing.T) {
207183
CPUPercent: 40,
208184
},
209185
},
210-
Canaries: []string{"cmd"},
211186
Label: map[string]interface{}{
212187
"git_repo": "https://github.com/drycc/controller-sdk-go",
213188
"team": "drycc",
@@ -227,7 +202,6 @@ func TestAppSettingsUnset(t *testing.T) {
227202
CPUPercent: 40,
228203
},
229204
},
230-
Canaries: []string{"cmd"},
231205
Label: map[string]interface{}{
232206
"git_repo": "https://github.com/drycc/controller-sdk-go",
233207
"team": "drycc",
@@ -269,7 +243,6 @@ func TestAppSettingsList(t *testing.T) {
269243
CPUPercent: 40,
270244
},
271245
},
272-
Canaries: []string{"cmd"},
273246
Label: map[string]interface{}{
274247
"git_repo": "https://github.com/drycc/controller-sdk-go",
275248
"team": "drycc",
@@ -289,64 +262,3 @@ func TestAppSettingsList(t *testing.T) {
289262
t.Errorf("Expected %v, Got %v", expected, actual)
290263
}
291264
}
292-
293-
func TestAppSettingsCanaryDelete(t *testing.T) {
294-
t.Parallel()
295-
296-
handler := fakeHTTPServer{}
297-
server := httptest.NewServer(&handler)
298-
defer server.Close()
299-
300-
drycc, err := drycc.New(false, server.URL, "abc")
301-
if err != nil {
302-
t.Fatal(err)
303-
}
304-
305-
appSettingsVars := api.AppSettings{
306-
Canaries: []string{"cmd"},
307-
}
308-
309-
err = CanaryRemove(drycc, "unset-test", appSettingsVars)
310-
311-
if err != nil {
312-
t.Error(err)
313-
}
314-
}
315-
316-
func TestAppSettingsCanaryRelease(t *testing.T) {
317-
t.Parallel()
318-
319-
handler := fakeHTTPServer{}
320-
server := httptest.NewServer(&handler)
321-
defer server.Close()
322-
323-
drycc, err := drycc.New(false, server.URL, "abc")
324-
if err != nil {
325-
t.Fatal(err)
326-
}
327-
328-
err = CanaryRelease(drycc, "unset-test")
329-
330-
if err != nil {
331-
t.Error(err)
332-
}
333-
}
334-
335-
func TestAppSettingsCanaryRollback(t *testing.T) {
336-
t.Parallel()
337-
338-
handler := fakeHTTPServer{}
339-
server := httptest.NewServer(&handler)
340-
defer server.Close()
341-
342-
drycc, err := drycc.New(false, server.URL, "abc")
343-
if err != nil {
344-
t.Fatal(err)
345-
}
346-
347-
err = CanaryRollback(drycc, "unset-test")
348-
349-
if err != nil {
350-
t.Error(err)
351-
}
352-
}

0 commit comments

Comments
 (0)