Skip to content

Commit

Permalink
Migrate to golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: Tam Mach <sayboras@yahoo.com>
Signed-off-by: wang yan <wangyan@vmware.com>
  • Loading branch information
sayboras authored and wy65701436 committed Mar 23, 2021
1 parent 9142de9 commit f807afb
Show file tree
Hide file tree
Showing 35 changed files with 61 additions and 105 deletions.
20 changes: 20 additions & 0 deletions .golangci.yml
@@ -0,0 +1,20 @@
linters:
enable:
- structcheck
- varcheck
- staticcheck
- unconvert
- gofmt
- goimports
- golint
- ineffassign
- vet
- unused
- misspell
disable:
- errcheck

run:
deadline: 2m
skip-dirs:
- vendor
15 changes: 0 additions & 15 deletions .gometalinter.json

This file was deleted.

51 changes: 0 additions & 51 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -50,7 +50,7 @@ version/version.go:

check: ## run all linters (TODO: enable "unused", "varcheck", "ineffassign", "unconvert", "staticheck", "goimports", "structcheck")
@echo "$(WHALE) $@"
gometalinter --config .gometalinter.json ./...
golangci-lint run

test: ## run tests, except integration test with test.short
@echo "$(WHALE) $@"
Expand Down
2 changes: 1 addition & 1 deletion blobs.go
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/docker/distribution/reference"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/registry-api-descriptor-template/main.go
Expand Up @@ -21,7 +21,7 @@ import (
"text/template"

"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
)

var spaceRegex = regexp.MustCompile(`\n\s*`)
Expand Down
2 changes: 1 addition & 1 deletion manifest/manifestlist/manifestlist.go
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/docker/distribution"
"github.com/docker/distribution/manifest"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion manifest/manifestlist/manifestlist_test.go
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/docker/distribution"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

