@@ -2,7 +2,6 @@ package apps
22
33import (
44 "encoding/json"
5- "errors"
65 "fmt"
76 "strconv"
87 "strings"
@@ -13,16 +12,12 @@ import (
1312
1413// List lists apps on a Deis controller.
1514func List (c * client.Client ) ([]api.App , error ) {
16- body , status , err := c .BasicRequest ("GET" , "/v1/apps/" , nil )
15+ body , err := c .BasicRequest ("GET" , "/v1/apps/" , nil )
1716
1817 if err != nil {
1918 return []api.App {}, err
2019 }
2120
22- if status != 200 {
23- return []api.App {}, errors .New (body )
24- }
25-
2621 apps := api.Apps {}
2722 if err = json .Unmarshal ([]byte (body ), & apps ); err != nil {
2823 return []api.App {}, err
@@ -45,16 +40,12 @@ func New(c *client.Client, id string) (api.App, error) {
4540 }
4641 }
4742
48- resBody , status , err := c .BasicRequest ("POST" , "/v1/apps/" , body )
43+ resBody , err := c .BasicRequest ("POST" , "/v1/apps/" , body )
4944
5045 if err != nil {
5146 return api.App {}, err
5247 }
5348
54- if status != 201 {
55- return api.App {}, errors .New (resBody )
56- }
57-
5849 app := api.App {}
5950 if err = json .Unmarshal ([]byte (resBody ), & app ); err != nil {
6051 return api.App {}, err
@@ -67,16 +58,12 @@ func New(c *client.Client, id string) (api.App, error) {
6758func Get (c * client.Client , appID string ) (api.App , error ) {
6859 u := fmt .Sprintf ("/v1/apps/%s/" , appID )
6960
70- body , status , err := c .BasicRequest ("GET" , u , nil )
61+ body , err := c .BasicRequest ("GET" , u , nil )
7162
7263 if err != nil {
7364 return api.App {}, err
7465 }
7566
76- if status != 200 {
77- return api.App {}, errors .New (body )
78- }
79-
8067 app := api.App {}
8168
8269 if err = json .Unmarshal ([]byte (body ), & app ); err != nil {
@@ -94,16 +81,12 @@ func Logs(c *client.Client, appID string, lines int) (string, error) {
9481 u += "?log_lines=" + strconv .Itoa (lines )
9582 }
9683
97- body , status , err := c .BasicRequest ("GET" , u , nil )
84+ body , err := c .BasicRequest ("GET" , u , nil )
9885
9986 if err != nil {
10087 return "" , err
10188 }
10289
103- if status != 200 {
104- return body , errors .New (body )
105- }
106-
10790 return strings .Trim (body , `"` ), nil
10891}
10992
@@ -118,16 +101,12 @@ func Run(c *client.Client, appID string, command string) (api.AppRunResponse, er
118101
119102 u := fmt .Sprintf ("/v1/apps/%s/run" , appID )
120103
121- resBody , status , err := c .BasicRequest ("POST" , u , body )
104+ resBody , err := c .BasicRequest ("POST" , u , body )
122105
123106 if err != nil {
124107 return api.AppRunResponse {}, err
125108 }
126109
127- if status != 200 {
128- return api.AppRunResponse {}, errors .New (resBody )
129- }
130-
131110 out := make ([]interface {}, 2 )
132111
133112 if err = json .Unmarshal ([]byte (resBody ), & out ); err != nil {
@@ -141,15 +120,6 @@ func Run(c *client.Client, appID string, command string) (api.AppRunResponse, er
141120func Delete (c * client.Client , appID string ) error {
142121 u := fmt .Sprintf ("/v1/apps/%s/" , appID )
143122
144- body , status , err := c .BasicRequest ("DELETE" , u , nil )
145-
146- if err != nil {
147- return err
148- }
149-
150- if status != 204 {
151- return errors .New (body )
152- }
153-
154- return nil
123+ _ , err := c .BasicRequest ("DELETE" , u , nil )
124+ return err
155125}
0 commit comments