Browse code

api/server: explicitly ignore unhandled errors (errcheck)

```
api/server/router/build/build_routes.go:309:41: Error return value of `(*encoding/json.Decoder).Decode` is not checked (errcheck)
api/server/router/build/build_routes.go:431:11: Error return value of `io.Copy` is not checked (errcheck)
api/server/router/container/container_routes.go:582:13: Error return value of `conn.Write` is not checked (errcheck)
api/server/router/grpc/grpc_routes.go:38:12: Error return value of `conn.Write` is not checked (errcheck)
api/server/router/grpc/grpc_routes.go:39:12: Error return value of `resp.Write` is not checked (errcheck)
api/server/router/image/image_routes.go:94:15: Error return value of `output.Write` is not checked (errcheck)
api/server/router/image/image_routes.go:139:15: Error return value of `output.Write` is not checked (errcheck)
api/server/router/image/image_routes.go:164:15: Error return value of `output.Write` is not checked (errcheck)
api/server/router/image/image_routes.go:180:15: Error return value of `output.Write` is not checked (errcheck)
api/server/router/plugin/plugin_routes.go:126:15: Error return value of `output.Write` is not checked (errcheck)
api/server/router/plugin/plugin_routes.go:165:15: Error return value of `output.Write` is not checked (errcheck)
api/server/router/plugin/plugin_routes.go:273:15: Error return value of `output.Write` is not checked (errcheck)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2019/08/29 00:38:51
Showing 3 changed files
... ...
@@ -176,7 +176,7 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *
176 176
 	if err := httputils.ParseForm(r); err != nil {
177 177
 		return err
178 178
 	}
179
-	filters, err := filters.FromJSON(r.Form.Get("filters"))
179
+	fltrs, err := filters.FromJSON(r.Form.Get("filters"))
180 180
 	if err != nil {
181 181
 		return errors.Wrap(err, "could not parse filters")
182 182
 	}
... ...
@@ -191,7 +191,7 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *
191 191
 
192 192
 	opts := types.BuildCachePruneOptions{
193 193
 		All:         httputils.BoolValue(r, "all"),
194
-		Filters:     filters,
194
+		Filters:     fltrs,
195 195
 		KeepStorage: int64(ks),
196 196
 	}
197 197
 
... ...
@@ -234,12 +234,12 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *
234 234
 	}
235 235
 
236 236
 	output := ioutils.NewWriteFlusher(ww)
237
-	defer output.Close()
237
+	defer func() { _ = output.Close() }()
238 238
 
239 239
 	errf := func(err error) error {
240 240
 
241 241
 		if httputils.BoolValue(r, "q") && notVerboseBuffer.Len() > 0 {
242
-			output.Write(notVerboseBuffer.Bytes())
242
+			_, _ = output.Write(notVerboseBuffer.Bytes())
243 243
 		}
244 244
 
245 245
 		// Do not write the error in the http output if it's still empty.
... ...
@@ -290,7 +290,7 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *
290 290
 	// Everything worked so if -q was provided the output from the daemon
291 291
 	// should be just the image ID and we'll print that to stdout.
292 292
 	if buildOptions.SuppressOutput {
293
-		fmt.Fprintln(streamformatter.NewStdoutWriter(output), imgID)
293
+		_, _ = fmt.Fprintln(streamformatter.NewStdoutWriter(output), imgID)
294 294
 	}
295 295
 	return nil
296 296
 }
... ...
@@ -306,7 +306,7 @@ func getAuthConfigs(header http.Header) map[string]types.AuthConfig {
306 306
 	authConfigsJSON := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authConfigsEncoded))
307 307
 	// Pulling an image does not error when no auth is provided so to remain
308 308
 	// consistent with the existing api decode errors are ignored
309
-	json.NewDecoder(authConfigsJSON).Decode(&authConfigs)
309
+	_ = json.NewDecoder(authConfigsJSON).Decode(&authConfigs)
310 310
 	return authConfigs
311 311
 }
312 312
 
... ...
@@ -428,7 +428,7 @@ func (w *wcf) notify() {
428 428
 	w.mu.Lock()
429 429
 	if !w.ready {
430 430
 		if w.buf.Len() > 0 {
431
-			io.Copy(w.Writer, w.buf)
431
+			_, _ = io.Copy(w.Writer, w.buf)
432 432
 		}
433 433
 		if w.flushed {
434 434
 			w.flusher.Flush()
... ...
@@ -91,7 +91,7 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite
91 91
 		if !output.Flushed() {
92 92
 			return err
93 93
 		}
94
-		output.Write(streamformatter.FormatError(err))
94
+		_, _ = output.Write(streamformatter.FormatError(err))
95 95
 	}
96 96
 
97 97
 	return nil
... ...
@@ -136,7 +136,7 @@ func (s *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter,
136 136
 		if !output.Flushed() {
137 137
 			return err
138 138
 		}
139
-		output.Write(streamformatter.FormatError(err))
139
+		_, _ = output.Write(streamformatter.FormatError(err))
140 140
 	}
141 141
 	return nil
142 142
 }
... ...
@@ -161,7 +161,7 @@ func (s *imageRouter) getImagesGet(ctx context.Context, w http.ResponseWriter, r
161 161
 		if !output.Flushed() {
162 162
 			return err
163 163
 		}
164
-		output.Write(streamformatter.FormatError(err))
164
+		_, _ = output.Write(streamformatter.FormatError(err))
165 165
 	}
166 166
 	return nil
167 167
 }
... ...
@@ -177,7 +177,7 @@ func (s *imageRouter) postImagesLoad(ctx context.Context, w http.ResponseWriter,
177 177
 	output := ioutils.NewWriteFlusher(w)
178 178
 	defer output.Close()
179 179
 	if err := s.backend.LoadImage(r.Body, output, quiet); err != nil {
180
-		output.Write(streamformatter.FormatError(err))
180
+		_, _ = output.Write(streamformatter.FormatError(err))
181 181
 	}
182 182
 	return nil
183 183
 }
... ...
@@ -123,7 +123,7 @@ func (pr *pluginRouter) upgradePlugin(ctx context.Context, w http.ResponseWriter
123 123
 		if !output.Flushed() {
124 124
 			return err
125 125
 		}
126
-		output.Write(streamformatter.FormatError(err))
126
+		_, _ = output.Write(streamformatter.FormatError(err))
127 127
 	}
128 128
 
129 129
 	return nil
... ...
@@ -162,7 +162,7 @@ func (pr *pluginRouter) pullPlugin(ctx context.Context, w http.ResponseWriter, r
162 162
 		if !output.Flushed() {
163 163
 			return err
164 164
 		}
165
-		output.Write(streamformatter.FormatError(err))
165
+		_, _ = output.Write(streamformatter.FormatError(err))
166 166
 	}
167 167
 
168 168
 	return nil
... ...
@@ -270,7 +270,7 @@ func (pr *pluginRouter) pushPlugin(ctx context.Context, w http.ResponseWriter, r
270 270
 		if !output.Flushed() {
271 271
 			return err
272 272
 		}
273
-		output.Write(streamformatter.FormatError(err))
273
+		_, _ = output.Write(streamformatter.FormatError(err))
274 274
 	}
275 275
 	return nil
276 276
 }