mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-09 06:04:12 +00:00
fix golint complaints
This commit is contained in:
@@ -90,4 +90,7 @@ docker-build:
|
|||||||
docker-system-tests:
|
docker-system-tests:
|
||||||
docker run --rm -it -v ${PWD}:/app aptly-system-test
|
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
|
.PHONY: man modules version release goxc docker-build docker-system-tests
|
||||||
|
|||||||
+1
-1
@@ -123,7 +123,7 @@ func apiFilesListFiles(c *gin.Context) {
|
|||||||
list := []string{}
|
list := []string{}
|
||||||
root := filepath.Join(context.UploadPath(), c.Params.ByName("dir"))
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -147,7 +147,7 @@ func apiMirrorsDrop(c *gin.Context) {
|
|||||||
|
|
||||||
resources := []string{string(repo.Key())}
|
resources := []string{string(repo.Key())}
|
||||||
taskName := fmt.Sprintf("Delete mirror %s", name)
|
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()
|
err := repo.CheckLock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to drop: %v", err)
|
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to drop: %v", err)
|
||||||
|
|||||||
+2
-2
@@ -340,7 +340,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
|||||||
|
|
||||||
resources = append(resources, string(published.Key()))
|
resources = append(resources, string(published.Key()))
|
||||||
taskName := fmt.Sprintf("Update published %s (%s): %s", published.SourceKind, strings.Join(updatedComponents, " "), strings.Join(updatedSnapshots, ", "))
|
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)
|
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, out, b.ForceOverwrite)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err)
|
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())}
|
resources := []string{string(published.Key())}
|
||||||
|
|
||||||
taskName := fmt.Sprintf("Delete published %s (%s)", prefix, distribution)
|
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,
|
err := collection.Remove(context, storage, prefix, distribution,
|
||||||
collectionFactory, out, force, skipCleanup)
|
collectionFactory, out, force, skipCleanup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+4
-4
@@ -173,7 +173,7 @@ func apiReposDrop(c *gin.Context) {
|
|||||||
|
|
||||||
resources := []string{string(repo.Key())}
|
resources := []string{string(repo.Key())}
|
||||||
taskName := fmt.Sprintf("Delete repo %s", name)
|
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)
|
published := publishedCollection.ByLocalRepo(repo)
|
||||||
if len(published) > 0 {
|
if len(published) > 0 {
|
||||||
return &task.ProcessReturnValue{Code: http.StatusConflict, Value: nil}, fmt.Errorf("unable to drop, local repo is published")
|
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())}
|
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")
|
out.Printf("Loading packages...\n")
|
||||||
list, err := deb.NewPackageListFromRefList(repo.RefList(), collectionFactory.PackageCollection(), nil)
|
list, err := deb.NewPackageListFromRefList(repo.RefList(), collectionFactory.PackageCollection(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -338,7 +338,7 @@ func apiReposPackageFromDir(c *gin.Context) {
|
|||||||
|
|
||||||
resources := []string{string(repo.Key())}
|
resources := []string{string(repo.Key())}
|
||||||
resources = append(resources, sources...)
|
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()
|
verifier := context.GetVerifier()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -472,7 +472,7 @@ func apiReposIncludePackageFromDir(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
resources = append(resources, sources...)
|
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 (
|
var (
|
||||||
err error
|
err error
|
||||||
verifier = context.GetVerifier()
|
verifier = context.GetVerifier()
|
||||||
|
|||||||
+6
-6
@@ -63,7 +63,7 @@ func apiSnapshotsCreateFromMirror(c *gin.Context) {
|
|||||||
// including snapshot resource key
|
// including snapshot resource key
|
||||||
resources := []string{string(repo.Key()), "S" + b.Name}
|
resources := []string{string(repo.Key()), "S" + b.Name}
|
||||||
taskName := fmt.Sprintf("Create snapshot of mirror %s", 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()
|
err := repo.CheckLock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &task.ProcessReturnValue{Code: http.StatusConflict, Value: nil}, err
|
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()))
|
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()
|
list := deb.NewPackageList()
|
||||||
|
|
||||||
// verify package refs and build package list
|
// verify package refs and build package list
|
||||||
@@ -196,7 +196,7 @@ func apiSnapshotsCreateFromRepository(c *gin.Context) {
|
|||||||
// including snapshot resource key
|
// including snapshot resource key
|
||||||
resources := []string{string(repo.Key()), "S" + b.Name}
|
resources := []string{string(repo.Key()), "S" + b.Name}
|
||||||
taskName := fmt.Sprintf("Create snapshot of repo %s", 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)
|
err := collection.LoadComplete(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, err
|
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}
|
resources := []string{string(snapshot.ResourceKey()), "S" + b.Name}
|
||||||
taskName := fmt.Sprintf("Update snapshot %s", 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)
|
_, err := collection.ByName(b.Name)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return &task.ProcessReturnValue{Code: http.StatusConflict, Value: nil}, fmt.Errorf("unable to rename: snapshot %s already exists", b.Name)
|
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())}
|
resources := []string{string(snapshot.ResourceKey())}
|
||||||
taskName := fmt.Sprintf("Delete snapshot %s", name)
|
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)
|
published := publishedCollection.BySnapshot(snapshot)
|
||||||
|
|
||||||
if len(published) > 0 {
|
if len(published) > 0 {
|
||||||
@@ -449,7 +449,7 @@ func apiSnapshotsMerge(c *gin.Context) {
|
|||||||
resources[i] = string(sources[i].ResourceKey())
|
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()
|
result := sources[0].RefList()
|
||||||
for i := 1; i < len(sources); i++ {
|
for i := 1; i < len(sources); i++ {
|
||||||
result = result.Merge(sources[i].RefList(), overrideMatching, false)
|
result = result.Merge(sources[i].RefList(), overrideMatching, false)
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ func (index *ContentsIndex) WriteTo(w io.Writer) (int64, error) {
|
|||||||
currentPkgs [][]byte
|
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
|
// cut prefix
|
||||||
key = key[prefixLen:]
|
key = key[prefixLen:]
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -116,7 +116,7 @@ func (collection *LocalRepoCollection) search(filter func(*LocalRepo) bool, uniq
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.db.ProcessByPrefix([]byte("L"), func(key, blob []byte) error {
|
collection.db.ProcessByPrefix([]byte("L"), func(_, blob []byte) error {
|
||||||
r := &LocalRepo{}
|
r := &LocalRepo{}
|
||||||
if err := r.Decode(blob); err != nil {
|
if err := r.Decode(blob); err != nil {
|
||||||
log.Printf("Error decoding local repo: %s\n", err)
|
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
|
// ForEach runs method for each repository
|
||||||
func (collection *LocalRepoCollection) ForEach(handler func(*LocalRepo) error) error {
|
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{}
|
r := &LocalRepo{}
|
||||||
if err := r.Decode(blob); err != nil {
|
if err := r.Decode(blob); err != nil {
|
||||||
log.Printf("Error decoding repo: %s\n", err)
|
log.Printf("Error decoding repo: %s\n", err)
|
||||||
|
|||||||
+1
-1
@@ -1123,7 +1123,7 @@ func (collection *PublishedRepoCollection) ByLocalRepo(repo *LocalRepo) []*Publi
|
|||||||
|
|
||||||
// ForEach runs method for each repository
|
// ForEach runs method for each repository
|
||||||
func (collection *PublishedRepoCollection) ForEach(handler func(*PublishedRepo) error) error {
|
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{}
|
r := &PublishedRepo{}
|
||||||
if err := r.Decode(blob); err != nil {
|
if err := r.Decode(blob); err != nil {
|
||||||
log.Printf("Error decoding published repo: %s\n", err)
|
log.Printf("Error decoding published repo: %s\n", err)
|
||||||
|
|||||||
+2
-2
@@ -777,7 +777,7 @@ func (collection *RemoteRepoCollection) search(filter func(*RemoteRepo) bool, un
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.db.ProcessByPrefix([]byte("R"), func(key, blob []byte) error {
|
collection.db.ProcessByPrefix([]byte("R"), func(_, blob []byte) error {
|
||||||
r := &RemoteRepo{}
|
r := &RemoteRepo{}
|
||||||
if err := r.Decode(blob); err != nil {
|
if err := r.Decode(blob); err != nil {
|
||||||
log.Printf("Error decoding remote repo: %s\n", err)
|
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
|
// ForEach runs method for each repository
|
||||||
func (collection *RemoteRepoCollection) ForEach(handler func(*RemoteRepo) error) error {
|
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{}
|
r := &RemoteRepo{}
|
||||||
if err := r.Decode(blob); err != nil {
|
if err := r.Decode(blob); err != nil {
|
||||||
log.Printf("Error decoding mirror: %s\n", err)
|
log.Printf("Error decoding mirror: %s\n", err)
|
||||||
|
|||||||
+2
-2
@@ -259,7 +259,7 @@ func (collection *SnapshotCollection) search(filter func(*Snapshot) bool, unique
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.db.ProcessByPrefix([]byte("S"), func(key, blob []byte) error {
|
collection.db.ProcessByPrefix([]byte("S"), func(_, blob []byte) error {
|
||||||
s := &Snapshot{}
|
s := &Snapshot{}
|
||||||
if err := s.Decode(blob); err != nil {
|
if err := s.Decode(blob); err != nil {
|
||||||
log.Printf("Error decoding snapshot: %s\n", err)
|
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
|
// ForEach runs method for each snapshot
|
||||||
func (collection *SnapshotCollection) ForEach(handler func(*Snapshot) error) error {
|
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{}
|
s := &Snapshot{}
|
||||||
if err := s.Decode(blob); err != nil {
|
if err := s.Decode(blob); err != nil {
|
||||||
log.Printf("Error decoding snapshot: %s\n", err)
|
log.Printf("Error decoding snapshot: %s\n", err)
|
||||||
|
|||||||
+1
-1
@@ -114,7 +114,7 @@ func NewPublishedStorage(
|
|||||||
|
|
||||||
if endpoint != "" {
|
if endpoint != "" {
|
||||||
opts = append(opts, config.WithEndpointResolverWithOptions(aws.EndpointResolverWithOptionsFunc(
|
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
|
return aws.Endpoint{URL: endpoint}, nil
|
||||||
},
|
},
|
||||||
)))
|
)))
|
||||||
|
|||||||
Reference in New Issue
Block a user