Fix detection of invalid context files when importing
Showing 1 of 2 files from the diff.
cli/context/store/store.go
changed.
Other files ignored by Codecov
cli/context/store/store_test.go
has changed.
@@ -300,7 +300,7 @@
Loading
300 | 300 | tlsData := ContextTLSData{ |
|
301 | 301 | Endpoints: map[string]EndpointTLSData{}, |
|
302 | 302 | } |
|
303 | - | ||
303 | + | var importedMetaFile bool |
|
304 | 304 | for { |
|
305 | 305 | hdr, err := tr.Next() |
|
306 | 306 | if err == io.EOF { |
@@ -325,6 +325,7 @@
Loading
325 | 325 | if err := s.CreateOrUpdate(meta); err != nil { |
|
326 | 326 | return err |
|
327 | 327 | } |
|
328 | + | importedMetaFile = true |
|
328 | 329 | } else if strings.HasPrefix(hdr.Name, "tls/") { |
|
329 | 330 | data, err := ioutil.ReadAll(tr) |
|
330 | 331 | if err != nil { |
@@ -335,7 +336,9 @@
Loading
335 | 336 | } |
|
336 | 337 | } |
|
337 | 338 | } |
|
338 | - | ||
339 | + | if !importedMetaFile { |
|
340 | + | return errdefs.InvalidParameter(errors.New("invalid context: no metadata found")) |
|
341 | + | } |
|
339 | 342 | return s.ResetTLSMaterial(name, &tlsData) |
|
340 | 343 | } |
|
341 | 344 |
@@ -352,6 +355,7 @@
Loading
352 | 355 | Endpoints: map[string]EndpointTLSData{}, |
|
353 | 356 | } |
|
354 | 357 | ||
358 | + | var importedMetaFile bool |
|
355 | 359 | for _, zf := range zr.File { |
|
356 | 360 | fi := zf.FileInfo() |
|
357 | 361 | if fi.IsDir() { |
@@ -376,6 +380,7 @@
Loading
376 | 380 | if err := s.CreateOrUpdate(meta); err != nil { |
|
377 | 381 | return err |
|
378 | 382 | } |
|
383 | + | importedMetaFile = true |
|
379 | 384 | } else if strings.HasPrefix(zf.Name, "tls/") { |
|
380 | 385 | f, err := zf.Open() |
|
381 | 386 | if err != nil { |
@@ -392,7 +397,9 @@
Loading
392 | 397 | } |
|
393 | 398 | } |
|
394 | 399 | } |
|
395 | - | ||
400 | + | if !importedMetaFile { |
|
401 | + | return errdefs.InvalidParameter(errors.New("invalid context: no metadata found")) |
|
402 | + | } |
|
396 | 403 | return s.ResetTLSMaterial(name, &tlsData) |
|
397 | 404 | } |
|
398 | 405 |
Files | Coverage |
---|---|
cli | 57.63% |
cli-plugins/manager | 49.72% |
internal | 48.02% |
opts | 52.53% |
cmd/docker/docker.go | 27.92% |
kubernetes/check.go | 77.27% |
service/logs/parse_logs.go | 73.33% |
templates/templates.go | 58.33% |
Project Totals (310 files) | 56.73% |
25538
1 |
comment: |
2 |
layout: header, changes, diff, sunburst |
3 |
coverage: |
4 |
status: |
5 |
patch: |
6 |
default: |
7 |
target: 50% |
8 |
only_pulls: true |
9 |
# project will give us the diff in the total code coverage between a commit
|
10 |
# and its parent
|
11 |
project: |
12 |
default: |
13 |
target: auto |
14 |
threshold: "15%" |
15 |
changes: false |
16 |
ignore: |
17 |
- "**/internal/test" |
18 |
- "vendor/*" |
19 |
- "cli/compose/schema/bindata.go" |
20 |
- "cli/command/stack/kubernetes/api/openapi" |
21 |
- "cli/command/stack/kubernetes/api/client" |
22 |
- ".*generated.*" |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.