@@ -52,19 +52,19 @@ func List(c *deis.Client, results int) ([]api.App, int, error) {
5252func New (c * deis.Client , appID string ) (api.App , error ) {
5353 body := []byte {}
5454
55- var err error
5655 if appID != "" {
5756 req := api.AppCreateRequest {ID : appID }
58- body , err = json .Marshal (req )
57+ b , err : = json .Marshal (req )
5958
6059 if err != nil {
6160 return api.App {}, err
6261 }
62+ body = b
6363 }
6464
65- res , err := c .Request ("POST" , "/v2/apps/" , body )
66- if err != nil {
67- return api.App {}, err
65+ res , reqErr := c .Request ("POST" , "/v2/apps/" , body )
66+ if reqErr != nil && ! deis . IsErrAPIMismatch ( reqErr ) {
67+ return api.App {}, reqErr
6868 }
6969 // Fix json.Decoder bug in <go1.7
7070 defer func () {
@@ -73,23 +73,23 @@ func New(c *deis.Client, appID string) (api.App, error) {
7373 }()
7474
7575 app := api.App {}
76- if err = json .NewDecoder (res .Body ).Decode (& app ); err != nil {
76+ if err : = json .NewDecoder (res .Body ).Decode (& app ); err != nil {
7777 return api.App {}, err
7878 }
7979
8080 // Add in app URL based on controller hostname, port included
8181 app .URL = fmt .Sprintf ("%s.%s" , app .ID , strings .TrimPrefix (c .ControllerURL .Host , workflowURLPrefix ))
8282
83- return app , nil
83+ return app , reqErr
8484}
8585
8686// Get app details from a controller.
8787func Get (c * deis.Client , appID string ) (api.App , error ) {
8888 u := fmt .Sprintf ("/v2/apps/%s/" , appID )
8989
90- res , err := c .Request ("GET" , u , nil )
91- if err != nil {
92- return api.App {}, err
90+ res , reqErr := c .Request ("GET" , u , nil )
91+ if reqErr != nil && ! deis . IsErrAPIMismatch ( reqErr ) {
92+ return api.App {}, reqErr
9393 }
9494 // Fix json.Decoder bug in <go1.7
9595 defer func () {
@@ -99,14 +99,14 @@ func Get(c *deis.Client, appID string) (api.App, error) {
9999
100100 app := api.App {}
101101
102- if err = json .NewDecoder (res .Body ).Decode (& app ); err != nil {
102+ if err : = json .NewDecoder (res .Body ).Decode (& app ); err != nil {
103103 return api.App {}, err
104104 }
105105
106106 // Add in app URL based on controller hostname, port included
107107 app .URL = fmt .Sprintf ("%s.%s" , app .ID , strings .TrimPrefix (c .ControllerURL .Host , workflowURLPrefix ))
108108
109- return app , nil
109+ return app , reqErr
110110}
111111
112112// Logs retrieves logs from an app. The number of log lines fetched can be set by the lines
@@ -118,8 +118,8 @@ func Logs(c *deis.Client, appID string, lines int) (string, error) {
118118 u += "?log_lines=" + strconv .Itoa (lines )
119119 }
120120
121- res , err := c .Request ("GET" , u , nil )
122- if err != nil {
121+ res , reqErr := c .Request ("GET" , u , nil )
122+ if reqErr != nil && ! deis . IsErrAPIMismatch ( reqErr ) {
123123 return "" , ErrNoLogs
124124 }
125125 defer res .Body .Close ()
@@ -130,7 +130,7 @@ func Logs(c *deis.Client, appID string, lines int) (string, error) {
130130 }
131131
132132 // We need to trim a few characters off the front and end of the string
133- return string (body [2 : len (body )- 1 ]), nil
133+ return string (body [2 : len (body )- 1 ]), reqErr
134134}
135135
136136// Run a one-time command in your app. This will start a kubernetes job with the
@@ -145,9 +145,9 @@ func Run(c *deis.Client, appID string, command string) (api.AppRunResponse, erro
145145
146146 u := fmt .Sprintf ("/v2/apps/%s/run" , appID )
147147
148- res , err := c .Request ("POST" , u , body )
149- if err != nil {
150- return api.AppRunResponse {}, err
148+ res , reqErr := c .Request ("POST" , u , body )
149+ if reqErr != nil && ! deis . IsErrAPIMismatch ( reqErr ) {
150+ return api.AppRunResponse {}, reqErr
151151 }
152152
153153 arr := api.AppRunResponse {}
@@ -156,7 +156,7 @@ func Run(c *deis.Client, appID string, command string) (api.AppRunResponse, erro
156156 return api.AppRunResponse {}, err
157157 }
158158
159- return arr , nil
159+ return arr , reqErr
160160}
161161
162162// Delete an app.
0 commit comments