@@ -28,18 +28,15 @@ import (
28
28
type PullHandler struct {
29
29
printer * output.Printer
30
30
layerSkipped atomic.Bool
31
+ target * option.Target
32
+ root ocispec.Descriptor
31
33
}
32
34
33
- // OnCompleted implements metadata.PullHandler.
34
- func (ph * PullHandler ) OnCompleted (opts * option.Target , desc ocispec.Descriptor ) error {
35
- if ph .layerSkipped .Load () {
36
- _ = ph .printer .Printf ("Skipped pulling layers without file name in %q\n " , ocispec .AnnotationTitle )
37
- _ = ph .printer .Printf ("Use 'oras copy %s --to-oci-layout <layout-dir>' to pull all layers.\n " , opts .RawReference )
38
- } else {
39
- _ = ph .printer .Println ("Pulled" , opts .AnnotatedReference ())
40
- _ = ph .printer .Println ("Digest:" , desc .Digest )
35
+ // NewPullHandler returns a new handler for Pull events.
36
+ func NewPullHandler (printer * output.Printer ) metadata.PullHandler {
37
+ return & PullHandler {
38
+ printer : printer ,
41
39
}
42
- return nil
43
40
}
44
41
45
42
func (ph * PullHandler ) OnFilePulled (_ string , _ string , _ ocispec.Descriptor , _ string ) error {
@@ -52,9 +49,20 @@ func (ph *PullHandler) OnLayerSkipped(ocispec.Descriptor) error {
52
49
return nil
53
50
}
54
51
55
- // NewPullHandler returns a new handler for Pull events.
56
- func NewPullHandler (printer * output.Printer ) metadata.PullHandler {
57
- return & PullHandler {
58
- printer : printer ,
52
+ // OnPulled implements metadata.PullHandler.
53
+ func (ph * PullHandler ) OnPulled (target * option.Target , desc ocispec.Descriptor ) {
54
+ ph .target = target
55
+ ph .root = desc
56
+ }
57
+
58
+ // Render implements metadata.PullHandler.
59
+ func (ph * PullHandler ) Render () error {
60
+ if ph .layerSkipped .Load () {
61
+ _ = ph .printer .Printf ("Skipped pulling layers without file name in %q\n " , ocispec .AnnotationTitle )
62
+ _ = ph .printer .Printf ("Use 'oras copy %s --to-oci-layout <layout-dir>' to pull all layers.\n " , ph .target .RawReference )
63
+ } else {
64
+ _ = ph .printer .Println ("Pulled" , ph .target .AnnotatedReference ())
65
+ _ = ph .printer .Println ("Digest:" , ph .root .Digest )
59
66
}
67
+ return nil
60
68
}
0 commit comments