Merge pull request #513 from smira/gometalinter

Switch to gometalinter
This commit is contained in:
Andrey Smirnov
2017-03-23 16:32:33 +03:00
committed by GitHub
80 changed files with 201 additions and 123 deletions

View File

@@ -17,7 +17,8 @@ prepare:
go get -u github.com/mattn/goveralls go get -u github.com/mattn/goveralls
go get -u github.com/axw/gocov/gocov go get -u github.com/axw/gocov/gocov
go get -u golang.org/x/tools/cmd/cover go get -u golang.org/x/tools/cmd/cover
go get -u github.com/golang/lint/golint go get -u github.com/alecthomas/gometalinter
gometalinter --install
dev: dev:
go get -u github.com/golang/dep/... go get -u github.com/golang/dep/...
@@ -35,10 +36,7 @@ coverage: coverage.out
rm -f coverage.out rm -f coverage.out
check: check:
go vet $(ALL_PACKAGES:%=./%) gometalinter --vendor --vendored-linters --config=linter.json ./...
for package in $(ALL_PACKAGES); do \
golint ./$$package; \
done
install: install:
go install -v go install -v

View File

@@ -2,11 +2,12 @@ package api
import ( import (
"fmt" "fmt"
"github.com/gin-gonic/gin"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/gin-gonic/gin"
) )
func verifyPath(path string) bool { func verifyPath(path string) bool {

View File

@@ -3,12 +3,13 @@ package api
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/gin-gonic/gin"
"github.com/smira/aptly/deb"
"io" "io"
"mime" "mime"
"os" "os"
"os/exec" "os/exec"
"github.com/gin-gonic/gin"
"github.com/smira/aptly/deb"
) )
// GET /api/graph.:ext?layout=[vertical|horizontal(default)] // GET /api/graph.:ext?layout=[vertical|horizontal(default)]

View File

@@ -2,10 +2,11 @@ package api
import ( import (
"fmt" "fmt"
"strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"strings"
) )
// SigningOptions is a shared between publish API GPG options structure // SigningOptions is a shared between publish API GPG options structure

View File

@@ -2,13 +2,14 @@ package api
import ( import (
"fmt" "fmt"
"os"
"path/filepath"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/database" "github.com/smira/aptly/database"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"os"
"path/filepath"
) )
// GET /api/repos // GET /api/repos

View File

@@ -2,6 +2,7 @@ package api
import ( import (
"fmt" "fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/smira/aptly/database" "github.com/smira/aptly/database"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"

View File

@@ -3,8 +3,9 @@
package aptly package aptly
import ( import (
"github.com/smira/aptly/utils"
"io" "io"
"github.com/smira/aptly/utils"
) )
// PackagePool is asbtraction of package pool storage. // PackagePool is asbtraction of package pool storage.

View File

@@ -4,13 +4,14 @@ package cmd
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"os"
"text/template"
"time"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"os"
"text/template"
"time"
) )
// ListPackagesRefList shows list of packages in PackageRefList // ListPackagesRefList shows list of packages in PackageRefList

View File

@@ -3,6 +3,7 @@ package cmd
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/smira/commander" "github.com/smira/commander"
) )

View File

@@ -2,11 +2,12 @@ package cmd
import ( import (
"fmt" "fmt"
"sort"
"strings"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"github.com/smira/commander" "github.com/smira/commander"
"sort"
"strings"
) )
// aptly db cleanup // aptly db cleanup
@@ -153,7 +154,7 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
context.Progress().ColoredPrintf("@{w!}Loading list of all packages...@|") context.Progress().ColoredPrintf("@{w!}Loading list of all packages...@|")
allPackageRefs := context.CollectionFactory().PackageCollection().AllPackageRefs() allPackageRefs := context.CollectionFactory().PackageCollection().AllPackageRefs()
toDelete := allPackageRefs.Substract(existingPackageRefs) toDelete := allPackageRefs.Subtract(existingPackageRefs)
// delete packages that are no longer referenced // delete packages that are no longer referenced
context.Progress().ColoredPrintf("@{r!}Deleting unreferenced packages (%d)...@|", toDelete.Len()) context.Progress().ColoredPrintf("@{r!}Deleting unreferenced packages (%d)...@|", toDelete.Len())

View File

