Use error interfaces for content/metadata

These interfaces allow us to preserve both the checking of error "cause"
as well as messages returned from the gRPC API so that the client gets
full error reason instead of a default "metadata: not found" in the case
of a missing image.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
This commit is contained in:
Phil Estes
2017-06-12 16:33:06 -04:00
parent f5c587c1f7
commit e10a9aff7d
14 changed files with 254 additions and 70 deletions

View File

@@ -31,7 +31,7 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
status, err := p.tracker.GetStatus(ref)
if err == nil {
if status.Offset == status.Total {
return nil, content.ErrExists
return nil, content.ErrExists("")
}
// TODO: Handle incomplete status
} else if !content.IsNotFound(err) {
@@ -72,7 +72,7 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
// TODO: Set updated time?
},
})
return nil, content.ErrExists
return nil, content.ErrExists("")
}
if resp.StatusCode != http.StatusNotFound {
// TODO: log error

View File

@@ -34,7 +34,7 @@ func (t *memoryStatusTracker) GetStatus(ref string) (Status, error) {
defer t.m.Unlock()
status, ok := t.statuses[ref]
if !ok {
return Status{}, content.ErrNotFound
return Status{}, content.ErrNotFound("")
}
return status, nil
}