diff --git a/Makefile b/Makefile index 7772584e..b3fd1064 100644 --- a/Makefile +++ b/Makefile @@ -90,4 +90,7 @@ docker-build: docker-system-tests: docker run --rm -it -v ${PWD}:/app aptly-system-test +golangci-lint: + docker run -t --rm -v ~/.cache/golangci-lint/v1.56.2:/root/.cache -v ${PWD}:/app -w /app golangci/golangci-lint:v1.56.2 golangci-lint run -v + .PHONY: man modules version release goxc docker-build docker-system-tests diff --git a/api/files.go b/api/files.go index 04242cc9..3e7ad149 100644 --- a/api/files.go +++ b/api/files.go @@ -123,7 +123,7 @@ func apiFilesListFiles(c *gin.Context) { list := []string{} root := filepath.Join(context.UploadPath(), c.Params.ByName("dir")) - err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(root, func(path string, _ os.FileInfo, err error) error { if err != nil { return err } diff --git a/api/mirror.go b/api/mirror.go index 70ff7156..d85e2824 100644 --- a/api/mirror.go +++ b/api/mirror.go @@ -147,7 +147,7 @@ func apiMirrorsDrop(c *gin.Context) { resources := []string{string(repo.Key())} taskName := fmt.Sprintf("Delete mirror %s", name) - maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { err := repo.CheckLock() if err != nil { return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to drop: %v", err) diff --git a/api/publish.go b/api/publish.go index 110dbe54..39506695 100644 --- a/api/publish.go +++ b/api/publish.go @@ -340,7 +340,7 @@ func apiPublishUpdateSwitch(c *gin.Context) { resources = append(resources, string(published.Key())) taskName := fmt.Sprintf("Update published %s (%s): %s", published.SourceKind, strings.Join(updatedComponents, " "), strings.Join(updatedSnapshots, ", ")) - maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { err := published.Publish(context.PackagePool(), context, collectionFactory, signer, out, b.ForceOverwrite) if err != nil { return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err) @@ -384,7 +384,7 @@ func apiPublishDrop(c *gin.Context) { resources := []string{string(published.Key())} taskName := fmt.Sprintf("Delete published %s (%s)", prefix, distribution) - maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { err := collection.Remove(context, storage, prefix, distribution, collectionFactory, out, force, skipCleanup) if err != nil { diff --git a/api/repos.go b/api/repos.go index fe6206d3..6f7d435c 100644 --- a/api/repos.go +++ b/api/repos.go @@ -173,7 +173,7 @@ func apiReposDrop(c *gin.Context) { resources := []string{string(repo.Key())} taskName := fmt.Sprintf("Delete repo %s", name) - maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { published := publishedCollection.ByLocalRepo(repo) if len(published) > 0 { return &task.ProcessReturnValue{Code: http.StatusConflict, Value: nil}, fmt.Errorf("unable to drop, local repo is published") @@ -236,7 +236,7 @@ func apiReposPackagesAddDelete(c *gin.Context, taskNamePrefix string, cb func(li } resources := []string{string(repo.Key())} - maybeRunTaskInBackground(c, taskNamePrefix+repo.Name, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskNamePrefix+repo.Name, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { out.Printf("Loading packages...\n") list, err := deb.NewPackageListFromRefList(repo.RefList(), collectionFactory.PackageCollection(), nil) if err != nil { @@ -338,7 +338,7 @@ func apiReposPackageFromDir(c *gin.Context) { resources := []string{string(repo.Key())} resources = append(resources, sources...) - maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { verifier := context.GetVerifier() var ( @@ -472,7 +472,7 @@ func apiReposIncludePackageFromDir(c *gin.Context) { } resources = append(resources, sources...) - maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { var ( err error verifier = context.GetVerifier() diff --git a/api/snapshot.go b/api/snapshot.go index af905221..dfad75c3 100644 --- a/api/snapshot.go +++ b/api/snapshot.go @@ -63,7 +63,7 @@ func apiSnapshotsCreateFromMirror(c *gin.Context) { // including snapshot resource key resources := []string{string(repo.Key()), "S" + b.Name} taskName := fmt.Sprintf("Create snapshot of mirror %s", name) - maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { err := repo.CheckLock() if err != nil { return &task.ProcessReturnValue{Code: http.StatusConflict, Value: nil}, err @@ -137,7 +137,7 @@ func apiSnapshotsCreate(c *gin.Context) { resources = append(resources, string(sources[i].ResourceKey())) } - maybeRunTaskInBackground(c, "Create snapshot "+b.Name, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, "Create snapshot "+b.Name, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { list := deb.NewPackageList() // verify package refs and build package list @@ -196,7 +196,7 @@ func apiSnapshotsCreateFromRepository(c *gin.Context) { // including snapshot resource key resources := []string{string(repo.Key()), "S" + b.Name} taskName := fmt.Sprintf("Create snapshot of repo %s", name) - maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { err := collection.LoadComplete(repo) if err != nil { return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, err @@ -247,7 +247,7 @@ func apiSnapshotsUpdate(c *gin.Context) { resources := []string{string(snapshot.ResourceKey()), "S" + b.Name} taskName := fmt.Sprintf("Update snapshot %s", name) - maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { _, err := collection.ByName(b.Name) if err == nil { return &task.ProcessReturnValue{Code: http.StatusConflict, Value: nil}, fmt.Errorf("unable to rename: snapshot %s already exists", b.Name) @@ -306,7 +306,7 @@ func apiSnapshotsDrop(c *gin.Context) { resources := []string{string(snapshot.ResourceKey())} taskName := fmt.Sprintf("Delete snapshot %s", name) - maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, taskName, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { published := publishedCollection.BySnapshot(snapshot) if len(published) > 0 { @@ -449,7 +449,7 @@ func apiSnapshotsMerge(c *gin.Context) { resources[i] = string(sources[i].ResourceKey()) } - maybeRunTaskInBackground(c, "Merge snapshot "+body.Destination, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { + maybeRunTaskInBackground(c, "Merge snapshot "+body.Destination, resources, func(_ aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { result := sources[0].RefList() for i := 1; i < len(sources); i++ { result = result.Merge(sources[i].RefList(), overrideMatching, false) diff --git a/deb/contents.go b/deb/contents.go index 9f694354..cc8f8cef 100644 --- a/deb/contents.go +++ b/deb/contents.go @@ -64,7 +64,7 @@ func (index *ContentsIndex) WriteTo(w io.Writer) (int64, error) { currentPkgs [][]byte ) - err = index.db.ProcessByPrefix(index.prefix, func(key []byte, value []byte) error { + err = index.db.ProcessByPrefix(index.prefix, func(key []byte, _ []byte) error { // cut prefix key = key[prefixLen:] diff --git a/deb/local.go b/deb/local.go index 2a15c734..1b09fdbd 100644 --- a/deb/local.go +++ b/deb/local.go @@ -116,7 +116,7 @@ func (collection *LocalRepoCollection) search(filter func(*LocalRepo) bool, uniq return result } - collection.db.ProcessByPrefix([]byte("L"), func(key, blob []byte) error { + collection.db.ProcessByPrefix([]byte("L"), func(_, blob []byte) error { r := &LocalRepo{} if err := r.Decode(blob); err != nil { log.Printf("Error decoding local repo: %s\n", err) @@ -219,7 +219,7 @@ func (collection *LocalRepoCollection) ByUUID(uuid string) (*LocalRepo, error) { // ForEach runs method for each repository func (collection *LocalRepoCollection) ForEach(handler func(*LocalRepo) error) error { - return collection.db.ProcessByPrefix([]byte("L"), func(key, blob []byte) error { + return collection.db.ProcessByPrefix([]byte("L"), func(_, blob []byte) error { r := &LocalRepo{} if err := r.Decode(blob); err != nil { log.Printf("Error decoding repo: %s\n", err) diff --git a/deb/publish.go b/deb/publish.go index 19f216b1..1fbb0739 100644 --- a/deb/publish.go +++ b/deb/publish.go @@ -1123,7 +1123,7 @@ func (collection *PublishedRepoCollection) ByLocalRepo(repo *LocalRepo) []*Publi // ForEach runs method for each repository func (collection *PublishedRepoCollection) ForEach(handler func(*PublishedRepo) error) error { - return collection.db.ProcessByPrefix([]byte("U"), func(key, blob []byte) error { + return collection.db.ProcessByPrefix([]byte("U"), func(_, blob []byte) error { r := &PublishedRepo{} if err := r.Decode(blob); err != nil { log.Printf("Error decoding published repo: %s\n", err) diff --git a/deb/remote.go b/deb/remote.go index 72deb7af..7b0e4427 100644 --- a/deb/remote.go +++ b/deb/remote.go @@ -777,7 +777,7 @@ func (collection *RemoteRepoCollection) search(filter func(*RemoteRepo) bool, un return result } - collection.db.ProcessByPrefix([]byte("R"), func(key, blob []byte) error { + collection.db.ProcessByPrefix([]byte("R"), func(_, blob []byte) error { r := &RemoteRepo{} if err := r.Decode(blob); err != nil { log.Printf("Error decoding remote repo: %s\n", err) @@ -880,7 +880,7 @@ func (collection *RemoteRepoCollection) ByUUID(uuid string) (*RemoteRepo, error) // ForEach runs method for each repository func (collection *RemoteRepoCollection) ForEach(handler func(*RemoteRepo) error) error { - return collection.db.ProcessByPrefix([]byte("R"), func(key, blob []byte) error { + return collection.db.ProcessByPrefix([]byte("R"), func(_, blob []byte) error { r := &RemoteRepo{} if err := r.Decode(blob); err != nil { log.Printf("Error decoding mirror: %s\n", err) diff --git a/deb/snapshot.go b/deb/snapshot.go index f351b87f..0457f25a 100644 --- a/deb/snapshot.go +++ b/deb/snapshot.go @@ -259,7 +259,7 @@ func (collection *SnapshotCollection) search(filter func(*Snapshot) bool, unique return result } - collection.db.ProcessByPrefix([]byte("S"), func(key, blob []byte) error { + collection.db.ProcessByPrefix([]byte("S"), func(_, blob []byte) error { s := &Snapshot{} if err := s.Decode(blob); err != nil { log.Printf("Error decoding snapshot: %s\n", err) @@ -341,7 +341,7 @@ func (collection *SnapshotCollection) BySnapshotSource(snapshot *Snapshot) []*Sn // ForEach runs method for each snapshot func (collection *SnapshotCollection) ForEach(handler func(*Snapshot) error) error { - return collection.db.ProcessByPrefix([]byte("S"), func(key, blob []byte) error { + return collection.db.ProcessByPrefix([]byte("S"), func(_, blob []byte) error { s := &Snapshot{} if err := s.Decode(blob); err != nil { log.Printf("Error decoding snapshot: %s\n", err) diff --git a/s3/public.go b/s3/public.go index 4dc7c959..44e85ca3 100644 --- a/s3/public.go +++ b/s3/public.go @@ -114,7 +114,7 @@ func NewPublishedStorage( if endpoint != "" { opts = append(opts, config.WithEndpointResolverWithOptions(aws.EndpointResolverWithOptionsFunc( - func(service, region string, options ...interface{}) (aws.Endpoint, error) { + func(_, _ string, _ ...interface{}) (aws.Endpoint, error) { return aws.Endpoint{URL: endpoint}, nil }, ))) diff --git a/Dockerfile b/system/Dockerfile similarity index 100% rename from Dockerfile rename to system/Dockerfile