Skip to content

Commit 9979a1a

Browse files
authored
Merge pull request #2951 from crosbymichael/lint-relase11
[release/1.1] fix: linter issue
2 parents 6b15143 + ff8a80e commit 9979a1a

21 files changed

Lines changed: 31 additions & 46 deletions

File tree

.gometalinter.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
"Enable": [
1212
"structcheck",
13-
"unused",
1413
"varcheck",
1514
"staticcheck",
1615
"unconvert",

archive/tar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func applyNaive(ctx context.Context, root string, tr *tar.Reader, options ApplyO
284284
linkBasename := filepath.Base(hdr.Linkname)
285285
srcHdr = aufsHardlinks[linkBasename]
286286
if srcHdr == nil {
287-
return 0, fmt.Errorf("Invalid aufs hardlink")
287+
return 0, fmt.Errorf("invalid aufs hardlink")
288288
}
289289
p, err := fs.RootPath(aufsTempdir, linkBasename)
290290
if err != nil {

archive/tar_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func TestBreakouts(t *testing.T) {
239239
if err != nil {
240240
return err
241241
}
242-
if bytes.Compare(b, content) != 0 {
242+
if !bytes.Equal(b, content) {
243243
return errors.Errorf("content differs: expected %v, got %v", content, b)
244244
}
245245
return nil
@@ -1073,7 +1073,7 @@ func fileEntry(name string, expected []byte, mode int) tarEntryValidator {
10731073
if hdr.Mode != int64(mode) {
10741074
return errors.Errorf("wrong mode %o, expected %o", hdr.Mode, mode)
10751075
}
1076-
if bytes.Compare(b, expected) != 0 {
1076+
if !bytes.Equal(b, expected) {
10771077
return errors.Errorf("different file content")
10781078
}
10791079
return nil

archive/tar_windows.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func tarName(p string) (string, error) {
7474
// in file names, it is mostly safe to replace however we must
7575
// check just in case
7676
if strings.Contains(p, "/") {
77-
return "", fmt.Errorf("Windows path contains forward slash: %s", p)
77+
return "", fmt.Errorf("windows path contains forward slash: %s", p)
7878
}
7979

8080
return strings.Replace(p, string(os.PathSeparator), "/", -1), nil
@@ -130,11 +130,7 @@ func skipFile(hdr *tar.Header) bool {
130130
// specific or Linux-specific, this warning should be changed to an error
131131
// to cater for the situation where someone does manage to upload a Linux
132132
// image but have it tagged as Windows inadvertently.
133-
if strings.Contains(hdr.Name, ":") {
134-
return true
135-
}
136-
137-
return false
133+
return strings.Contains(hdr.Name, ":")
138134
}
139135

140136
// handleTarTypeBlockCharFifo is an OS-specific helper function used by

container_linux_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ func TestShimSigkilled(t *testing.T) {
838838
}
839839

840840
pid := task.Pid()
841-
if pid <= 0 {
841+
if pid < 1 {
842842
t.Fatalf("invalid task pid %d", pid)
843843
}
844844

@@ -901,7 +901,7 @@ func TestDaemonRestartWithRunningShim(t *testing.T) {
901901
}
902902

903903
pid := task.Pid()
904-
if pid <= 0 {
904+
if pid < 1 {
905905
t.Fatalf("invalid task pid %d", pid)
906906
}
907907

@@ -1130,7 +1130,7 @@ func testUserNamespaces(t *testing.T, readonlyRootFS bool) {
11301130
t.Fatal(err)
11311131
}
11321132

1133-
if pid := task.Pid(); pid <= 0 {
1133+
if pid := task.Pid(); pid < 1 {
11341134
t.Errorf("invalid task pid %d", pid)
11351135
}
11361136
if err := task.Start(ctx); err != nil {

container_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestContainerStart(t *testing.T) {
134134
t.Fatal(err)
135135
}
136136

137-
if pid := task.Pid(); pid <= 0 {
137+
if pid := task.Pid(); pid < 1 {
138138
t.Errorf("invalid task pid %d", pid)
139139
}
140140
if err := task.Start(ctx); err != nil {
@@ -433,7 +433,7 @@ func TestContainerPids(t *testing.T) {
433433
}
434434

435435
pid := task.Pid()
436-
if pid <= 0 {
436+
if pid < 1 {
437437
t.Errorf("invalid task pid %d", pid)
438438
}
439439
processes, err := task.Pids(ctx)
@@ -783,7 +783,7 @@ func TestWaitStoppedTask(t *testing.T) {
783783
t.Fatal(err)
784784
}
785785

786-
if pid := task.Pid(); pid <= 0 {
786+
if pid := task.Pid(); pid < 1 {
787787
t.Errorf("invalid task pid %d", pid)
788788
}
789789
if err := task.Start(ctx); err != nil {

content/local/locks.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,5 @@ func unlock(ref string) {
4747
locksMu.Lock()
4848
defer locksMu.Unlock()
4949

50-
if _, ok := locks[ref]; ok {
51-
delete(locks, ref)
52-
}
50+
delete(locks, ref)
5351
}

contrib/seccomp/seccomp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ func WithProfile(profile string) oci.SpecOpts {
3737
s.Linux.Seccomp = &specs.LinuxSeccomp{}
3838
f, err := ioutil.ReadFile(profile)
3939
if err != nil {
40-
return fmt.Errorf("Cannot load seccomp profile %q: %v", profile, err)
40+
return fmt.Errorf("cannot load seccomp profile %q: %v", profile, err)
4141
}
4242
if err := json.Unmarshal(f, s.Linux.Seccomp); err != nil {
43-
return fmt.Errorf("Decoding seccomp profile failed %q: %v", profile, err)
43+
return fmt.Errorf("decoding seccomp profile failed %q: %v", profile, err)
4444
}
4545
return nil
4646
}

diff/apply/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (s *fsApplier) Apply(ctx context.Context, desc ocispec.Descriptor, mounts [
5858
defer func() {
5959
if err == nil {
6060
log.G(ctx).WithFields(logrus.Fields{
61-
"d": time.Now().Sub(t1),
61+
"d": time.Since(t1),
6262
"dgst": desc.Digest,
6363
"size": desc.Size,
6464
"media": desc.MediaType,

diff/windows/windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (s windowsDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts
9292
defer func() {
9393
if err == nil {
9494
log.G(ctx).WithFields(logrus.Fields{
95-
"d": time.Now().Sub(t1),
95+
"d": time.Since(t1),
9696
"dgst": desc.Digest,
9797
"size": desc.Size,
9898
"media": desc.MediaType,

0 commit comments

Comments
 (0)