vendor: github.com/docker/docker v20.10.3-0.20220309172631-83b51522df43
Changed `matcher.Matches(file)` to `matcher.MatchesOrParentMatches(file)`:
cli/command/image/build/context.go:95:9: SA1019: matcher.Matches is deprecated: This implementation is buggy (it only checks a single parent dir against the pattern) and will be removed soon. Use either MatchesOrParentMatches or MatchesUsingParentResults instead. (staticcheck)
return matcher.Matches(file)
^
And updated a test to match the JSON omitting empty RootFS.Type fields (in
practice, this field should never be empty in real situations, and always
be "layer"). Changed the test to use subtests to easier find which case
is failing.
full diff: 343665850e...83b51522df
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -92,7 +92,7 @@ func filepathMatches(matcher *fileutils.PatternMatcher, file string) (bool, erro
|
||||
// Don't let them exclude everything, kind of silly.
|
||||
return false, nil
|
||||
}
|
||||
return matcher.Matches(file)
|
||||
return matcher.MatchesOrParentMatches(file)
|
||||
}
|
||||
|
||||
// DetectArchiveReader detects whether the input stream is an archive or a
|
||||
|
||||
@ -75,14 +75,17 @@ func TestNewInspectCommandSuccess(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
imageInspectInvocationCount = 0
|
||||
cli := test.NewFakeCli(&fakeClient{imageInspectFunc: tc.imageInspectFunc})
|
||||
cmd := newInspectCommand(cli)
|
||||
cmd.SetOut(io.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
err := cmd.Execute()
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("inspect-command-success.%s.golden", tc.name))
|
||||
assert.Check(t, is.Equal(imageInspectInvocationCount, tc.imageCount))
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
imageInspectInvocationCount = 0
|
||||
cli := test.NewFakeCli(&fakeClient{imageInspectFunc: tc.imageInspectFunc})
|
||||
cmd := newInspectCommand(cli)
|
||||
cmd.SetOut(io.Discard)
|
||||
cmd.SetArgs(tc.args)
|
||||
err := cmd.Execute()
|
||||
assert.NilError(t, err)
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("inspect-command-success.%s.golden", tc.name))
|
||||
assert.Check(t, is.Equal(imageInspectInvocationCount, tc.imageCount))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,9 +19,7 @@
|
||||
"Data": null,
|
||||
"Name": ""
|
||||
},
|
||||
"RootFS": {
|
||||
"Type": ""
|
||||
},
|
||||
"RootFS": {},
|
||||
"Metadata": {
|
||||
"LastTagTime": "0001-01-01T00:00:00Z"
|
||||
}
|
||||
@ -46,9 +44,7 @@
|
||||
"Data": null,
|
||||
"Name": ""
|
||||
},
|
||||
"RootFS": {
|
||||
"Type": ""
|
||||
},
|
||||
"RootFS": {},
|
||||
"Metadata": {
|
||||
"LastTagTime": "0001-01-01T00:00:00Z"
|
||||
}
|
||||
|
||||
@ -19,9 +19,7 @@
|
||||
"Data": null,
|
||||
"Name": ""
|
||||
},
|
||||
"RootFS": {
|
||||
"Type": ""
|
||||
},
|
||||
"RootFS": {},
|
||||
"Metadata": {
|
||||
"LastTagTime": "0001-01-01T00:00:00Z"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user