handle error returns more properly

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
v0.8
Tonis Tiigi 2020-07-18 15:51:00 -07:00
parent 5da4a40ae8
commit 94c202bfb9
5 changed files with 11 additions and 14 deletions

View File

@ -97,8 +97,8 @@ type cniNS struct {
path string
}
func (ns *cniNS) Set(s *specs.Spec) {
oci.WithLinuxNamespace(specs.LinuxNamespace{
func (ns *cniNS) Set(s *specs.Spec) error {
return oci.WithLinuxNamespace(specs.LinuxNamespace{
Type: specs.NetworkNamespace,
Path: ns.path,
})(nil, nil, nil, s)

View File

@ -19,8 +19,8 @@ func (h *host) New() (Namespace, error) {
type hostNS struct {
}
func (h *hostNS) Set(s *specs.Spec) {
oci.WithHostNamespace(specs.NetworkNamespace)(nil, nil, nil, s)
func (h *hostNS) Set(s *specs.Spec) error {
return oci.WithHostNamespace(specs.NetworkNamespace)(nil, nil, nil, s)
}
func (h *hostNS) Close() error {

View File

@ -15,5 +15,5 @@ type Provider interface {
type Namespace interface {
io.Closer
// Set the namespace on the spec
Set(*specs.Spec)
Set(*specs.Spec) error
}

View File

@ -18,7 +18,8 @@ func (h *none) New() (Namespace, error) {
type noneNS struct {
}
func (h *noneNS) Set(s *specs.Spec) {
func (h *noneNS) Set(s *specs.Spec) error {
return nil
}
func (h *noneNS) Close() error {

View File

@ -93,21 +93,17 @@ func Push(ctx context.Context, sm *session.Manager, sid string, cs content.Store
Size: ra.Size(),
MediaType: mtype,
})
layersDone(err)
if err != nil {
if err := layersDone(err); err != nil {
return err
}
mfstDone := oneOffProgress(ctx, fmt.Sprintf("pushing manifest for %s", ref))
for i := len(manifestStack) - 1; i >= 0; i-- {
_, err := pushHandler(ctx, manifestStack[i])
if err != nil {
mfstDone(err)
return err
if _, err := pushHandler(ctx, manifestStack[i]); err != nil {
return mfstDone(err)
}
}
mfstDone(nil)
return nil
return mfstDone(nil)
}
func annotateDistributionSourceHandler(cs content.Store, f images.HandlerFunc) func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {