From 8b03df2dae14c6ce4159ac9b40022a19d0d9e827 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Wed, 7 Oct 2020 15:08:20 -0700 Subject: [PATCH 1/3] Enable linter on windows Signed-off-by: Maksym Pavlenko --- .gitattributes | 1 + .github/workflows/ci.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..a0717e4b3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.go text eol=lf \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4916ffb61..f5c4c6ddd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: - os: [ubuntu-18.04, macos-10.15] # TODO: pass linters on 'windows-2019' + os: [ubuntu-18.04, macos-10.15, windows-2019] steps: - name: Install Go From 8b046647e63ad74c58ffab693ed752c834fcf795 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Wed, 7 Oct 2020 15:17:56 -0700 Subject: [PATCH 2/3] Use golangci-lint Github Action Signed-off-by: Maksym Pavlenko --- .github/workflows/ci.yml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5c4c6ddd..a37bf4b1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,13 +20,13 @@ jobs: strategy: matrix: + go-version: [1.15.2] os: [ubuntu-18.04, macos-10.15, windows-2019] steps: - - name: Install Go - uses: actions/setup-go@v1 + - uses: actions/checkout@v2 with: - go-version: '1.15.2' + path: src/github.com/containerd/containerd - name: Set env shell: bash @@ -34,22 +34,10 @@ jobs: echo "::set-env name=GOPATH::${{ github.workspace }}" echo "::add-path::${{ github.workspace }}/bin" - - name: Checkout - uses: actions/checkout@v2 + - uses: golangci/golangci-lint-action@v2 with: - path: src/github.com/containerd/containerd - - - name: Install dev tools - env: - GO111MODULE: off - shell: bash - run: script/setup/install-dev-tools - working-directory: src/github.com/containerd/containerd - - - name: Make check - shell: bash - run: make check - working-directory: src/github.com/containerd/containerd + version: v1.29 + working-directory: src/github.com/containerd/containerd # # Project checks From c59d1cd5b069ed6a978675e6d835f57464c364a8 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Wed, 7 Oct 2020 15:42:01 -0700 Subject: [PATCH 3/3] Fix linter issues Signed-off-by: Maksym Pavlenko --- remotes/docker/auth/fetch.go | 12 ++++-------- runtime/v2/example/example.go | 4 +--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/remotes/docker/auth/fetch.go b/remotes/docker/auth/fetch.go index 7a05e3933..f65c6be38 100644 --- a/remotes/docker/auth/fetch.go +++ b/remotes/docker/auth/fetch.go @@ -106,10 +106,8 @@ func FetchTokenWithOAuth(ctx context.Context, client *http.Client, headers http. return nil, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") - if headers != nil { - for k, v := range headers { - req.Header[k] = append(req.Header[k], v...) - } + for k, v := range headers { + req.Header[k] = append(req.Header[k], v...) } resp, err := ctxhttp.Do(ctx, client, req) @@ -152,10 +150,8 @@ func FetchToken(ctx context.Context, client *http.Client, headers http.Header, t return nil, err } - if headers != nil { - for k, v := range headers { - req.Header[k] = append(req.Header[k], v...) - } + for k, v := range headers { + req.Header[k] = append(req.Header[k], v...) } reqParams := req.URL.Query() diff --git a/runtime/v2/example/example.go b/runtime/v2/example/example.go index de126e6d8..5708e6f5b 100644 --- a/runtime/v2/example/example.go +++ b/runtime/v2/example/example.go @@ -31,8 +31,6 @@ import ( var ( // check to make sure the *service implements the GRPC API _ = (taskAPI.TaskService)(&service{}) - // common response type - empty = &ptypes.Empty{} ) // New returns a new shim service @@ -121,7 +119,7 @@ func (s *service) Connect(ctx context.Context, r *taskAPI.ConnectRequest) (*task // Shutdown is called after the underlying resources of the shim are cleaned up and the service can be stopped func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (*ptypes.Empty, error) { os.Exit(0) - return empty, nil + return &ptypes.Empty{}, nil } // Stats returns container level system stats for a container and its processes