mirror of
https://github.com/distribution/distribution.git
synced 2025-09-03 07:54:41 +00:00
Merge pull request #3766 from thaJeztah/gofumpt
format code with gofumpt
This commit is contained in:
@@ -93,7 +93,7 @@ var validRegions = map[string]struct{}{}
|
||||
// validObjectACLs contains known s3 object Acls
|
||||
var validObjectACLs = map[string]struct{}{}
|
||||
|
||||
//DriverParameters A struct that encapsulates all of the driver parameters after all values have been set
|
||||
// DriverParameters A struct that encapsulates all of the driver parameters after all values have been set
|
||||
type DriverParameters struct {
|
||||
AccessKey string
|
||||
SecretKey string
|
||||
@@ -632,7 +632,6 @@ func (d *driver) Reader(ctx context.Context, path string, offset int64) (io.Read
|
||||
Key: aws.String(d.s3Path(path)),
|
||||
Range: aws.String("bytes=" + strconv.FormatInt(offset, 10) + "-"),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
if s3Err, ok := err.(awserr.Error); ok && s3Err.Code() == "InvalidRange" {
|
||||
return ioutil.NopCloser(bytes.NewReader(nil)), nil
|
||||
@@ -1166,16 +1165,22 @@ func (d *driver) doWalk(parentCtx context.Context, objectCount *int64, path, pre
|
||||
// directoryDiff finds all directories that are not in common between
|
||||
// the previous and current paths in sorted order.
|
||||
//
|
||||
// Eg 1 directoryDiff("/path/to/folder", "/path/to/folder/folder/file")
|
||||
// => [ "/path/to/folder/folder" ],
|
||||
// Eg 2 directoryDiff("/path/to/folder/folder1", "/path/to/folder/folder2/file")
|
||||
// => [ "/path/to/folder/folder2" ]
|
||||
// Eg 3 directoryDiff("/path/to/folder/folder1/file", "/path/to/folder/folder2/file")
|
||||
// => [ "/path/to/folder/folder2" ]
|
||||
// Eg 4 directoryDiff("/path/to/folder/folder1/file", "/path/to/folder/folder2/folder1/file")
|
||||
// => [ "/path/to/folder/folder2", "/path/to/folder/folder2/folder1" ]
|
||||
// Eg 5 directoryDiff("/", "/path/to/folder/folder/file")
|
||||
// => [ "/path", "/path/to", "/path/to/folder", "/path/to/folder/folder" ],
|
||||
// # Examples
|
||||
//
|
||||
// directoryDiff("/path/to/folder", "/path/to/folder/folder/file")
|
||||
// // => [ "/path/to/folder/folder" ]
|
||||
//
|
||||
// directoryDiff("/path/to/folder/folder1", "/path/to/folder/folder2/file")
|
||||
// // => [ "/path/to/folder/folder2" ]
|
||||
//
|
||||
// directoryDiff("/path/to/folder/folder1/file", "/path/to/folder/folder2/file")
|
||||
// // => [ "/path/to/folder/folder2" ]
|
||||
//
|
||||
// directoryDiff("/path/to/folder/folder1/file", "/path/to/folder/folder2/folder1/file")
|
||||
// // => [ "/path/to/folder/folder2", "/path/to/folder/folder2/folder1" ]
|
||||
//
|
||||
// directoryDiff("/", "/path/to/folder/folder/file")
|
||||
// // => [ "/path", "/path/to", "/path/to/folder", "/path/to/folder/folder" ]
|
||||
func directoryDiff(prev, current string) []string {
|
||||
var paths []string
|
||||
|
||||
|
@@ -27,27 +27,32 @@ import (
|
||||
// Hook up gocheck into the "go test" runner.
|
||||
func Test(t *testing.T) { check.TestingT(t) }
|
||||
|
||||
var s3DriverConstructor func(rootDirectory, storageClass string) (*Driver, error)
|
||||
var skipS3 func() string
|
||||
var (
|
||||
s3DriverConstructor func(rootDirectory, storageClass string) (*Driver, error)
|
||||
skipS3 func() string
|
||||
)
|
||||
|
||||
func init() {
|
||||
accessKey := os.Getenv("AWS_ACCESS_KEY")
|
||||
secretKey := os.Getenv("AWS_SECRET_KEY")
|
||||
bucket := os.Getenv("S3_BUCKET")
|
||||
encrypt := os.Getenv("S3_ENCRYPT")
|
||||
keyID := os.Getenv("S3_KEY_ID")
|
||||
secure := os.Getenv("S3_SECURE")
|
||||
skipVerify := os.Getenv("S3_SKIP_VERIFY")
|
||||
v4Auth := os.Getenv("S3_V4_AUTH")
|
||||
region := os.Getenv("AWS_REGION")
|
||||
objectACL := os.Getenv("S3_OBJECT_ACL")
|
||||
var (
|
||||
accessKey = os.Getenv("AWS_ACCESS_KEY")
|
||||
secretKey = os.Getenv("AWS_SECRET_KEY")
|
||||
bucket = os.Getenv("S3_BUCKET")
|
||||
encrypt = os.Getenv("S3_ENCRYPT")
|
||||
keyID = os.Getenv("S3_KEY_ID")
|
||||
secure = os.Getenv("S3_SECURE")
|
||||
skipVerify = os.Getenv("S3_SKIP_VERIFY")
|
||||
v4Auth = os.Getenv("S3_V4_AUTH")
|
||||
region = os.Getenv("AWS_REGION")
|
||||
objectACL = os.Getenv("S3_OBJECT_ACL")
|
||||
regionEndpoint = os.Getenv("REGION_ENDPOINT")
|
||||
forcePathStyle = os.Getenv("AWS_S3_FORCE_PATH_STYLE")
|
||||
sessionToken = os.Getenv("AWS_SESSION_TOKEN")
|
||||
useDualStack = os.Getenv("S3_USE_DUALSTACK")
|
||||
combineSmallPart = os.Getenv("MULTIPART_COMBINE_SMALL_PART")
|
||||
accelerate = os.Getenv("S3_ACCELERATE")
|
||||
)
|
||||
|
||||
root, err := ioutil.TempDir("", "driver-")
|
||||
regionEndpoint := os.Getenv("REGION_ENDPOINT")
|
||||
forcePathStyle := os.Getenv("AWS_S3_FORCE_PATH_STYLE")
|
||||
sessionToken := os.Getenv("AWS_SESSION_TOKEN")
|
||||
useDualStack := os.Getenv("S3_USE_DUALSTACK")
|
||||
combineSmallPart := os.Getenv("MULTIPART_COMBINE_SMALL_PART")
|
||||
accelerate := os.Getenv("S3_ACCELERATE")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -343,7 +348,7 @@ func TestDelete(t *testing.T) {
|
||||
return false
|
||||
}
|
||||
|
||||
var objs = []string{
|
||||
objs := []string{
|
||||
"/file1",
|
||||
"/file1-2",
|
||||
"/file1/2",
|
||||
@@ -411,7 +416,7 @@ func TestDelete(t *testing.T) {
|
||||
}
|
||||
|
||||
// objects to skip auto-created test case
|
||||
var skipCase = map[string]bool{
|
||||
skipCase := map[string]bool{
|
||||
// special case where deleting "/file1" also deletes "/file1/2" is tested explicitly
|
||||
"/file1": true,
|
||||
}
|
||||
@@ -536,7 +541,7 @@ func TestWalk(t *testing.T) {
|
||||
t.Fatalf("unexpected error creating driver with standard storage: %v", err)
|
||||
}
|
||||
|
||||
var fileset = []string{
|
||||
fileset := []string{
|
||||
"/file1",
|
||||
"/folder1/file1",
|
||||
"/folder2/file1",
|
||||
|
Reference in New Issue
Block a user