Skip to content
Snippets Groups Projects
Commit da8db466 authored by Manish Tomar's avatar Manish Tomar
Browse files

Fix gometalint errors

parent b75069ef
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -133,10 +133,7 @@ func pathFor(spec pathSpec) (string, error) {
 
return path.Join(append(append(repoPrefix, v.name, "_manifests", "revisions"), components...)...), nil
case manifestRevisionLinkPathSpec:
root, err := pathFor(manifestRevisionPathSpec{
name: v.name,
revision: v.revision,
})
root, err := pathFor(manifestRevisionPathSpec(v))
 
if err != nil {
return "", err
Loading
Loading
@@ -156,10 +153,7 @@ func pathFor(spec pathSpec) (string, error) {
 
return path.Join(root, v.tag), nil
case manifestTagCurrentPathSpec:
root, err := pathFor(manifestTagPathSpec{
name: v.name,
tag: v.tag,
})
root, err := pathFor(manifestTagPathSpec(v))
 
if err != nil {
return "", err
Loading
Loading
@@ -167,10 +161,7 @@ func pathFor(spec pathSpec) (string, error) {
 
return path.Join(root, "current", "link"), nil
case manifestTagIndexPathSpec:
root, err := pathFor(manifestTagPathSpec{
name: v.name,
tag: v.tag,
})
root, err := pathFor(manifestTagPathSpec(v))
 
if err != nil {
return "", err
Loading
Loading
@@ -178,11 +169,7 @@ func pathFor(spec pathSpec) (string, error) {
 
return path.Join(root, "index"), nil
case manifestTagIndexEntryLinkPathSpec:
root, err := pathFor(manifestTagIndexEntryPathSpec{
name: v.name,
tag: v.tag,
revision: v.revision,
})
root, err := pathFor(manifestTagIndexEntryPathSpec(v))
 
if err != nil {
return "", err
Loading
Loading
Loading
Loading
@@ -10,7 +10,6 @@ func TestPathMapper(t *testing.T) {
for _, testcase := range []struct {
spec pathSpec
expected string
err error
}{
{
spec: manifestRevisionPathSpec{
Loading
Loading
Loading
Loading
@@ -59,7 +59,7 @@ func PurgeUploads(ctx context.Context, driver storageDriver.StorageDriver, older
// file, so gather files by UUID with a date from startedAt.
func getOutstandingUploads(ctx context.Context, driver storageDriver.StorageDriver) (map[string]uploadData, []error) {
var errors []error
uploads := make(map[string]uploadData, 0)
uploads := make(map[string]uploadData)
 
inUploadDir := false
root, err := pathFor(repositoriesRootPathSpec{})
Loading
Loading
Loading
Loading
@@ -118,7 +118,7 @@ func TestPurgeOnlyUploads(t *testing.T) {
t.Fatalf(err.Error())
}
nonUploadPath := strings.Replace(dataPath, "_upload", "_important", -1)
if strings.Index(nonUploadPath, "_upload") != -1 {
if strings.Contains(nonUploadPath, "_upload") {
t.Fatalf("Non-upload path not created correctly")
}
 
Loading
Loading
@@ -132,7 +132,7 @@ func TestPurgeOnlyUploads(t *testing.T) {
t.Error("Unexpected errors", errs)
}
for _, file := range deleted {
if strings.Index(file, "_upload") == -1 {
if !strings.Contains(file, "_upload") {
t.Errorf("Non-upload file deleted")
}
}
Loading
Loading
Loading
Loading
@@ -14,9 +14,8 @@ import (
)
 
var (
errUnexpectedURL = errors.New("unexpected URL on layer")
errMissingURL = errors.New("missing URL on layer")
errInvalidURL = errors.New("invalid URL on layer")
errMissingURL = errors.New("missing URL on layer")
errInvalidURL = errors.New("invalid URL on layer")
)
 
//schema2ManifestHandler is a ManifestHandler that covers schema2 manifests.
Loading
Loading
Loading
Loading
@@ -50,25 +50,6 @@ func (ts *tagStore) All(ctx context.Context) ([]string, error) {
return tags, nil
}
 
// exists returns true if the specified manifest tag exists in the repository.
func (ts *tagStore) exists(ctx context.Context, tag string) (bool, error) {
tagPath, err := pathFor(manifestTagCurrentPathSpec{
name: ts.repository.Named().Name(),
tag: tag,
})
if err != nil {
return false, err
}
exists, err := exists(ctx, ts.blobStore.driver, tagPath)
if err != nil {
return false, err
}
return exists, nil
}
// Tag tags the digest with the given tag, updating the the store to point at
// the current tag. The digest must point to a manifest.
func (ts *tagStore) Tag(ctx context.Context, tag string, desc distribution.Descriptor) error {
Loading
Loading
package storage
import (
"context"
"github.com/docker/distribution/registry/storage/driver"
)
// Exists provides a utility method to test whether or not a path exists in
// the given driver.
func exists(ctx context.Context, drv driver.StorageDriver, path string) (bool, error) {
if _, err := drv.Stat(ctx, path); err != nil {
switch err := err.(type) {
case driver.PathNotFoundError:
return false, nil
default:
return false, err
}
}
return true, nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment