Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ linters:
- staticcheck
path: ^.*/log.go$
text: "ST1003:"
- linters:
- staticcheck
path: internal/cache/cache.go
text: "ST1012: error var MissErr"
- linters:
- staticcheck
path: internal/setup/setup.go
text: "ST1012: error var preferNone"
- linters:
- staticcheck
path: internal/testutil/containschecker.go
Expand Down
2 changes: 1 addition & 1 deletion internal/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (index *ubuntuIndex) fetch(path, digest string, flags fetchFlags) (io.ReadS
reader, err := index.archive.cache.Open(digest)
if err == nil {
return reader, nil
} else if err != cache.MissErr {
} else if err != cache.ErrMiss {
return nil, err
}

Expand Down
6 changes: 3 additions & 3 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (cw *Writer) Digest() string {

const digestKind = "sha256"

var MissErr = fmt.Errorf("not cached")
var ErrMiss = fmt.Errorf("not cached")

func (c *Cache) filePath(digest string) string {
return filepath.Join(c.Dir, digestKind, digest)
Expand Down Expand Up @@ -134,12 +134,12 @@ func (c *Cache) Write(digest string, data []byte) error {

func (c *Cache) Open(digest string) (io.ReadSeekCloser, error) {
if c.Dir == "" || digest == "" {
return nil, MissErr
return nil, ErrMiss
}
filePath := c.filePath(digest)
file, err := os.Open(filePath)
if os.IsNotExist(err) {
return nil, MissErr
return nil, ErrMiss
} else if err != nil {
return nil, fmt.Errorf("cannot open cache file: %v", err)
}
Expand Down
14 changes: 7 additions & 7 deletions internal/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func (s *S) TestCacheEmpty(c *C) {
cc := cache.Cache{c.MkDir()}

_, err := cc.Open(data1Digest)
c.Assert(err, Equals, cache.MissErr)
c.Assert(err, Equals, cache.ErrMiss)
_, err = cc.Read(data1Digest)
c.Assert(err, Equals, cache.MissErr)
c.Assert(err, Equals, cache.ErrMiss)
_, err = cc.Read("")
c.Assert(err, Equals, cache.MissErr)
c.Assert(err, Equals, cache.ErrMiss)
}

func (s *S) TestCacheReadWrite(c *C) {
Expand All @@ -73,9 +73,9 @@ func (s *S) TestCacheReadWrite(c *C) {
c.Assert(string(data2), Equals, "data2")

_, err = cc.Read(data3Digest)
c.Assert(err, Equals, cache.MissErr)
c.Assert(err, Equals, cache.ErrMiss)
_, err = cc.Read("")
c.Assert(err, Equals, cache.MissErr)
c.Assert(err, Equals, cache.ErrMiss)

_, err = os.Stat(data1Path)
c.Assert(err, IsNil)
Expand Down Expand Up @@ -131,9 +131,9 @@ func (s *S) TestCacheWrongDigest(c *C) {
c.Assert(errClose, ErrorMatches, "expected digest "+data1Digest+", got "+data2Digest)

_, err = cc.Read(data1Digest)
c.Assert(err, Equals, cache.MissErr)
c.Assert(err, Equals, cache.ErrMiss)
_, err = cc.Read(data2Digest)
c.Assert(err, Equals, cache.MissErr)
c.Assert(err, Equals, cache.ErrMiss)
}

func (s *S) TestCacheOpen(c *C) {
Expand Down
6 changes: 3 additions & 3 deletions internal/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (r *Release) validate() error {
_, err := preferredPathPackage(newPath, new.Package, old.Package, prefers)
if err == nil {
continue
} else if err != preferNone {
} else if err != errPreferNone {
return err
}
}
Expand Down Expand Up @@ -585,10 +585,10 @@ func preferredPathPackage(path, pkg1, pkg2 string, prefers map[preferKey]string)
pkg1, pkg2 = sortPair(conflict, sample)
return "", fmt.Errorf("package %q and %q conflict on %s without prefer relationship", pkg1, pkg2, path)
}
return "", preferNone
return "", errPreferNone
}

var preferNone = errors.New("no prefer relationship")
var errPreferNone = errors.New("no prefer relationship")

func findPrefer(path, pkg, prefer string, prefers map[preferKey]string) (found bool, err error) {
if len(prefers) == 0 {
Expand Down
Loading