govet: compose literal uses unkeyed fields

This commit is contained in:
Ximon Eighteen
2022-01-25 13:36:17 +01:00
committed by Lorenzo Bolla
parent ef2541776b
commit 4cf57ae84d

View File

@@ -65,17 +65,17 @@ func apiSnapshotsCreateFromMirror(c *gin.Context) {
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) {
err := repo.CheckLock() err := repo.CheckLock()
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusConflict, nil}, err return &task.ProcessReturnValue{Code: http.StatusConflict, Value: nil}, err
} }
err = collection.LoadComplete(repo) err = collection.LoadComplete(repo)
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusInternalServerError, nil}, err return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, err
} }
snapshot, err = deb.NewSnapshotFromRepository(b.Name, repo) snapshot, err = deb.NewSnapshotFromRepository(b.Name, repo)
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusBadRequest, nil}, err return &task.ProcessReturnValue{Code: http.StatusBadRequest, Value: nil}, err
} }
if b.Description != "" { if b.Description != "" {
@@ -84,9 +84,9 @@ func apiSnapshotsCreateFromMirror(c *gin.Context) {
err = snapshotCollection.Add(snapshot) err = snapshotCollection.Add(snapshot)
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusBadRequest, nil}, err return &task.ProcessReturnValue{Code: http.StatusBadRequest, Value: nil}, err
} }
return &task.ProcessReturnValue{http.StatusCreated, snapshot}, nil return &task.ProcessReturnValue{Code: http.StatusCreated, Value: snapshot}, nil
}) })
} }
@@ -144,13 +144,13 @@ func apiSnapshotsCreate(c *gin.Context) {
p, err := collectionFactory.PackageCollection().ByKey([]byte(ref)) p, err := collectionFactory.PackageCollection().ByKey([]byte(ref))
if err != nil { if err != nil {
if err == database.ErrNotFound { if err == database.ErrNotFound {
return &task.ProcessReturnValue{http.StatusNotFound, nil}, fmt.Errorf("package %s: %s", ref, err) return &task.ProcessReturnValue{Code: http.StatusNotFound, Value: nil}, fmt.Errorf("package %s: %s", ref, err)
} }
return &task.ProcessReturnValue{http.StatusInternalServerError, nil}, err return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, err
} }
err = list.Add(p) err = list.Add(p)
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusBadRequest, nil}, err return &task.ProcessReturnValue{Code: http.StatusBadRequest, Value: nil}, err
} }
} }
@@ -158,9 +158,9 @@ func apiSnapshotsCreate(c *gin.Context) {
err = snapshotCollection.Add(snapshot) err = snapshotCollection.Add(snapshot)
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusBadRequest, nil}, err return &task.ProcessReturnValue{Code: http.StatusBadRequest, Value: nil}, err
} }
return &task.ProcessReturnValue{http.StatusCreated, nil}, nil return &task.ProcessReturnValue{Code: http.StatusCreated, Value: nil}, nil
}) })
} }
@@ -198,12 +198,12 @@ func apiSnapshotsCreateFromRepository(c *gin.Context) {
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) {
err := collection.LoadComplete(repo) err := collection.LoadComplete(repo)
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusInternalServerError, nil}, err return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, err
} }
snapshot, err = deb.NewSnapshotFromLocalRepo(b.Name, repo) snapshot, err = deb.NewSnapshotFromLocalRepo(b.Name, repo)
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusNotFound, nil}, err return &task.ProcessReturnValue{Code: http.StatusNotFound, Value: nil}, err
} }
if b.Description != "" { if b.Description != "" {
@@ -212,9 +212,9 @@ func apiSnapshotsCreateFromRepository(c *gin.Context) {
err = snapshotCollection.Add(snapshot) err = snapshotCollection.Add(snapshot)
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusBadRequest, nil}, err return &task.ProcessReturnValue{Code: http.StatusBadRequest, Value: nil}, err
} }
return &task.ProcessReturnValue{http.StatusCreated, snapshot}, nil return &task.ProcessReturnValue{Code: http.StatusCreated, Value: snapshot}, nil
}) })
} }
@@ -249,7 +249,7 @@ func apiSnapshotsUpdate(c *gin.Context) {
maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) { maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, detail *task.Detail) (*task.ProcessReturnValue, error) {
_, err := collection.ByName(b.Name) _, err := collection.ByName(b.Name)
if err == nil { if err == nil {
return &task.ProcessReturnValue{http.StatusConflict, 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)
} }
if b.Name != "" { if b.Name != "" {
@@ -262,9 +262,9 @@ func apiSnapshotsUpdate(c *gin.Context) {
err = collectionFactory.SnapshotCollection().Update(snapshot) err = collectionFactory.SnapshotCollection().Update(snapshot)
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusInternalServerError, nil}, err return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, err
} }
return &task.ProcessReturnValue{http.StatusOK, snapshot}, nil return &task.ProcessReturnValue{Code: http.StatusOK, Value: snapshot}, nil
}) })
} }
@@ -309,21 +309,21 @@ func apiSnapshotsDrop(c *gin.Context) {
published := publishedCollection.BySnapshot(snapshot) published := publishedCollection.BySnapshot(snapshot)
if len(published) > 0 { if len(published) > 0 {
return &task.ProcessReturnValue{http.StatusConflict, nil}, fmt.Errorf("unable to drop: snapshot is published") return &task.ProcessReturnValue{Code: http.StatusConflict, Value: nil}, fmt.Errorf("unable to drop: snapshot is published")
} }
if !force { if !force {
snapshots := snapshotCollection.BySnapshotSource(snapshot) snapshots := snapshotCollection.BySnapshotSource(snapshot)
if len(snapshots) > 0 { if len(snapshots) > 0 {
return &task.ProcessReturnValue{http.StatusConflict, nil}, fmt.Errorf("won't delete snapshot that was used as source for other snapshots, use ?force=1 to override") return &task.ProcessReturnValue{Code: http.StatusConflict, Value: nil}, fmt.Errorf("won't delete snapshot that was used as source for other snapshots, use ?force=1 to override")
} }
} }
err = snapshotCollection.Drop(snapshot) err = snapshotCollection.Drop(snapshot)
if err != nil { if err != nil {
return &task.ProcessReturnValue{http.StatusInternalServerError, nil}, err return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, err
} }
return &task.ProcessReturnValue{http.StatusOK, gin.H{}}, nil return &task.ProcessReturnValue{Code: http.StatusOK, Value: gin.H{}}, nil
}) })
} }