var expectedManifestListSerialization = []byte(`{
Expand Down
2 changes: 1 addition & 1 deletion manifest/ocischema/builder.go
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/docker/distribution"
"github.com/docker/distribution/manifest"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

// Builder is a type for constructing manifests.
Expand Down
2 changes: 1 addition & 1 deletion manifest/ocischema/builder_test.go
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/docker/distribution"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

type mockBlobService struct {
Expand Down
2 changes: 1 addition & 1 deletion manifest/ocischema/manifest.go
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/docker/distribution"
"github.com/docker/distribution/manifest"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion manifest/ocischema/manifest_test.go
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/docker/distribution"
"github.com/docker/distribution/manifest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

var expectedManifestSerialization = []byte(`{
Expand Down
2 changes: 1 addition & 1 deletion notifications/bridge_test.go
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/docker/distribution"
"github.com/docker/distribution/manifest/schema1"
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
"github.com/docker/distribution/uuid"
"github.com/docker/libtrust"
"github.com/opencontainers/go-digest"
Expand Down
2 changes: 1 addition & 1 deletion reference/reference_test.go
Expand Up @@ -639,7 +639,7 @@ func TestParseNamed(t *testing.T) {
failf("error parsing name: %s", err)
continue
} else if err == nil && testcase.err != nil {
failf("parsing succeded: expected error %v", testcase.err)
failf("parsing succeeded: expected error %v", testcase.err)
continue
} else if err != testcase.err {
failf("unexpected error %v, expected %v", err, testcase.err)
Expand Down
2 changes: 1 addition & 1 deletion registry/client/repository.go
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/docker/distribution"
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
"github.com/docker/distribution/registry/client/transport"
"github.com/docker/distribution/registry/storage/cache"
"github.com/docker/distribution/registry/storage/cache/memory"
Expand Down
4 changes: 2 additions & 2 deletions registry/handlers/api_test.go
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/docker/distribution/manifest/schema2"
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
storagedriver "github.com/docker/distribution/registry/storage/driver"
"github.com/docker/distribution/registry/storage/driver/factory"
_ "github.com/docker/distribution/registry/storage/driver/testdriver"
Expand Down Expand Up @@ -2357,7 +2357,7 @@ func checkBodyHasErrorCodes(t *testing.T, msg string, resp *http.Response, error
// Ensure that counts of expected errors were all non-zero
for code := range expected {
if counts[code] == 0 {
t.Fatalf("expected error code %v not encounterd during %s: %s", code, msg, string(p))
t.Fatalf("expected error code %v not encountered during %s: %s", code, msg, string(p))
}
}

Expand Down
2 changes: 1 addition & 1 deletion registry/handlers/app.go
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/docker/distribution/notifications"
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
"github.com/docker/distribution/registry/auth"
registrymiddleware "github.com/docker/distribution/registry/middleware/registry"
repositorymiddleware "github.com/docker/distribution/registry/middleware/repository"
Expand Down
2 changes: 1 addition & 1 deletion registry/handlers/app_test.go
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/docker/distribution/configuration"
"github.com/docker/distribution/context"
"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
"github.com/docker/distribution/registry/auth"
_ "github.com/docker/distribution/registry/auth/silly"
"github.com/docker/distribution/registry/storage"
Expand Down
2 changes: 1 addition & 1 deletion registry/handlers/blob.go
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/docker/distribution"
"github.com/docker/distribution/context"
"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
"github.com/gorilla/handlers"
"github.com/opencontainers/go-digest"
)
Expand Down
2 changes: 1 addition & 1 deletion registry/handlers/context.go
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/docker/distribution"
dcontext "github.com/docker/distribution/context"
"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
"github.com/docker/distribution/registry/auth"
"github.com/opencontainers/go-digest"
)
Expand Down
4 changes: 2 additions & 2 deletions registry/handlers/manifests.go
Expand Up @@ -14,11 +14,11 @@ import (
"github.com/docker/distribution/manifest/schema2"
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
"github.com/docker/distribution/registry/auth"
"github.com/gorilla/handlers"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

// These constants determine which architecture and OS to choose from a
Expand Down
2 changes: 1 addition & 1 deletion registry/handlers/tags.go
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/docker/distribution"
"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
"github.com/gorilla/handlers"
)

Expand Down
3 changes: 2 additions & 1 deletion registry/registry.go
Expand Up @@ -14,7 +14,8 @@ import (

"rsc.io/letsencrypt"

"github.com/Shopify/logrus-bugsnag"
logrus_bugsnag "github.com/Shopify/logrus-bugsnag"

logstash "github.com/bshuster-repo/logrus-logstash-hook"
"github.com/bugsnag/bugsnag-go"
"github.com/docker/distribution/configuration"
Expand Down
6 changes: 3 additions & 3 deletions registry/storage/blob_test.go
Expand Up @@ -418,7 +418,7 @@ func TestBlobMount(t *testing.T) {

bs := repository.Blobs(ctx)
// Test destination for existence.
statDesc, err = bs.Stat(ctx, desc.Digest)
_, err = bs.Stat(ctx, desc.Digest)
if err == nil {
t.Fatalf("unexpected non-error stating unmounted blob: %v", desc)
}
Expand Down Expand Up @@ -478,12 +478,12 @@ func TestBlobMount(t *testing.T) {
t.Fatalf("Unexpected error deleting blob")
}

d, err := bs.Stat(ctx, desc.Digest)
_, err = bs.Stat(ctx, desc.Digest)
if err != nil {
t.Fatalf("unexpected error stating blob deleted from source repository: %v", err)
}

d, err = sbs.Stat(ctx, desc.Digest)
d, err := sbs.Stat(ctx, desc.Digest)
if err == nil {
t.Fatalf("unexpected non-error stating deleted blob: %v", d)
}
Expand Down
3 changes: 1 addition & 2 deletions registry/storage/cache/cachecheck/suite.go
Expand Up @@ -173,8 +173,7 @@ func checkBlobDescriptorCacheClear(ctx context.Context, t *testing.T, provider c
t.Error(err)
}

desc, err = cache.Stat(ctx, localDigest)
if err == nil {
if _, err = cache.Stat(ctx, localDigest); err == nil {
t.Fatalf("expected error statting deleted blob: %v", err)
}
}
2 changes: 1 addition & 1 deletion registry/storage/driver/filesystem/driver_test.go
Expand Up @@ -36,7 +36,7 @@ func init() {
func TestFromParametersImpl(t *testing.T) {

tests := []struct {
params map[string]interface{} // techincally the yaml can contain anything
params map[string]interface{} // technically the yaml can contain anything
expected DriverParameters
pass bool
}{
Expand Down
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/aws/aws-sdk-go/service/cloudfront/sign"
dcontext "github.com/docker/distribution/context"
storagedriver "github.com/docker/distribution/registry/storage/driver"
"github.com/docker/distribution/registry/storage/driver/middleware"
storagemiddleware "github.com/docker/distribution/registry/storage/driver/middleware"
)

// cloudFrontStorageMiddleware provides a simple implementation of layerHandler that
Expand Down
2 changes: 1 addition & 1 deletion registry/storage/driver/s3-aws/s3.go
Expand Up @@ -366,7 +366,7 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
return New(params)
}

// getParameterAsInt64 converts paramaters[name] to an int64 value (using
// getParameterAsInt64 converts parameters[name] to an int64 value (using
// defaultt if nil), verifies it is no smaller than min, and returns it.
func getParameterAsInt64(parameters map[string]interface{}, name string, defaultt int64, min int64, max int64) (int64, error) {
rv := defaultt
Expand Down
2 changes: 1 addition & 1 deletion registry/storage/manifeststore.go
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/docker/distribution/manifest/schema1"
"github.com/docker/distribution/manifest/schema2"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

// A ManifestHandler gets and puts manifests of a particular type.
Expand Down
2 changes: 1 addition & 1 deletion registry/storage/manifeststore_test.go
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/docker/distribution/testutil"
"github.com/docker/libtrust"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

type manifestStoreTestEnv struct {
Expand Down
2 changes: 1 addition & 1 deletion registry/storage/ocimanifesthandler.go
Expand Up @@ -9,7 +9,7 @@ import (
dcontext "github.com/docker/distribution/context"
"github.com/docker/distribution/manifest/ocischema"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

//ocischemaManifestHandler is a ManifestHandler that covers ocischema manifests.
Expand Down
2 changes: 1 addition & 1 deletion registry/storage/ocimanifesthandler_test.go
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/docker/distribution/manifest"
"github.com/docker/distribution/manifest/ocischema"
"github.com/docker/distribution/registry/storage/driver/inmemory"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

func TestVerifyOCIManifestNonDistributableLayer(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion registry/storage/schema2manifesthandler.go
Expand Up @@ -93,7 +93,7 @@ func (ms *schema2ManifestHandler) verifyManifest(ctx context.Context, mnfst sche
switch descriptor.MediaType {
case schema2.MediaTypeForeignLayer:
// Clients download this layer from an external URL, so do not check for
// its presense.
// its presence.
if len(descriptor.URLs) == 0 {
err = errMissingURL
}
Expand Down

0 comments on commit f807afb

Please sign in to comment.