@@ -14,37 +14,40 @@ import (
1414)
1515
1616var (
17- // SkipDesc is used to skip processing of a descriptor and
17+ // ErrSkipDesc is used to skip processing of a descriptor and
1818 // its descendants.
19- SkipDesc = fmt .Errorf ("skip descriptor" )
19+ ErrSkipDesc = fmt .Errorf ("skip descriptor" )
2020
21- // StopHandler is used to signify that the descriptor
21+ // ErrStopHandler is used to signify that the descriptor
2222 // has been handled and should not be handled further.
2323 // This applies only to a single descriptor in a handler
2424 // chain and does not apply to descendant descriptors.
25- StopHandler = fmt .Errorf ("stop handler" )
25+ ErrStopHandler = fmt .Errorf ("stop handler" )
2626)
2727
28+ // Handler handles image manifests
2829type Handler interface {
2930 Handle (ctx context.Context , desc ocispec.Descriptor ) (subdescs []ocispec.Descriptor , err error )
3031}
3132
33+ // HandlerFunc function implementing the Handler interface
3234type HandlerFunc func (ctx context.Context , desc ocispec.Descriptor ) (subdescs []ocispec.Descriptor , err error )
3335
36+ // Handle image manifests
3437func (fn HandlerFunc ) Handle (ctx context.Context , desc ocispec.Descriptor ) (subdescs []ocispec.Descriptor , err error ) {
3538 return fn (ctx , desc )
3639}
3740
3841// Handlers returns a handler that will run the handlers in sequence.
3942//
40- // A handler may return `StopHandler ` to stop calling additional handlers
43+ // A handler may return `ErrStopHandler ` to stop calling additional handlers
4144func Handlers (handlers ... Handler ) HandlerFunc {
4245 return func (ctx context.Context , desc ocispec.Descriptor ) (subdescs []ocispec.Descriptor , err error ) {
4346 var children []ocispec.Descriptor
4447 for _ , handler := range handlers {
4548 ch , err := handler .Handle (ctx , desc )
4649 if err != nil {
47- if errors .Cause (err ) == StopHandler {
50+ if errors .Cause (err ) == ErrStopHandler {
4851 break
4952 }
5053 return nil , err
@@ -67,7 +70,7 @@ func Walk(ctx context.Context, handler Handler, descs ...ocispec.Descriptor) err
6770
6871 children , err := handler .Handle (ctx , desc )
6972 if err != nil {
70- if errors .Cause (err ) == SkipDesc {
73+ if errors .Cause (err ) == ErrSkipDesc {
7174 continue // don't traverse the children.
7275 }
7376 return err
@@ -87,7 +90,7 @@ func Walk(ctx context.Context, handler Handler, descs ...ocispec.Descriptor) err
8790// If the handler decode subresources, they will be visited, as well.
8891//
8992// Handlers for siblings are run in parallel on the provided descriptors. A
90- // handler may return `SkipDesc ` to signal to the dispatcher to not traverse
93+ // handler may return `ErrSkipDesc ` to signal to the dispatcher to not traverse
9194// any children.
9295//
9396// Typically, this function will be used with `FetchHandler`, often composed
@@ -104,7 +107,7 @@ func Dispatch(ctx context.Context, handler Handler, descs ...ocispec.Descriptor)
104107
105108 children , err := handler .Handle (ctx , desc )
106109 if err != nil {
107- if errors .Cause (err ) == SkipDesc {
110+ if errors .Cause (err ) == ErrSkipDesc {
108111 return nil // don't traverse the children.
109112 }
110113 return err
0 commit comments