Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ jobs:
with:
go-version-file: go.mod

- name: Check
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
args: --timeout=10m --issues-exit-code=0

accel_build:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
with:
go-version-file: go.mod

- name: Run Linter
run: |
make install-check-tools
make check

- name: Unit Test
run: |
go test -v -count=1 ./pkg/...
42 changes: 26 additions & 16 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
# https://golangci-lint.run/usage/configuration#config-file

version: "2"
linters:
enable:
- staticcheck
- unconvert
- gofmt
- goimports
- revive
- ineffassign
- govet
- unused
- misspell
- revive
- unconvert
disable:
- errcheck

run:
timeout: 5m
issues:
exclude-dirs:
- misc
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- misc
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- misc
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build:
go build -ldflags '-X main.versionTag=${VERSION_TAG} -X main.versionGitCommit=${GIT_COMMIT} -X main.versionBuildTime=${BUILD_TIME}' -gcflags=all="-N -l" ./cmd/accelctl

install-check-tools:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6

check:
@echo "$@"
Expand Down
8 changes: 4 additions & 4 deletions cmd/accelctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"time"

"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
cli "github.com/urfave/cli/v2"

"github.com/goharbor/acceleration-service/pkg/client"
"github.com/goharbor/acceleration-service/pkg/config"
Expand All @@ -34,9 +34,9 @@ var versionBuildTime string

var ctl *client.Client

func ellipsis(txt string, max int) string {
if len(txt) > max {
return fmt.Sprintf("%s...", txt[0:max])
func ellipsis(txt string, maximum int) string {
if len(txt) > maximum {
return fmt.Sprintf("%s...", txt[0:maximum])
}
return txt
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/acceld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
cli "github.com/urfave/cli/v2"

"github.com/goharbor/acceleration-service/pkg/config"
"github.com/goharbor/acceleration-service/pkg/daemon"
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/goharbor/acceleration-service

go 1.22.0

toolchain go1.24.2
go 1.24.2

require (
github.com/containerd/containerd/v2 v2.0.2
Expand Down
4 changes: 2 additions & 2 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import (
"github.com/containerd/platforms"
nydusutils "github.com/goharbor/acceleration-service/pkg/driver/nydus/utils"
"github.com/goharbor/acceleration-service/pkg/utils"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go"
digest "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go"
"github.com/pkg/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/docker/cli/cli/config"
"github.com/goharbor/acceleration-service/pkg/remote"
"github.com/pkg/errors"
"gopkg.in/yaml.v3"
yaml "gopkg.in/yaml.v3"
)

type Config struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/content/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"os"
"testing"

"github.com/opencontainers/go-digest"
digest "github.com/opencontainers/go-digest"
"github.com/stretchr/testify/require"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/content/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import (
"github.com/containerd/containerd/v2/pkg/namespaces"
"github.com/containerd/containerd/v2/plugins/content/local"
"github.com/containerd/errdefs"
"github.com/dustin/go-humanize"
humanize "github.com/dustin/go-humanize"

"github.com/goharbor/acceleration-service/pkg/cache"
"github.com/goharbor/acceleration-service/pkg/remote"
"github.com/opencontainers/go-digest"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion pkg/content/ported.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/containerd/errdefs"
"github.com/containerd/log"
"github.com/containerd/platforms"
"github.com/opencontainers/go-digest"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"golang.org/x/sync/semaphore"
"golang.org/x/sync/singleflight"
Expand Down
2 changes: 1 addition & 1 deletion pkg/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (cvt *Converter) Convert(ctx context.Context, source, target, cacheRef stri
if errors.Is(err, ctrErrdefs.ErrNotFound) {
logger.Infof("cache %s not found", cacheRef)
} else {
logger.Warnf(errors.Wrapf(err, "fetch cache %s", cacheRef).Error())
logger.Warn(errors.Wrapf(err, "fetch cache %s", cacheRef).Error())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/nydus/nydus.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
nydusutils "github.com/goharbor/acceleration-service/pkg/driver/nydus/utils"
"github.com/goharbor/acceleration-service/pkg/errdefs"
"github.com/goharbor/acceleration-service/pkg/utils"
"github.com/opencontainers/image-spec/specs-go"
specs "github.com/opencontainers/image-spec/specs-go"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/nydus/utils/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"path/filepath"

"github.com/containerd/containerd/v2/pkg/archive/compression"
"github.com/opencontainers/go-digest"
digest "github.com/opencontainers/go-digest"
)

// PackTargz makes .tar(.gz) stream of file named `name` and returns reader
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/nydus/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"os"
"testing"

"github.com/opencontainers/go-digest"
digest "github.com/opencontainers/go-digest"
)

func Test_GetRawBootstrapFromV6(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/router/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/goharbor/acceleration-service/pkg/errdefs"
"github.com/goharbor/acceleration-service/pkg/server/util"
"github.com/labstack/echo/v4"
echo "github.com/labstack/echo/v4"
)

func (r *LocalRouter) CheckHealth(ctx echo.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"errors"
"net/http"

"github.com/labstack/echo/v4"
echo "github.com/labstack/echo/v4"
"github.com/sirupsen/logrus"

"github.com/goharbor/acceleration-service/pkg/handler"
Expand Down
2 changes: 1 addition & 1 deletion pkg/router/task_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strconv"

"github.com/goharbor/acceleration-service/pkg/model"
"github.com/labstack/echo/v4"
echo "github.com/labstack/echo/v4"

"github.com/goharbor/acceleration-service/pkg/errdefs"
"github.com/goharbor/acceleration-service/pkg/server/util"
Expand Down
2 changes: 1 addition & 1 deletion pkg/router/task_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"net/http"

"github.com/goharbor/acceleration-service/pkg/task"
"github.com/labstack/echo/v4"
echo "github.com/labstack/echo/v4"
)

func (r *LocalRouter) ListTask(ctx echo.Context) error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"time"

"github.com/labstack/echo-contrib/prometheus"
"github.com/labstack/echo/v4"
echo "github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/labstack/gommon/log"
"github.com/pkg/errors"
Expand Down Expand Up @@ -135,7 +135,7 @@ func NewHTTPServer(cfg *config.ServerConfig, metricCfg *config.MetricConfig, rou
ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logrus.Fatal(errors.Wrapf(err, fmt.Sprintf("[%s] gracefully shutdown http server", cfg.Name)))
logrus.Fatal(errors.Wrap(err, fmt.Sprintf("[%s] gracefully shutdown http server", cfg.Name)))
}
}()

Expand Down
4 changes: 3 additions & 1 deletion pkg/server/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

package util

import "github.com/labstack/echo/v4"
import (
echo "github.com/labstack/echo/v4"
)

type ErrorResp struct {
Code string `json:"code"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/containerd/containerd/v2/core/images"
"github.com/containerd/containerd/v2/pkg/labels"
"github.com/containerd/platforms"
"github.com/opencontainers/go-digest"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
Expand Down