@@ -3,14 +3,15 @@ package cmd
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/smira/aptly/deb"
"github.com/smira/aptly/utils"
"github.com/smira/commander"
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"github.com/smira/aptly/deb"
"github.com/smira/aptly/utils"
"github.com/smira/commander"
) )
func aptlyGraph(cmd *commander.Command, args []string) error { func aptlyGraph(cmd *commander.Command, args []string) error {

View File

@@ -1,10 +1,11 @@
package cmd package cmd
import ( import (
"strings"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"strings"
) )
func getVerifier(flags *flag.FlagSet) (utils.Verifier, error) { func getVerifier(flags *flag.FlagSet) (utils.Verifier, error) {

View File

@@ -2,11 +2,12 @@ package cmd
import ( import (
"fmt" "fmt"
"strings"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/query" "github.com/smira/aptly/query"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"strings"
) )
func aptlyMirrorCreate(cmd *commander.Command, args []string) error { func aptlyMirrorCreate(cmd *commander.Command, args []string) error {

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
) )

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/query" "github.com/smira/aptly/query"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"

View File

@@ -2,9 +2,10 @@ package cmd
import ( import (
"fmt" "fmt"
"sort"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
"sort"
) )
func aptlyMirrorList(cmd *commander.Command, args []string) error { func aptlyMirrorList(cmd *commander.Command, args []string) error {

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
) )

View File

@@ -2,11 +2,12 @@ package cmd
import ( import (
"fmt" "fmt"
"strings"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"strings"
) )
func aptlyMirrorShow(cmd *commander.Command, args []string) error { func aptlyMirrorShow(cmd *commander.Command, args []string) error {

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
) )

View File

@@ -2,9 +2,10 @@ package cmd
import ( import (
"fmt" "fmt"
"sort"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
"sort"
) )
func aptlyPublishList(cmd *commander.Command, args []string) error { func aptlyPublishList(cmd *commander.Command, args []string) error {

View File

@@ -2,9 +2,10 @@ package cmd
import ( import (
"fmt" "fmt"
"strings"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
"strings"
) )
func aptlyPublishShow(cmd *commander.Command, args []string) error { func aptlyPublishShow(cmd *commander.Command, args []string) error {

View File

@@ -2,12 +2,13 @@ package cmd
import ( import (
"fmt" "fmt"
"strings"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"strings"
) )
func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error { func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {

View File

@@ -2,11 +2,12 @@ package cmd
import ( import (
"fmt" "fmt"
"strings"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"strings"
) )
func aptlyPublishSwitch(cmd *commander.Command, args []string) error { func aptlyPublishSwitch(cmd *commander.Command, args []string) error {

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"

View File

@@ -2,12 +2,13 @@ package cmd
import ( import (
"fmt" "fmt"
"os"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"os"
) )
func aptlyRepoAdd(cmd *commander.Command, args []string) error { func aptlyRepoAdd(cmd *commander.Command, args []string) error {

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
) )

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/AlekSi/pointer" "github.com/AlekSi/pointer"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"

View File

@@ -3,15 +3,16 @@ package cmd
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"os"
"path/filepath"
"text/template"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/query" "github.com/smira/aptly/query"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"os"
"path/filepath"
"text/template"
) )
func aptlyRepoInclude(cmd *commander.Command, args []string) error { func aptlyRepoInclude(cmd *commander.Command, args []string) error {

View File

@@ -2,9 +2,10 @@ package cmd
import ( import (
"fmt" "fmt"
"sort"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
"sort"
) )
func aptlyRepoList(cmd *commander.Command, args []string) error { func aptlyRepoList(cmd *commander.Command, args []string) error {

View File

@@ -2,11 +2,12 @@ package cmd
import ( import (
"fmt" "fmt"
"sort"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/query" "github.com/smira/aptly/query"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"sort"
) )
func aptlyRepoMoveCopyImport(cmd *commander.Command, args []string) error { func aptlyRepoMoveCopyImport(cmd *commander.Command, args []string) error {

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/query" "github.com/smira/aptly/query"
"github.com/smira/commander" "github.com/smira/commander"

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
) )

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
) )

View File

@@ -2,9 +2,10 @@ package cmd
import ( import (
"fmt" "fmt"
"os"
ctx "github.com/smira/aptly/context" ctx "github.com/smira/aptly/context"
"github.com/smira/commander" "github.com/smira/commander"
"os"
) )
// Run runs single command starting from root cmd with args, optionally initializing context // Run runs single command starting from root cmd with args, optionally initializing context

View File

@@ -2,16 +2,17 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/deb"
"github.com/smira/aptly/utils"
"github.com/smira/commander"
"github.com/smira/flag"
"net" "net"
"net/http" "net/http"
"os" "os"
"sort" "sort"
"strings" "strings"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/deb"
"github.com/smira/aptly/utils"
"github.com/smira/commander"
"github.com/smira/flag"
) )
func aptlyServe(cmd *commander.Command, args []string) error { func aptlyServe(cmd *commander.Command, args []string) error {

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
) )

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
) )

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
) )

View File

@@ -2,12 +2,13 @@ package cmd
import ( import (
"fmt" "fmt"
"sort"
"strings"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/query" "github.com/smira/aptly/query"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"sort"
"strings"
) )
func aptlySnapshotFilter(cmd *commander.Command, args []string) error { func aptlySnapshotFilter(cmd *commander.Command, args []string) error {

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
) )

View File

@@ -2,9 +2,10 @@ package cmd
import ( import (
"fmt" "fmt"
"strings"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
"strings"
) )
func aptlySnapshotMerge(cmd *commander.Command, args []string) error { func aptlySnapshotMerge(cmd *commander.Command, args []string) error {

View File

@@ -2,12 +2,13 @@ package cmd
import ( import (
"fmt" "fmt"
"sort"
"strings"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/aptly/query" "github.com/smira/aptly/query"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"sort"
"strings"
) )
func aptlySnapshotPull(cmd *commander.Command, args []string) error { func aptlySnapshotPull(cmd *commander.Command, args []string) error {

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
) )

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
) )

View File

@@ -2,9 +2,10 @@ package cmd
import ( import (
"fmt" "fmt"
"sort"
"github.com/smira/aptly/deb" "github.com/smira/aptly/deb"
"github.com/smira/commander" "github.com/smira/commander"
"sort"
) )
func aptlySnapshotVerify(cmd *commander.Command, args []string) error { func aptlySnapshotVerify(cmd *commander.Command, args []string) error {

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/commander" "github.com/smira/commander"
) )

View File

@@ -2,10 +2,11 @@ package console
import ( import (
"fmt" "fmt"
"strings"
"github.com/cheggaaa/pb" "github.com/cheggaaa/pb"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/wsxiaoys/terminal/color" "github.com/wsxiaoys/terminal/color"
"strings"
) )
const ( const (

View File

@@ -1,8 +1,9 @@
package console package console
import ( import (
"golang.org/x/crypto/ssh/terminal"
"syscall" "syscall"
"golang.org/x/crypto/ssh/terminal"
) )
// RunningOnTerminal checks whether stdout is terminal // RunningOnTerminal checks whether stdout is terminal

View File

@@ -3,6 +3,14 @@ package context
import ( import (
"fmt" "fmt"
"os"
"path/filepath"
"runtime"
"runtime/pprof"
"strings"
"sync"
"time"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/console" "github.com/smira/aptly/console"
"github.com/smira/aptly/database" "github.com/smira/aptly/database"
@@ -14,13 +22,6 @@ import (
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"github.com/smira/commander" "github.com/smira/commander"
"github.com/smira/flag" "github.com/smira/flag"
"os"
"path/filepath"
"runtime"
"runtime/pprof"
"strings"
"sync"
"time"
) )
// AptlyContext is a common context shared by all commands // AptlyContext is a common context shared by all commands

View File

@@ -2,13 +2,14 @@ package deb
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
"strings" "strings"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
) )
// Changes is a result of .changes file parsing // Changes is a result of .changes file parsing

View File

@@ -1,9 +1,10 @@
package deb package deb
import ( import (
. "gopkg.in/check.v1"
"os" "os"
"path/filepath" "path/filepath"
. "gopkg.in/check.v1"
) )
type ChangesSuite struct { type ChangesSuite struct {

View File

@@ -1,10 +1,11 @@
package deb package deb
import ( import (
"github.com/smira/aptly/utils"
"path/filepath" "path/filepath"
"runtime" "runtime"
"github.com/smira/aptly/utils"
. "gopkg.in/check.v1" . "gopkg.in/check.v1"
) )

View File

@@ -2,8 +2,9 @@ package deb
import ( import (
"fmt" "fmt"
"github.com/awalterschulze/gographviz"
"strings" "strings"
"github.com/awalterschulze/gographviz"
) )
// BuildGraph generates graph contents from aptly object database // BuildGraph generates graph contents from aptly object database
@@ -18,15 +19,15 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
var labelEnd string var labelEnd string
switch layout { switch layout {
case "vertical": case "vertical":
graph.AddAttr("aptly", "rankdir", "LR") graph.AddAttr("aptly", "rankdir", "LR")
labelStart = "" labelStart = ""
labelEnd = "" labelEnd = ""
case "horizontal": case "horizontal":
fallthrough fallthrough
default: default:
labelStart = "{" labelStart = "{"
labelEnd = "}" labelEnd = "}"
} }
existingNodes := map[string]bool{} existingNodes := map[string]bool{}
@@ -94,7 +95,7 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
"shape": "Mrecord", "shape": "Mrecord",
"style": "filled", "style": "filled",
"fillcolor": "cadetblue1", "fillcolor": "cadetblue1",
"label": fmt.Sprintf("%sSnapshot %s|%s|pkgs: %d%s", labelStart, "label": fmt.Sprintf("%sSnapshot %s|%s|pkgs: %d%s", labelStart,
snapshot.Name, description, snapshot.NumPackages(), labelEnd), snapshot.Name, description, snapshot.NumPackages(), labelEnd),
}) })

View File

@@ -1,12 +1,13 @@
package deb package deb
import ( import (
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
"strings" "strings"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
) )
// CollectPackageFiles walks filesystem collecting all candidates for package files // CollectPackageFiles walks filesystem collecting all candidates for package files

View File

@@ -3,11 +3,12 @@ package deb
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
) )
type indexFiles struct { type indexFiles struct {

View File

@@ -3,11 +3,12 @@ package deb
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"log"
"sync"
"github.com/smira/aptly/database" "github.com/smira/aptly/database"
"github.com/smira/go-uuid/uuid" "github.com/smira/go-uuid/uuid"
"github.com/ugorji/go/codec" "github.com/ugorji/go/codec"
"log"
"sync"
) )
// LocalRepo is a collection of packages created locally // LocalRepo is a collection of packages created locally

View File

@@ -2,6 +2,7 @@ package deb
import ( import (
"errors" "errors"
"github.com/smira/aptly/database" "github.com/smira/aptly/database"
. "gopkg.in/check.v1" . "gopkg.in/check.v1"

View File

@@ -3,11 +3,12 @@ package deb
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
) )
// Package is single instance of Debian package // Package is single instance of Debian package
@@ -317,7 +318,7 @@ func (p *Package) GetArchitecture() string {
return p.Architecture return p.Architecture
} }
// GetDependencies compiles list of dependenices by flags from options // GetDependencies compiles list of dependncies by flags from options
func (p *Package) GetDependencies(options int) (dependencies []string) { func (p *Package) GetDependencies(options int) (dependencies []string) {
deps := p.Deps() deps := p.Deps()

View File

@@ -3,10 +3,11 @@ package deb
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"path/filepath"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/database" "github.com/smira/aptly/database"
"github.com/ugorji/go/codec" "github.com/ugorji/go/codec"
"path/filepath"
) )
// PackageCollection does management of packages in DB // PackageCollection does management of packages in DB

View File

@@ -3,14 +3,15 @@ package deb
import ( import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
"hash/fnv" "hash/fnv"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
) )
// PackageFile is a single file entry in package // PackageFile is a single file entry in package

View File

@@ -1,11 +1,12 @@
package deb package deb
import ( import (
"github.com/smira/aptly/files"
"github.com/smira/aptly/utils"
"os" "os"
"path/filepath" "path/filepath"
"github.com/smira/aptly/files"
"github.com/smira/aptly/utils"
. "gopkg.in/check.v1" . "gopkg.in/check.v1"
) )

View File

@@ -2,12 +2,13 @@ package deb
import ( import (
"bytes" "bytes"
"github.com/smira/aptly/files"
"github.com/smira/aptly/utils"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"github.com/smira/aptly/files"
"github.com/smira/aptly/utils"
. "gopkg.in/check.v1" . "gopkg.in/check.v1"
) )

View File

@@ -2,10 +2,11 @@ package deb
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/utils"
"os/exec" "os/exec"
"regexp" "regexp"
"strings" "strings"
"github.com/smira/aptly/utils"
) )
var ppaRegexp = regexp.MustCompile("^ppa:([^/]+)/(.+)$") var ppaRegexp = regexp.MustCompile("^ppa:([^/]+)/(.+)$")

