diff --git a/configuration/configuration.go b/configuration/configuration.go index 901a25716..c9bb72e3c 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -14,13 +14,13 @@ import ( // optionally modified by environment variables type Configuration struct { // Version is the version which defines the format of the rest of the configuration - Version Version `yaml:"version"` + Version Version `yaml:"version"` // Loglevel is the level at which registry operations are logged Loglevel Loglevel `yaml:"loglevel"` // Storage is the configuration for the registry's storage driver - Storage Storage `yaml:"storage"` + Storage Storage `yaml:"storage"` } // v_0_1_Configuration is a Version 0.1 Configuration struct @@ -162,7 +162,7 @@ func (storage *Storage) UnmarshalYAML(unmarshal func(interface{}) error) error { // MarshalYAML implements the yaml.Marshaler interface func (storage Storage) MarshalYAML() (interface{}, error) { - if storage.Parameters == nil { + if storage.Parameters() == nil { return storage.Type, nil } return map[string]Parameters(storage), nil diff --git a/errors_test.go b/errors_test.go index dc6a8de78..580754f52 100644 --- a/errors_test.go +++ b/errors_test.go @@ -14,7 +14,7 @@ func TestErrorCodes(t *testing.T) { } if ec.Message() != errorCodesMessages[ec] { - t.Fatalf("incorrect message for error code %v: %q != !q", ec, ec.Message(), errorCodesMessages[ec]) + t.Fatalf("incorrect message for error code %v: %q != %q", ec, ec.Message(), errorCodesMessages[ec]) } // Serialize the error code using the json library to ensure that we @@ -26,7 +26,7 @@ func TestErrorCodes(t *testing.T) { } if len(p) <= 0 { - t.Fatalf("expected content in marshaled before for error code %v: %v", ec) + t.Fatalf("expected content in marshaled before for error code %v", ec) } // First, unmarshal to interface and ensure we have a string. diff --git a/storagedriver/filesystem/filesystem.go b/storagedriver/filesystem/filesystem.go index 2cca78906..96c781601 100644 --- a/storagedriver/filesystem/filesystem.go +++ b/storagedriver/filesystem/filesystem.go @@ -60,7 +60,7 @@ func (d *FilesystemDriver) subPath(subPath string) string { func (d *FilesystemDriver) GetContent(path string) ([]byte, error) { contents, err := ioutil.ReadFile(d.subPath(path)) if err != nil { - return nil, storagedriver.PathNotFoundError{path} + return nil, storagedriver.PathNotFoundError{Path: path} } return contents, nil } @@ -89,7 +89,7 @@ func (d *FilesystemDriver) ReadStream(path string, offset uint64) (io.ReadCloser return nil, err } else if seekPos < int64(offset) { file.Close() - return nil, storagedriver.InvalidOffsetError{path, offset} + return nil, storagedriver.InvalidOffsetError{Path: path, Offset: offset} } return file, nil @@ -104,7 +104,7 @@ func (d *FilesystemDriver) WriteStream(subPath string, offset, size uint64, read } if offset > resumableOffset { - return storagedriver.InvalidOffsetError{subPath, offset} + return storagedriver.InvalidOffsetError{Path: subPath, Offset: offset} } fullPath := d.subPath(subPath) @@ -161,7 +161,7 @@ func (d *FilesystemDriver) CurrentSize(subPath string) (uint64, error) { if err != nil && !os.IsNotExist(err) { return 0, err } else if err != nil { - return 0, storagedriver.PathNotFoundError{subPath} + return 0, storagedriver.PathNotFoundError{Path: subPath} } return uint64(fileInfo.Size()), nil } @@ -200,7 +200,7 @@ func (d *FilesystemDriver) Delete(subPath string) error { if err != nil && !os.IsNotExist(err) { return err } else if err != nil { - return storagedriver.PathNotFoundError{subPath} + return storagedriver.PathNotFoundError{Path: subPath} } err = os.RemoveAll(fullPath) diff --git a/storagedriver/inmemory/inmemory.go b/storagedriver/inmemory/inmemory.go index fee39bc97..14590a3a4 100644 --- a/storagedriver/inmemory/inmemory.go +++ b/storagedriver/inmemory/inmemory.go @@ -45,7 +45,7 @@ func (d *InMemoryDriver) GetContent(path string) ([]byte, error) { defer d.mutex.RUnlock() contents, ok := d.storage[path] if !ok { - return nil, storagedriver.PathNotFoundError{path} + return nil, storagedriver.PathNotFoundError{Path: path} } return contents, nil } @@ -64,7 +64,7 @@ func (d *InMemoryDriver) ReadStream(path string, offset uint64) (io.ReadCloser, if err != nil { return nil, err } else if len(contents) < int(offset) { - return nil, storagedriver.InvalidOffsetError{path, offset} + return nil, storagedriver.InvalidOffsetError{Path: path, Offset: offset} } src := contents[offset:] @@ -84,7 +84,7 @@ func (d *InMemoryDriver) WriteStream(path string, offset, size uint64, reader io } if offset > resumableOffset { - return storagedriver.InvalidOffsetError{path, offset} + return storagedriver.InvalidOffsetError{Path: path, Offset: offset} } contents, err := ioutil.ReadAll(reader) @@ -138,7 +138,7 @@ func (d *InMemoryDriver) Move(sourcePath string, destPath string) error { defer d.mutex.Unlock() contents, ok := d.storage[sourcePath] if !ok { - return storagedriver.PathNotFoundError{sourcePath} + return storagedriver.PathNotFoundError{Path: sourcePath} } d.storage[destPath] = contents delete(d.storage, sourcePath) @@ -156,7 +156,7 @@ func (d *InMemoryDriver) Delete(path string) error { } if len(subPaths) == 0 { - return storagedriver.PathNotFoundError{path} + return storagedriver.PathNotFoundError{Path: path} } for _, subPath := range subPaths { diff --git a/storagedriver/ipc/server.go b/storagedriver/ipc/server.go index 9d45c94e4..f374bf062 100644 --- a/storagedriver/ipc/server.go +++ b/storagedriver/ipc/server.go @@ -38,7 +38,6 @@ func StorageDriverServer(driver storagedriver.StorageDriver) error { } go receive(driver, receiver) } - return nil } } diff --git a/storagedriver/s3/s3.go b/storagedriver/s3/s3.go index c932a1e17..7ef7df6b7 100644 --- a/storagedriver/s3/s3.go +++ b/storagedriver/s3/s3.go @@ -65,7 +65,7 @@ func FromParameters(parameters map[string]string) (*S3Driver, error) { } region := aws.GetRegion(regionName) if region.Name == "" { - return nil, fmt.Errorf("Invalid region provided: %s", region) + return nil, fmt.Errorf("Invalid region provided: %v", region) } bucket, ok := parameters["bucket"] @@ -140,7 +140,7 @@ func (d *S3Driver) WriteStream(path string, offset, size uint64, reader io.ReadC } if (offset) > uint64(len(parts))*chunkSize || (offset < size && offset%chunkSize != 0) { - return storagedriver.InvalidOffsetError{path, offset} + return storagedriver.InvalidOffsetError{Path: path, Offset: offset} } if len(parts) > 0 { @@ -226,7 +226,9 @@ func (d *S3Driver) List(path string) ([]string, error) { func (d *S3Driver) Move(sourcePath string, destPath string) error { /* This is terrible, but aws doesn't have an actual move. */ - _, err := d.Bucket.PutCopy(destPath, getPermissions(), s3.CopyOptions{d.getOptions(), "", d.getContentType()}, d.Bucket.Name+"/"+sourcePath) + _, err := d.Bucket.PutCopy(destPath, getPermissions(), + s3.CopyOptions{Options: d.getOptions(), MetadataDirective: "", ContentType: d.getContentType()}, + d.Bucket.Name+"/"+sourcePath) if err != nil { return err } @@ -237,7 +239,7 @@ func (d *S3Driver) Move(sourcePath string, destPath string) error { func (d *S3Driver) Delete(path string) error { listResponse, err := d.Bucket.List(path, "", "", listPartsMax) if err != nil || len(listResponse.Contents) == 0 { - return storagedriver.PathNotFoundError{path} + return storagedriver.PathNotFoundError{Path: path} } s3Objects := make([]s3.Object, listPartsMax) @@ -247,7 +249,7 @@ func (d *S3Driver) Delete(path string) error { s3Objects[index].Key = key.Key } - err := d.Bucket.DelMulti(s3.Delete{false, s3Objects[0:len(listResponse.Contents)]}) + err := d.Bucket.DelMulti(s3.Delete{Quiet: false, Objects: s3Objects[0:len(listResponse.Contents)]}) if err != nil { return nil }