Skip to content

Commit b8c794b

Browse files
committed
fix linting issues
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 8d2ccc1 commit b8c794b

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

cli/command/image/build/internal/git/gitutils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ func supportsShallowClone(remoteURL string) bool {
148148

149149
// Try a HEAD request and fallback to a Get request on error
150150
res, err := http.Head(serviceURL) // #nosec G107
151+
if res != nil && res.Body != nil {
152+
defer res.Body.Close()
153+
}
151154
if err != nil || res.StatusCode != http.StatusOK {
152155
res, err = http.Get(serviceURL) // #nosec G107
153156
if err == nil {

cli/command/image/build/internal/git/gitutils_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,15 @@ func TestValidGitTransport(t *testing.T) {
350350
"github.com/docker/docker",
351351
}
352352

353-
for _, url := range gitUrls {
354-
if !isGitTransport(url) {
355-
t.Fatalf("%q should be detected as valid Git prefix", url)
353+
for _, u := range gitUrls {
354+
if !isGitTransport(u) {
355+
t.Fatalf("%q should be detected as valid Git prefix", u)
356356
}
357357
}
358358

359-
for _, url := range incompleteGitUrls {
360-
if isGitTransport(url) {
361-
t.Fatalf("%q should not be detected as valid Git prefix", url)
359+
for _, u := range incompleteGitUrls {
360+
if isGitTransport(u) {
361+
t.Fatalf("%q should not be detected as valid Git prefix", u)
362362
}
363363
}
364364
}
@@ -371,8 +371,8 @@ func TestGitInvalidRef(t *testing.T) {
371371
"git@g.com:a/b.git#with space",
372372
}
373373

374-
for _, url := range gitUrls {
375-
_, err := Clone(url)
374+
for _, u := range gitUrls {
375+
_, err := Clone(u)
376376
assert.Assert(t, err != nil)
377377
// On Windows, git has different case for the "invalid refspec" error,
378378
// so we can't use ErrorContains.

0 commit comments

Comments
 (0)