mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Add govet/golint into Travis CI build
Fix current issues
This commit is contained in:
@@ -35,8 +35,10 @@ coverage: coverage.out
|
|||||||
rm -f coverage.out
|
rm -f coverage.out
|
||||||
|
|
||||||
check:
|
check:
|
||||||
go vet -shadow=true $(ALL_PACKAGES:%=./%)
|
go vet $(ALL_PACKAGES:%=./%)
|
||||||
golint $(ALL_PACKAGES:%=./%)
|
for package in $(ALL_PACKAGES); do \
|
||||||
|
golint ./$$package; \
|
||||||
|
done
|
||||||
|
|
||||||
install:
|
install:
|
||||||
go install -v
|
go install -v
|
||||||
@@ -46,7 +48,7 @@ system-test: install
|
|||||||
if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi
|
if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi
|
||||||
PATH=$(BINPATH)/:$(PATH) $(PYTHON) system/run.py --long $(TESTS)
|
PATH=$(BINPATH)/:$(PATH) $(PYTHON) system/run.py --long $(TESTS)
|
||||||
|
|
||||||
travis: $(TRAVIS_TARGET) system-test
|
travis: $(TRAVIS_TARGET) check system-test
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -v `go list ./... | grep -v vendor/` -gocheck.v=true
|
go test -v `go list ./... | grep -v vendor/` -gocheck.v=true
|
||||||
|
|||||||
+7
-6
@@ -3,12 +3,13 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"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"
|
||||||
"sort"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Lock order acquisition (canonical):
|
// Lock order acquisition (canonical):
|
||||||
@@ -23,8 +24,8 @@ func apiVersion(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ACQUIREDB = iota
|
acquiredb = iota
|
||||||
RELEASEDB
|
releasedb
|
||||||
)
|
)
|
||||||
|
|
||||||
// Flushes all collections which cache in-memory objects
|
// Flushes all collections which cache in-memory objects
|
||||||
@@ -80,14 +81,14 @@ func acquireDatabase(requests chan int, acks chan error) {
|
|||||||
for {
|
for {
|
||||||
request := <-requests
|
request := <-requests
|
||||||
switch request {
|
switch request {
|
||||||
case ACQUIREDB:
|
case acquiredb:
|
||||||
if clients == 0 {
|
if clients == 0 {
|
||||||
acks <- context.ReOpenDatabase()
|
acks <- context.ReOpenDatabase()
|
||||||
} else {
|
} else {
|
||||||
acks <- nil
|
acks <- nil
|
||||||
}
|
}
|
||||||
clients++
|
clients++
|
||||||
case RELEASEDB:
|
case releasedb:
|
||||||
clients--
|
clients--
|
||||||
if clients == 0 {
|
if clients == 0 {
|
||||||
flushColections()
|
flushColections()
|
||||||
|
|||||||
+4
-3
@@ -1,9 +1,10 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
ctx "github.com/smira/aptly/context"
|
ctx "github.com/smira/aptly/context"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var context *ctx.AptlyContext
|
var context *ctx.AptlyContext
|
||||||
@@ -26,14 +27,14 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
|||||||
go cacheFlusher(requests, acks)
|
go cacheFlusher(requests, acks)
|
||||||
|
|
||||||
router.Use(func(c *gin.Context) {
|
router.Use(func(c *gin.Context) {
|
||||||
requests <- ACQUIREDB
|
requests <- acquiredb
|
||||||
err := <-acks
|
err := <-acks
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.Fail(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
requests <- RELEASEDB
|
requests <- releasedb
|
||||||
err = <-acks
|
err = <-acks
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.Fail(500, err)
|
||||||
|
|||||||
+1
-1
@@ -3,5 +3,5 @@ package aptly
|
|||||||
// Version of aptly
|
// Version of aptly
|
||||||
const Version = "0.9.8~dev"
|
const Version = "0.9.8~dev"
|
||||||
|
|
||||||
// Enable debugging features?
|
// EnableDebug triggers some debugging features
|
||||||
const EnableDebug = false
|
const EnableDebug = false
|
||||||
|
|||||||
@@ -2,14 +2,15 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"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"
|
|
||||||
"os/signal"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
||||||
@@ -88,7 +89,7 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
// on any interruption, unlock the mirror
|
// on any interruption, unlock the mirror
|
||||||
err := context.ReOpenDatabase()
|
err = context.ReOpenDatabase()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
repo.MarkAsIdle()
|
repo.MarkAsIdle()
|
||||||
context.CollectionFactory().RemoteRepoCollection().Update(repo)
|
context.CollectionFactory().RemoteRepoCollection().Update(repo)
|
||||||
@@ -130,7 +131,7 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// Wait for all downloads to finish
|
// Wait for all downloads to finish
|
||||||
errors := make([]string, 0)
|
var errors []string
|
||||||
|
|
||||||
for count > 0 {
|
for count > 0 {
|
||||||
select {
|
select {
|
||||||
@@ -149,7 +150,7 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
signal.Stop(sigch)
|
signal.Stop(sigch)
|
||||||
|
|
||||||
if len(errors) > 0 {
|
if len(errors) > 0 {
|
||||||
return fmt.Errorf("unable to update: download errors:\n %s\n", strings.Join(errors, "\n "))
|
return fmt.Errorf("unable to update: download errors:\n %s", strings.Join(errors, "\n "))
|
||||||
}
|
}
|
||||||
|
|
||||||
err = context.ReOpenDatabase()
|
err = context.ReOpenDatabase()
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ func aptlyTaskRun(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
var finfo os.FileInfo
|
var finfo os.FileInfo
|
||||||
if finfo, err = os.Stat(filename); os.IsNotExist(err) || finfo.IsDir() {
|
if finfo, err = os.Stat(filename); os.IsNotExist(err) || finfo.IsDir() {
|
||||||
return fmt.Errorf("no such file, %s\n", filename)
|
return fmt.Errorf("no such file, %s", filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Print("Reading file...\n\n")
|
fmt.Print("Reading file...\n\n")
|
||||||
|
|||||||
+4
-2
@@ -2,9 +2,10 @@ package deb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/smira/aptly/aptly"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/smira/aptly/utils"
|
||||||
"sort"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Dependency options
|
// Dependency options
|
||||||
@@ -66,6 +67,7 @@ func NewPackageList() *PackageList {
|
|||||||
return NewPackageListWithDuplicates(false, 1000)
|
return NewPackageListWithDuplicates(false, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewPackageListWithDuplicates creates empty package list which might allow or block duplicate packages
|
||||||
func NewPackageListWithDuplicates(duplicates bool, capacity int) *PackageList {
|
func NewPackageListWithDuplicates(duplicates bool, capacity int) *PackageList {
|
||||||
if capacity == 0 {
|
if capacity == 0 {
|
||||||
capacity = 1000
|
capacity = 1000
|
||||||
@@ -247,7 +249,7 @@ func (l *PackageList) Strings() []string {
|
|||||||
|
|
||||||
for _, p := range l.packages {
|
for _, p := range l.packages {
|
||||||
result[i] = string(p.Key(""))
|
result[i] = string(p.Key(""))
|
||||||
i += 1
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ func (s *PackageCollectionSuite) TestByKey(c *C) {
|
|||||||
c.Check(p2.Files()[0].Filename, Equals, "alien-arena-common_7.40-2_i386.deb")
|
c.Check(p2.Files()[0].Filename, Equals, "alien-arena-common_7.40-2_i386.deb")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PackageCollectionSuite) TestByKeyOld_0_3(c *C) {
|
func (s *PackageCollectionSuite) TestByKeyOld0_3(c *C) {
|
||||||
key := []byte("Pi386 vmware-view-open-client 4.5.0-297975+dfsg-4+b1")
|
key := []byte("Pi386 vmware-view-open-client 4.5.0-297975+dfsg-4+b1")
|
||||||
s.db.Put(key, old_0_3_Package)
|
s.db.Put(key, old0_3Package)
|
||||||
|
|
||||||
p, err := s.collection.ByKey(key)
|
p, err := s.collection.ByKey(key)
|
||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
@@ -133,7 +133,7 @@ func (s *PackageCollectionSuite) TestDeleteByKey(c *C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This is old package (pre-0.4) that would habe to be converted
|
// This is old package (pre-0.4) that would habe to be converted
|
||||||
var old_0_3_Package = []byte{0x8f, 0xac, 0x41, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0xa4, 0x69, 0x33, 0x38, 0x36,
|
var old0_3Package = []byte{0x8f, 0xac, 0x41, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0xa4, 0x69, 0x33, 0x38, 0x36,
|
||||||
0xac, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0xc0, 0xb1, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x44, 0x65,
|
0xac, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0xc0, 0xb1, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x44, 0x65,
|
||||||
0x70, 0x65, 0x6e, 0x64, 0x73, 0x49, 0x6e, 0x44, 0x65, 0x70, 0xc0, 0xa7, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0xdc, 0x0, 0x12,
|
0x70, 0x65, 0x6e, 0x64, 0x73, 0x49, 0x6e, 0x44, 0x65, 0x70, 0xc0, 0xa7, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0xdc, 0x0, 0x12,
|
||||||
0xb7, 0x6c, 0x69, 0x62, 0x61, 0x74, 0x6b, 0x31, 0x2e, 0x30, 0x2d, 0x30, 0x20, 0x28, 0x3e, 0x3d, 0x20, 0x31, 0x2e, 0x31, 0x32, 0x2e,
|
0xb7, 0x6c, 0x69, 0x62, 0x61, 0x74, 0x6b, 0x31, 0x2e, 0x30, 0x2d, 0x30, 0x20, 0x28, 0x3e, 0x3d, 0x20, 0x31, 0x2e, 0x31, 0x32, 0x2e,
|
||||||
|
|||||||
+2
-2
@@ -921,7 +921,7 @@ func (collection *PublishedRepoCollection) ByUUID(uuid string) (*PublishedRepo,
|
|||||||
|
|
||||||
// BySnapshot looks up repository by snapshot source
|
// BySnapshot looks up repository by snapshot source
|
||||||
func (collection *PublishedRepoCollection) BySnapshot(snapshot *Snapshot) []*PublishedRepo {
|
func (collection *PublishedRepoCollection) BySnapshot(snapshot *Snapshot) []*PublishedRepo {
|
||||||
result := make([]*PublishedRepo, 0)
|
var result []*PublishedRepo
|
||||||
for _, r := range collection.list {
|
for _, r := range collection.list {
|
||||||
if r.SourceKind == "snapshot" {
|
if r.SourceKind == "snapshot" {
|
||||||
if r.SourceUUID == snapshot.UUID {
|
if r.SourceUUID == snapshot.UUID {
|
||||||
@@ -941,7 +941,7 @@ func (collection *PublishedRepoCollection) BySnapshot(snapshot *Snapshot) []*Pub
|
|||||||
|
|
||||||
// ByLocalRepo looks up repository by local repo source
|
// ByLocalRepo looks up repository by local repo source
|
||||||
func (collection *PublishedRepoCollection) ByLocalRepo(repo *LocalRepo) []*PublishedRepo {
|
func (collection *PublishedRepoCollection) ByLocalRepo(repo *LocalRepo) []*PublishedRepo {
|
||||||
result := make([]*PublishedRepo, 0)
|
var result []*PublishedRepo
|
||||||
for _, r := range collection.list {
|
for _, r := range collection.list {
|
||||||
if r.SourceKind == "local" {
|
if r.SourceKind == "local" {
|
||||||
if r.SourceUUID == repo.UUID {
|
if r.SourceUUID == repo.UUID {
|
||||||
|
|||||||
+3
-2
@@ -3,9 +3,10 @@ package deb
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/AlekSi/pointer"
|
"github.com/AlekSi/pointer"
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
"sort"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// PackageRefList is a list of keys of packages, this is basis for snapshot
|
// PackageRefList is a list of keys of packages, this is basis for snapshot
|
||||||
@@ -389,7 +390,7 @@ func (l *PackageRefList) FilterLatestRefs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compensate for the reduced set
|
// Compensate for the reduced set
|
||||||
i -= 1
|
i--
|
||||||
}
|
}
|
||||||
|
|
||||||
lastArch, lastName, lastVer = arch, name, ver
|
lastArch, lastName, lastVer = arch, name, ver
|
||||||
|
|||||||
+21
-20
@@ -2,16 +2,17 @@ package deb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"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"
|
||||||
"github.com/smira/aptly/files"
|
"github.com/smira/aptly/files"
|
||||||
"github.com/smira/aptly/http"
|
"github.com/smira/aptly/http"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/smira/aptly/utils"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"sort"
|
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
@@ -197,7 +198,7 @@ func (s *RemoteRepoSuite) TestFetch(c *C) {
|
|||||||
|
|
||||||
func (s *RemoteRepoSuite) TestFetchNullVerifier1(c *C) {
|
func (s *RemoteRepoSuite) TestFetchNullVerifier1(c *C) {
|
||||||
downloader := http.NewFakeDownloader()
|
downloader := http.NewFakeDownloader()
|
||||||
downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/InRelease", &http.HTTPError{Code: 404})
|
downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/InRelease", &http.Error{Code: 404})
|
||||||
downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/Release", exampleReleaseFile)
|
downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/Release", exampleReleaseFile)
|
||||||
downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/Release.gpg", "GPG")
|
downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/Release.gpg", "GPG")
|
||||||
|
|
||||||
@@ -257,8 +258,8 @@ func (s *RemoteRepoSuite) TestDownload(c *C) {
|
|||||||
err := s.repo.Fetch(s.downloader, nil)
|
err := s.repo.Fetch(s.downloader, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages.bz2", &http.HTTPError{Code: 404})
|
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages.bz2", &http.Error{Code: 404})
|
||||||
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages.gz", &http.HTTPError{Code: 404})
|
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages.gz", &http.Error{Code: 404})
|
||||||
s.downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages", examplePackagesFile)
|
s.downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages", examplePackagesFile)
|
||||||
|
|
||||||
err = s.repo.DownloadPackageIndexes(s.progress, s.downloader, s.collectionFactory, false, 1)
|
err = s.repo.DownloadPackageIndexes(s.progress, s.downloader, s.collectionFactory, false, 1)
|
||||||
@@ -286,11 +287,11 @@ func (s *RemoteRepoSuite) TestDownloadWithSources(c *C) {
|
|||||||
err := s.repo.Fetch(s.downloader, nil)
|
err := s.repo.Fetch(s.downloader, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages.bz2", &http.HTTPError{Code: 404})
|
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages.bz2", &http.Error{Code: 404})
|
||||||
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages.gz", &http.HTTPError{Code: 404})
|
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages.gz", &http.Error{Code: 404})
|
||||||
s.downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages", examplePackagesFile)
|
s.downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/main/binary-i386/Packages", examplePackagesFile)
|
||||||
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/source/Sources.bz2", &http.HTTPError{Code: 404})
|
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/source/Sources.bz2", &http.Error{Code: 404})
|
||||||
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/source/Sources.gz", &http.HTTPError{Code: 404})
|
s.downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/source/Sources.gz", &http.Error{Code: 404})
|
||||||
s.downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/main/source/Sources", exampleSourcesFile)
|
s.downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/main/source/Sources", exampleSourcesFile)
|
||||||
|
|
||||||
err = s.repo.DownloadPackageIndexes(s.progress, s.downloader, s.collectionFactory, false, 1)
|
err = s.repo.DownloadPackageIndexes(s.progress, s.downloader, s.collectionFactory, false, 1)
|
||||||
@@ -327,9 +328,9 @@ func (s *RemoteRepoSuite) TestDownloadWithSources(c *C) {
|
|||||||
func (s *RemoteRepoSuite) TestDownloadFlat(c *C) {
|
func (s *RemoteRepoSuite) TestDownloadFlat(c *C) {
|
||||||
downloader := http.NewFakeDownloader()
|
downloader := http.NewFakeDownloader()
|
||||||
downloader.ExpectResponse("http://repos.express42.com/virool/precise/Release", exampleReleaseFile)
|
downloader.ExpectResponse("http://repos.express42.com/virool/precise/Release", exampleReleaseFile)
|
||||||
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.bz2", &http.HTTPError{Code: 404})
|
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.bz2", &http.Error{Code: 404})
|
||||||
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.gz", &http.HTTPError{Code: 404})
|
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.gz", &http.Error{Code: 404})
|
||||||
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.xz", &http.HTTPError{Code: 404})
|
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.xz", &http.Error{Code: 404})
|
||||||
downloader.ExpectResponse("http://repos.express42.com/virool/precise/Packages", examplePackagesFile)
|
downloader.ExpectResponse("http://repos.express42.com/virool/precise/Packages", examplePackagesFile)
|
||||||
|
|
||||||
err := s.flat.Fetch(downloader, nil)
|
err := s.flat.Fetch(downloader, nil)
|
||||||
@@ -358,13 +359,13 @@ func (s *RemoteRepoSuite) TestDownloadWithSourcesFlat(c *C) {
|
|||||||
|
|
||||||
downloader := http.NewFakeDownloader()
|
downloader := http.NewFakeDownloader()
|
||||||
downloader.ExpectResponse("http://repos.express42.com/virool/precise/Release", exampleReleaseFile)
|
downloader.ExpectResponse("http://repos.express42.com/virool/precise/Release", exampleReleaseFile)
|
||||||
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.bz2", &http.HTTPError{Code: 404})
|
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.bz2", &http.Error{Code: 404})
|
||||||
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.gz", &http.HTTPError{Code: 404})
|
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.gz", &http.Error{Code: 404})
|
||||||
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.xz", &http.HTTPError{Code: 404})
|
downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.xz", &http.Error{Code: 404})
|
||||||
downloader.ExpectResponse("http://repos.express42.com/virool/precise/Packages", examplePackagesFile)
|
downloader.ExpectResponse("http://repos.express42.com/virool/precise/Packages", examplePackagesFile)
|
||||||
downloader.ExpectError("http://repos.express42.com/virool/precise/Sources.bz2", &http.HTTPError{Code: 404})
|
downloader.ExpectError("http://repos.express42.com/virool/precise/Sources.bz2", &http.Error{Code: 404})
|
||||||
downloader.ExpectError("http://repos.express42.com/virool/precise/Sources.gz", &http.HTTPError{Code: 404})
|
downloader.ExpectError("http://repos.express42.com/virool/precise/Sources.gz", &http.Error{Code: 404})
|
||||||
downloader.ExpectError("http://repos.express42.com/virool/precise/Sources.xz", &http.HTTPError{Code: 404})
|
downloader.ExpectError("http://repos.express42.com/virool/precise/Sources.xz", &http.Error{Code: 404})
|
||||||
downloader.ExpectResponse("http://repos.express42.com/virool/precise/Sources", exampleSourcesFile)
|
downloader.ExpectResponse("http://repos.express42.com/virool/precise/Sources", exampleSourcesFile)
|
||||||
|
|
||||||
err := s.flat.Fetch(downloader, nil)
|
err := s.flat.Fetch(downloader, nil)
|
||||||
|
|||||||
+8
-7
@@ -4,15 +4,16 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/database"
|
|
||||||
"github.com/smira/aptly/utils"
|
|
||||||
"github.com/smira/go-uuid/uuid"
|
|
||||||
"github.com/ugorji/go/codec"
|
|
||||||
"log"
|
"log"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/smira/aptly/database"
|
||||||
|
"github.com/smira/aptly/utils"
|
||||||
|
"github.com/smira/go-uuid/uuid"
|
||||||
|
"github.com/ugorji/go/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Snapshot is immutable state of repository: list of packages
|
// Snapshot is immutable state of repository: list of packages
|
||||||
@@ -251,7 +252,7 @@ func (collection *SnapshotCollection) ByUUID(uuid string) (*Snapshot, error) {
|
|||||||
|
|
||||||
// ByRemoteRepoSource looks up snapshots that have specified RemoteRepo as a source
|
// ByRemoteRepoSource looks up snapshots that have specified RemoteRepo as a source
|
||||||
func (collection *SnapshotCollection) ByRemoteRepoSource(repo *RemoteRepo) []*Snapshot {
|
func (collection *SnapshotCollection) ByRemoteRepoSource(repo *RemoteRepo) []*Snapshot {
|
||||||
result := make([]*Snapshot, 0)
|
var result []*Snapshot
|
||||||
|
|
||||||
for _, s := range collection.list {
|
for _, s := range collection.list {
|
||||||
if s.SourceKind == "repo" && utils.StrSliceHasItem(s.SourceIDs, repo.UUID) {
|
if s.SourceKind == "repo" && utils.StrSliceHasItem(s.SourceIDs, repo.UUID) {
|
||||||
@@ -263,7 +264,7 @@ func (collection *SnapshotCollection) ByRemoteRepoSource(repo *RemoteRepo) []*Sn
|
|||||||
|
|
||||||
// ByLocalRepoSource looks up snapshots that have specified LocalRepo as a source
|
// ByLocalRepoSource looks up snapshots that have specified LocalRepo as a source
|
||||||
func (collection *SnapshotCollection) ByLocalRepoSource(repo *LocalRepo) []*Snapshot {
|
func (collection *SnapshotCollection) ByLocalRepoSource(repo *LocalRepo) []*Snapshot {
|
||||||
result := make([]*Snapshot, 0)
|
var result []*Snapshot
|
||||||
|
|
||||||
for _, s := range collection.list {
|
for _, s := range collection.list {
|
||||||
if s.SourceKind == "local" && utils.StrSliceHasItem(s.SourceIDs, repo.UUID) {
|
if s.SourceKind == "local" && utils.StrSliceHasItem(s.SourceIDs, repo.UUID) {
|
||||||
@@ -275,7 +276,7 @@ func (collection *SnapshotCollection) ByLocalRepoSource(repo *LocalRepo) []*Snap
|
|||||||
|
|
||||||
// BySnapshotSource looks up snapshots that have specified snapshot as a source
|
// BySnapshotSource looks up snapshots that have specified snapshot as a source
|
||||||
func (collection *SnapshotCollection) BySnapshotSource(snapshot *Snapshot) []*Snapshot {
|
func (collection *SnapshotCollection) BySnapshotSource(snapshot *Snapshot) []*Snapshot {
|
||||||
result := make([]*Snapshot, 0)
|
var result []*Snapshot
|
||||||
|
|
||||||
for _, s := range collection.list {
|
for _, s := range collection.list {
|
||||||
if s.SourceKind == "snapshot" && utils.StrSliceHasItem(s.SourceIDs, snapshot.UUID) {
|
if s.SourceKind == "snapshot" && utils.StrSliceHasItem(s.SourceIDs, snapshot.UUID) {
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -195,7 +196,7 @@ func (s *SnapshotCollectionSuite) TestFindByRemoteRepoSource(c *C) {
|
|||||||
|
|
||||||
repo3, _ := NewRemoteRepo("other", "http://mirror.yandex.ru/debian/", "lenny", []string{"main"}, []string{}, false, false)
|
repo3, _ := NewRemoteRepo("other", "http://mirror.yandex.ru/debian/", "lenny", []string{"main"}, []string{}, false, false)
|
||||||
|
|
||||||
c.Check(s.collection.ByRemoteRepoSource(repo3), DeepEquals, []*Snapshot{})
|
c.Check(s.collection.ByRemoteRepoSource(repo3), DeepEquals, []*Snapshot(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SnapshotCollectionSuite) TestFindByLocalRepoSource(c *C) {
|
func (s *SnapshotCollectionSuite) TestFindByLocalRepoSource(c *C) {
|
||||||
@@ -209,7 +210,7 @@ func (s *SnapshotCollectionSuite) TestFindByLocalRepoSource(c *C) {
|
|||||||
|
|
||||||
lrepo3 := NewLocalRepo("other", "")
|
lrepo3 := NewLocalRepo("other", "")
|
||||||
|
|
||||||
c.Check(s.collection.ByLocalRepoSource(lrepo3), DeepEquals, []*Snapshot{})
|
c.Check(s.collection.ByLocalRepoSource(lrepo3), DeepEquals, []*Snapshot(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SnapshotCollectionSuite) TestFindSnapshotSource(c *C) {
|
func (s *SnapshotCollectionSuite) TestFindSnapshotSource(c *C) {
|
||||||
@@ -225,7 +226,7 @@ func (s *SnapshotCollectionSuite) TestFindSnapshotSource(c *C) {
|
|||||||
|
|
||||||
c.Check(s.collection.BySnapshotSource(s.snapshot1), DeepEquals, []*Snapshot{snapshot3, snapshot4})
|
c.Check(s.collection.BySnapshotSource(s.snapshot1), DeepEquals, []*Snapshot{snapshot3, snapshot4})
|
||||||
c.Check(s.collection.BySnapshotSource(s.snapshot2), DeepEquals, []*Snapshot{snapshot3})
|
c.Check(s.collection.BySnapshotSource(s.snapshot2), DeepEquals, []*Snapshot{snapshot3})
|
||||||
c.Check(s.collection.BySnapshotSource(snapshot5), DeepEquals, []*Snapshot{})
|
c.Check(s.collection.BySnapshotSource(snapshot5), DeepEquals, []*Snapshot(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SnapshotCollectionSuite) TestDrop(c *C) {
|
func (s *SnapshotCollectionSuite) TestDrop(c *C) {
|
||||||
|
|||||||
+5
-5
@@ -19,14 +19,14 @@ import (
|
|||||||
"github.com/smira/go-xz"
|
"github.com/smira/go-xz"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTTPError is download error connected to HTTP code
|
// Error is download error connected to HTTP code
|
||||||
type HTTPError struct {
|
type Error struct {
|
||||||
Code int
|
Code int
|
||||||
URL string
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error
|
// Error
|
||||||
func (e *HTTPError) Error() string {
|
func (e *Error) Error() string {
|
||||||
return fmt.Sprintf("HTTP code %d while fetching %s", e.Code, e.URL)
|
return fmt.Sprintf("HTTP code %d while fetching %s", e.Code, e.URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ func (downloader *downloaderImpl) downloadTask(req *http.Request, task *download
|
|||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||||
return "", &HTTPError{Code: resp.StatusCode, URL: task.url}
|
return "", &Error{Code: resp.StatusCode, URL: task.url}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.MkdirAll(filepath.Dir(task.destination), 0777)
|
err = os.MkdirAll(filepath.Dir(task.destination), 0777)
|
||||||
@@ -367,7 +367,7 @@ func DownloadTryCompression(downloader aptly.Downloader, url string, expectedChe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err1, ok := err.(*HTTPError); ok && (err1.Code == 404 || err1.Code == 403) {
|
if err1, ok := err.(*Error); ok && (err1.Code == 404 || err1.Code == 403) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|||||||
+14
-15
@@ -233,7 +233,7 @@ func (s *DownloaderSuite) TestDownloadTryCompression(c *C) {
|
|||||||
// bzip2 not available, but gz is
|
// bzip2 not available, but gz is
|
||||||
buf = make([]byte, 4)
|
buf = make([]byte, 4)
|
||||||
d = NewFakeDownloader()
|
d = NewFakeDownloader()
|
||||||
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.bz2", &Error{Code: 404})
|
||||||
d.ExpectResponse("http://example.com/file.gz", gzipData)
|
d.ExpectResponse("http://example.com/file.gz", gzipData)
|
||||||
r, file, err = DownloadTryCompression(d, "http://example.com/file", expectedChecksums, false, 1)
|
r, file, err = DownloadTryCompression(d, "http://example.com/file", expectedChecksums, false, 1)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
@@ -245,8 +245,8 @@ func (s *DownloaderSuite) TestDownloadTryCompression(c *C) {
|
|||||||
// bzip2 & gzip not available, but xz is
|
// bzip2 & gzip not available, but xz is
|
||||||
buf = make([]byte, 4)
|
buf = make([]byte, 4)
|
||||||
d = NewFakeDownloader()
|
d = NewFakeDownloader()
|
||||||
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.bz2", &Error{Code: 404})
|
||||||
d.ExpectError("http://example.com/file.gz", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.gz", &Error{Code: 404})
|
||||||
d.ExpectResponse("http://example.com/file.xz", xzData)
|
d.ExpectResponse("http://example.com/file.xz", xzData)
|
||||||
r, file, err = DownloadTryCompression(d, "http://example.com/file", expectedChecksums, false, 1)
|
r, file, err = DownloadTryCompression(d, "http://example.com/file", expectedChecksums, false, 1)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
@@ -258,9 +258,9 @@ func (s *DownloaderSuite) TestDownloadTryCompression(c *C) {
|
|||||||
// bzip2, gzip & xz not available, but raw is
|
// bzip2, gzip & xz not available, but raw is
|
||||||
buf = make([]byte, 4)
|
buf = make([]byte, 4)
|
||||||
d = NewFakeDownloader()
|
d = NewFakeDownloader()
|
||||||
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.bz2", &Error{Code: 404})
|
||||||
d.ExpectError("http://example.com/file.gz", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.gz", &Error{Code: 404})
|
||||||
d.ExpectError("http://example.com/file.xz", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.xz", &Error{Code: 404})
|
||||||
d.ExpectResponse("http://example.com/file", rawData)
|
d.ExpectResponse("http://example.com/file", rawData)
|
||||||
r, file, err = DownloadTryCompression(d, "http://example.com/file", expectedChecksums, false, 1)
|
r, file, err = DownloadTryCompression(d, "http://example.com/file", expectedChecksums, false, 1)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
@@ -270,11 +270,10 @@ func (s *DownloaderSuite) TestDownloadTryCompression(c *C) {
|
|||||||
c.Assert(d.Empty(), Equals, true)
|
c.Assert(d.Empty(), Equals, true)
|
||||||
|
|
||||||
// gzip available, but broken
|
// gzip available, but broken
|
||||||
buf = make([]byte, 4)
|
|
||||||
d = NewFakeDownloader()
|
d = NewFakeDownloader()
|
||||||
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.bz2", &Error{Code: 404})
|
||||||
d.ExpectResponse("http://example.com/file.gz", "x")
|
d.ExpectResponse("http://example.com/file.gz", "x")
|
||||||
r, file, err = DownloadTryCompression(d, "http://example.com/file", nil, true, 1)
|
_, file, err = DownloadTryCompression(d, "http://example.com/file", nil, true, 1)
|
||||||
c.Assert(err, ErrorMatches, "unexpected EOF")
|
c.Assert(err, ErrorMatches, "unexpected EOF")
|
||||||
c.Assert(d.Empty(), Equals, true)
|
c.Assert(d.Empty(), Equals, true)
|
||||||
}
|
}
|
||||||
@@ -285,17 +284,17 @@ func (s *DownloaderSuite) TestDownloadTryCompressionErrors(c *C) {
|
|||||||
c.Assert(err, ErrorMatches, "unexpected request.*")
|
c.Assert(err, ErrorMatches, "unexpected request.*")
|
||||||
|
|
||||||
d = NewFakeDownloader()
|
d = NewFakeDownloader()
|
||||||
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.bz2", &Error{Code: 404})
|
||||||
d.ExpectError("http://example.com/file.gz", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.gz", &Error{Code: 404})
|
||||||
d.ExpectError("http://example.com/file.xz", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.xz", &Error{Code: 404})
|
||||||
d.ExpectError("http://example.com/file", errors.New("403"))
|
d.ExpectError("http://example.com/file", errors.New("403"))
|
||||||
_, _, err = DownloadTryCompression(d, "http://example.com/file", nil, true, 1)
|
_, _, err = DownloadTryCompression(d, "http://example.com/file", nil, true, 1)
|
||||||
c.Assert(err, ErrorMatches, "403")
|
c.Assert(err, ErrorMatches, "403")
|
||||||
|
|
||||||
d = NewFakeDownloader()
|
d = NewFakeDownloader()
|
||||||
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.bz2", &Error{Code: 404})
|
||||||
d.ExpectError("http://example.com/file.gz", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.gz", &Error{Code: 404})
|
||||||
d.ExpectError("http://example.com/file.xz", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.xz", &Error{Code: 404})
|
||||||
d.ExpectResponse("http://example.com/file", rawData)
|
d.ExpectResponse("http://example.com/file", rawData)
|
||||||
expectedChecksums := map[string]utils.ChecksumInfo{
|
expectedChecksums := map[string]utils.ChecksumInfo{
|
||||||
"file.bz2": {Size: 7},
|
"file.bz2": {Size: 7},
|
||||||
|
|||||||
+7
-7
@@ -28,15 +28,15 @@ type s3Error struct {
|
|||||||
Code string
|
Code string
|
||||||
Message string
|
Message string
|
||||||
BucketName string
|
BucketName string
|
||||||
RequestId string
|
RequestID string
|
||||||
HostId string
|
HostID string
|
||||||
}
|
}
|
||||||
|
|
||||||
type action struct {
|
type action struct {
|
||||||
srv *Server
|
srv *Server
|
||||||
w http.ResponseWriter
|
w http.ResponseWriter
|
||||||
req *http.Request
|
req *http.Request
|
||||||
reqId string
|
reqID string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config controls the internal behaviour of the Server. A nil config is the default
|
// Config controls the internal behaviour of the Server. A nil config is the default
|
||||||
@@ -62,7 +62,7 @@ func (c *Config) send409Conflict() bool {
|
|||||||
// All of the data for the server is kept in memory.
|
// All of the data for the server is kept in memory.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
url string
|
url string
|
||||||
reqId int
|
reqID int
|
||||||
listener net.Listener
|
listener net.Listener
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
buckets map[string]*bucket
|
buckets map[string]*bucket
|
||||||
@@ -144,9 +144,9 @@ func (srv *Server) serveHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
srv: srv,
|
srv: srv,
|
||||||
w: w,
|
w: w,
|
||||||
req: req,
|
req: req,
|
||||||
reqId: fmt.Sprintf("%09X", srv.reqId),
|
reqID: fmt.Sprintf("%09X", srv.reqID),
|
||||||
}
|
}
|
||||||
srv.reqId++
|
srv.reqID++
|
||||||
|
|
||||||
var r resource
|
var r resource
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -158,7 +158,7 @@ func (srv *Server) serveHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
case bucketResource:
|
case bucketResource:
|
||||||
err.BucketName = r.name
|
err.BucketName = r.name
|
||||||
}
|
}
|
||||||
err.RequestId = a.reqId
|
err.RequestID = a.reqID
|
||||||
// TODO HostId
|
// TODO HostId
|
||||||
w.Header().Set("Content-Type", `xml version="1.0" encoding="UTF-8"`)
|
w.Header().Set("Content-Type", `xml version="1.0" encoding="UTF-8"`)
|
||||||
w.WriteHeader(err.statusCode)
|
w.WriteHeader(err.statusCode)
|
||||||
|
|||||||
+7
-6
@@ -3,18 +3,19 @@ package swift
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/ncw/swift"
|
|
||||||
"github.com/smira/aptly/aptly"
|
|
||||||
"github.com/smira/aptly/files"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ncw/swift"
|
||||||
|
"github.com/smira/aptly/aptly"
|
||||||
|
"github.com/smira/aptly/files"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PublishedStorage abstract file system with published files (actually hosted on Swift)
|
// PublishedStorage abstract file system with published files (actually hosted on Swift)
|
||||||
type PublishedStorage struct {
|
type PublishedStorage struct {
|
||||||
conn swift.Connection
|
conn *swift.Connection
|
||||||
container string
|
container string
|
||||||
prefix string
|
prefix string
|
||||||
supportBulkDelete bool
|
supportBulkDelete bool
|
||||||
@@ -51,7 +52,7 @@ func NewPublishedStorage(username string, password string, authURL string, tenan
|
|||||||
if tenantID == "" {
|
if tenantID == "" {
|
||||||
tenantID = os.Getenv("OS_TENANT_ID")
|
tenantID = os.Getenv("OS_TENANT_ID")
|
||||||
}
|
}
|
||||||
if domain == "" {
|
if domain == "" {
|
||||||
domain = os.Getenv("OS_USER_DOMAIN_NAME")
|
domain = os.Getenv("OS_USER_DOMAIN_NAME")
|
||||||
}
|
}
|
||||||
if domainID == "" {
|
if domainID == "" {
|
||||||
@@ -64,7 +65,7 @@ func NewPublishedStorage(username string, password string, authURL string, tenan
|
|||||||
tenantDomainID = os.Getenv("OS_PROJECT_DOMAIN_ID")
|
tenantDomainID = os.Getenv("OS_PROJECT_DOMAIN_ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
ct := swift.Connection{
|
ct := &swift.Connection{
|
||||||
UserName: username,
|
UserName: username,
|
||||||
ApiKey: password,
|
ApiKey: password,
|
||||||
AuthUrl: authURL,
|
AuthUrl: authURL,
|
||||||
|
|||||||
@@ -6,4 +6,3 @@ Download queue: 1 items (30 B)
|
|||||||
Downloading ${url}pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb...
|
Downloading ${url}pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb...
|
||||||
ERROR: unable to update: download errors:
|
ERROR: unable to update: download errors:
|
||||||
${url}pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb: sha1 hash mismatch "8d3a014000038725d6daf8771b42a0784253688f" != "66b27417d37e024c46526c2f6d358a754fc552f3"
|
${url}pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb: sha1 hash mismatch "8d3a014000038725d6daf8771b42a0784253688f" != "66b27417d37e024c46526c2f6d358a754fc552f3"
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
ERROR: no such file, not_found
|
ERROR: no such file, not_found
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -104,7 +104,7 @@ func StrSliceDeduplicate(s []string) []string {
|
|||||||
|
|
||||||
// StrSlicesSubstract finds all the strings which are in l but not in r, both slices shoult be sorted
|
// StrSlicesSubstract finds all the strings which are in l but not in r, both slices shoult be sorted
|
||||||
func StrSlicesSubstract(l, r []string) []string {
|
func StrSlicesSubstract(l, r []string) []string {
|
||||||
result := make([]string, 0)
|
var result []string
|
||||||
|
|
||||||
// pointer to left and right reflists
|
// pointer to left and right reflists
|
||||||
il, ir := 0, 0
|
il, ir := 0, 0
|
||||||
|
|||||||
+1
-1
@@ -58,7 +58,7 @@ func (s *ListSuite) TestStrSliceDeduplicate(c *C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *ListSuite) TestStrSlicesSubstract(c *C) {
|
func (s *ListSuite) TestStrSlicesSubstract(c *C) {
|
||||||
empty := []string{}
|
empty := []string(nil)
|
||||||
l1 := []string{"r1", "r2", "r3", "r4"}
|
l1 := []string{"r1", "r2", "r3", "r4"}
|
||||||
l2 := []string{"r1", "r3"}
|
l2 := []string{"r1", "r3"}
|
||||||
l3 := []string{"r2", "r4"}
|
l3 := []string{"r2", "r4"}
|
||||||
|
|||||||
+16
-15
@@ -2,22 +2,23 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// check if directory exists and is accessible
|
// DirIsAccessible verifies that directory exists and is accessible
|
||||||
func DirIsAccessible(filename string) error {
|
func DirIsAccessible(filename string) error {
|
||||||
_, err := os.Stat(filename);
|
_, err := os.Stat(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ! os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
return fmt.Errorf("Something went wrong, %v", err)
|
return fmt.Errorf("Something went wrong, %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if unix.Access(filename, unix.W_OK) != nil {
|
if unix.Access(filename, unix.W_OK) != nil {
|
||||||
return fmt.Errorf("'%s' is inaccessible, check access rights", filename)
|
return fmt.Errorf("'%s' is inaccessible, check access rights", filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user