@@ -75,9 +75,11 @@ func NewPrometheus(root, graphDriverName string, maxParallelDownloads uint) (*Pr
7575func (p * Prometheus ) PullImage (imageName , dstName string ) (* OciManifest , error ) {
7676 progressCh := make (chan types.ProgressProperties )
7777 manifestCh := make (chan OciManifest )
78+ errorCh := make (chan error )
7879
7980 defer close (progressCh )
8081 defer close (manifestCh )
82+ defer close (errorCh )
8183
8284 manifest , err := p .PullManifestOnly (imageName )
8385 if err != nil {
@@ -88,7 +90,7 @@ func (p *Prometheus) PullImage(imageName, dstName string) (*OciManifest, error)
8890 layersAll := len (manifest .LayerInfos ()) + 1
8991 layersDone := 0
9092
91- err = p .pullImage (imageName , dstName , progressCh , manifestCh )
93+ err = p .pullImage (imageName , dstName , progressCh , manifestCh , errorCh )
9294 if err != nil {
9395 return nil , err
9496 }
@@ -108,6 +110,8 @@ func (p *Prometheus) PullImage(imageName, dstName string) (*OciManifest, error)
108110 }
109111 case manifest := <- manifestCh :
110112 return & manifest , nil
113+ case err := <- errorCh :
114+ return nil , err
111115 }
112116 }
113117}
@@ -121,12 +125,12 @@ func (p *Prometheus) PullImage(imageName, dstName string) (*OciManifest, error)
121125//
122126// NOTE: The user is responsible for closing both channels once the operation
123127// completes.
124- func (p * Prometheus ) PullImageAsync (imageName , dstName string , progressCh chan types.ProgressProperties , manifestCh chan OciManifest ) error {
125- err := p .pullImage (imageName , dstName , progressCh , manifestCh )
128+ func (p * Prometheus ) PullImageAsync (imageName , dstName string , progressCh chan types.ProgressProperties , manifestCh chan OciManifest , errorCh chan error ) error {
129+ err := p .pullImage (imageName , dstName , progressCh , manifestCh , errorCh )
126130 return err
127131}
128132
129- func (p * Prometheus ) pullImage (imageName , dstName string , progressCh chan types.ProgressProperties , manifestCh chan OciManifest ) error {
133+ func (p * Prometheus ) pullImage (imageName , dstName string , progressCh chan types.ProgressProperties , manifestCh chan OciManifest , errorCh chan error ) error {
130134 srcRef , err := alltransports .ParseImageName (fmt .Sprintf ("docker://%s" , imageName ))
131135 if err != nil {
132136 return err
@@ -166,12 +170,14 @@ func (p *Prometheus) pullImage(imageName, dstName string, progressCh chan types.
166170 },
167171 )
168172 if err != nil {
173+ errorCh <- err
169174 return
170175 }
171176
172177 var manifest OciManifest
173178 err = json .Unmarshal (pulledManifestBytes , & manifest )
174179 if err != nil {
180+ errorCh <- err
175181 return
176182 }
177183
0 commit comments