View File

@@ -51,7 +51,7 @@ type PublishedRepo struct {
// Map of sources by each component: component name -> source UUID // Map of sources by each component: component name -> source UUID
Sources map[string]string Sources map[string]string
// Legacy fields for compatibily with old published repositories (< 0.6) // Legacy fields for compatibility with old published repositories (< 0.6)
Component string Component string
// SourceUUID is UUID of either snapshot or local repo // SourceUUID is UUID of either snapshot or local repo
SourceUUID string `codec:"SnapshotUUID"` SourceUUID string `codec:"SnapshotUUID"`

View File

@@ -4,13 +4,14 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/database" "github.com/smira/aptly/database"
"github.com/smira/aptly/files" "github.com/smira/aptly/files"
"github.com/ugorji/go/codec" "github.com/ugorji/go/codec"
"io/ioutil"
"os"
"path/filepath"
. "gopkg.in/check.v1" . "gopkg.in/check.v1"
) )

View File

@@ -110,8 +110,8 @@ func (l *PackageRefList) Strings() []string {
return result return result
} }
// Substract returns all packages in l that are not in r // Subtract returns all packages in l that are not in r
func (l *PackageRefList) Substract(r *PackageRefList) *PackageRefList { func (l *PackageRefList) Subtract(r *PackageRefList) *PackageRefList {
result := &PackageRefList{Refs: make([][]byte, 0, 128)} result := &PackageRefList{Refs: make([][]byte, 0, 128)}
// pointer to left and right reflists // pointer to left and right reflists
@@ -271,7 +271,7 @@ func (l *PackageRefList) Diff(r *PackageRefList, packageCollection *PackageColle
// Merge merges reflist r into current reflist. If overrideMatching, merge // Merge merges reflist r into current reflist. If overrideMatching, merge
// replaces matching packages (by architecture/name) with reference from r. // replaces matching packages (by architecture/name) with reference from r.
// If ignoreConflicting is set, all packages are preserved, otherwise conflciting // If ignoreConflicting is set, all packages are preserved, otherwise conflicting
// packages are overwritten with packages from "right" snapshot. // packages are overwritten with packages from "right" snapshot.
func (l *PackageRefList) Merge(r *PackageRefList, overrideMatching, ignoreConflicting bool) (result *PackageRefList) { func (l *PackageRefList) Merge(r *PackageRefList, overrideMatching, ignoreConflicting bool) (result *PackageRefList) {
var overriddenArch, overridenName []byte var overriddenArch, overridenName []byte
@@ -328,7 +328,7 @@ func (l *PackageRefList) Merge(r *PackageRefList, overrideMatching, ignoreConfli
if overrideMatching { if overrideMatching {
if bytes.Equal(archL, overriddenArch) && bytes.Equal(nameL, overridenName) { if bytes.Equal(archL, overriddenArch) && bytes.Equal(nameL, overridenName) {
// this package has already been overriden on the right // this package has already been overridden on the right
il++ il++
continue continue
} }

View File

@@ -2,6 +2,7 @@ package deb
import ( import (
"errors" "errors"
"github.com/smira/aptly/database" "github.com/smira/aptly/database"
. "gopkg.in/check.v1" . "gopkg.in/check.v1"
@@ -156,12 +157,12 @@ func (s *PackageRefListSuite) TestSubstract(c *C) {
l4 := &PackageRefList{Refs: [][]byte{r4, r5}} l4 := &PackageRefList{Refs: [][]byte{r4, r5}}
l5 := &PackageRefList{Refs: [][]byte{r1, r2, r3}} l5 := &PackageRefList{Refs: [][]byte{r1, r2, r3}}
c.Check(l1.Substract(empty), DeepEquals, l1) c.Check(l1.Subtract(empty), DeepEquals, l1)
c.Check(l1.Substract(l2), DeepEquals, l3) c.Check(l1.Subtract(l2), DeepEquals, l3)
c.Check(l1.Substract(l3), DeepEquals, l2) c.Check(l1.Subtract(l3), DeepEquals, l2)
c.Check(l1.Substract(l4), DeepEquals, l5) c.Check(l1.Subtract(l4), DeepEquals, l5)
c.Check(empty.Substract(l1), DeepEquals, empty) c.Check(empty.Subtract(l1), DeepEquals, empty)
c.Check(l2.Substract(l3), DeepEquals, l2) c.Check(l2.Subtract(l3), DeepEquals, l2)
} }
func (s *PackageRefListSuite) TestDiff(c *C) { func (s *PackageRefListSuite) TestDiff(c *C) {

View File

@@ -3,12 +3,6 @@ package deb
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/database"
"github.com/smira/aptly/http"
"github.com/smira/aptly/utils"
"github.com/smira/go-uuid/uuid"
"github.com/ugorji/go/codec"
"log" "log"
"net/url" "net/url"
"os" "os"
@@ -20,6 +14,13 @@ import (
"sync" "sync"
"syscall" "syscall"
"time" "time"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/database"
"github.com/smira/aptly/http"
"github.com/smira/aptly/utils"
"github.com/smira/go-uuid/uuid"
"github.com/ugorji/go/codec"
) )
// RemoteRepo statuses // RemoteRepo statuses

View File

@@ -3,9 +3,10 @@ package deb
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os"
"github.com/DisposaBoy/JsonConfigReader" "github.com/DisposaBoy/JsonConfigReader"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"os"
) )
// UploadersRule is single rule of format: what packages can group or key upload // UploadersRule is single rule of format: what packages can group or key upload

View File

@@ -2,12 +2,13 @@ package files
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/aptly"
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"sync" "sync"
"github.com/smira/aptly/aptly"
) )
// PackagePool is deduplicated storage of package files on filesystem // PackagePool is deduplicated storage of package files on filesystem

View File

@@ -2,11 +2,12 @@ package files
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/aptly"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"syscall" "syscall"
"github.com/smira/aptly/aptly"
) )
// PublishedStorage abstract file system with public dirs (published repos) // PublishedStorage abstract file system with public dirs (published repos)

View File

@@ -2,11 +2,12 @@ package http
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
) )
type expectedRequest struct { type expectedRequest struct {

4
linter.json Normal file
View File

@@ -0,0 +1,4 @@
{
"DisableAll": true,
"Enable": ["vet", "golint", "gofmt", "deadcode", "goimports", "misspell"]
}

View File

@@ -1,8 +1,9 @@
package main package main
import ( import (
"github.com/smira/aptly/cmd"
"os" "os"
"github.com/smira/aptly/cmd"
) )
func main() { func main() {

View File

@@ -2,9 +2,6 @@ package main
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/cmd"
"github.com/smira/commander"
"github.com/smira/flag"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
@@ -13,6 +10,10 @@ import (
"runtime" "runtime"
"strings" "strings"
"text/template" "text/template"
"github.com/smira/aptly/cmd"
"github.com/smira/commander"
"github.com/smira/flag"
) )
func allFlags(flags *flag.FlagSet) []*flag.Flag { func allFlags(flags *flag.FlagSet) []*flag.Flag {

View File

@@ -2,11 +2,12 @@ package query
import ( import (
"fmt" "fmt"
"github.com/smira/aptly/deb"
"regexp" "regexp"
"strings" "strings"
"unicode" "unicode"
"unicode/utf8" "unicode/utf8"
"github.com/smira/aptly/deb"
) )
type parser struct { type parser struct {

View File

@@ -1,9 +1,10 @@
package query package query
import ( import (
"github.com/smira/aptly/deb"
"regexp" "regexp"
"github.com/smira/aptly/deb"
. "gopkg.in/check.v1" . "gopkg.in/check.v1"
) )

View File

@@ -2,6 +2,10 @@ package s3
import ( import (
"fmt" "fmt"
"os"
"path/filepath"
"strings"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/corehandlers" "github.com/aws/aws-sdk-go/aws/corehandlers"
"github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/credentials"
@@ -11,9 +15,6 @@ import (
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/files" "github.com/smira/aptly/files"
"github.com/smira/go-aws-auth" "github.com/smira/go-aws-auth"
"os"
"path/filepath"
"strings"
) )
// PublishedStorage abstract file system with published files (actually hosted on S3) // PublishedStorage abstract file system with published files (actually hosted on S3)

View File

@@ -2,13 +2,14 @@ package swift
import ( import (
"fmt" "fmt"
. "gopkg.in/check.v1"
"io/ioutil" "io/ioutil"
"math/rand" "math/rand"
"os" "os"
"path/filepath" "path/filepath"
"time" "time"
. "gopkg.in/check.v1"
"github.com/ncw/swift/swifttest" "github.com/ncw/swift/swifttest"
"github.com/smira/aptly/files" "github.com/smira/aptly/files"

View File

@@ -26,6 +26,7 @@ const (
listenFdsStart = 3 listenFdsStart = 3
) )
// Files returns all the fds passed from systemd
func Files(unsetEnv bool) []*os.File { func Files(unsetEnv bool) []*os.File {
if unsetEnv { if unsetEnv {
defer os.Unsetenv("LISTEN_PID") defer os.Unsetenv("LISTEN_PID")