MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / handlePullImageProcess

Function handlePullImageProcess

agent/utils/docker/docker.go:205–235  ·  view source on GitHub ↗
(out io.Reader, task *task.Task)

Source from the content-addressed store, hash-verified

203}
204
205func handlePullImageProcess(out io.Reader, task *task.Task) error {
206 decoder := json.NewDecoder(out)
207 for {
208 var progress map[string]interface{}
209 if err := decoder.Decode(&progress); err != nil {
210 if err == io.EOF {
211 break
212 }
213 return err
214 }
215 if msg, ok := progress["errorDetail"]; ok {
216 return fmt.Errorf("image pull failed, err: %v", msg)
217 }
218 if msg, ok := progress["error"]; ok {
219 return fmt.Errorf("image pull failed, err: %v", msg)
220 }
221 if task == nil {
222 continue
223 }
224 status, _ := progress["status"].(string)
225 switch status {
226 case "Downloading", "Extracting":
227 logProcess(progress, task)
228 case "Pull complete", "Download complete", "Already exists", "Verifying Checksum":
229 id, _ := progress["id"].(string)
230 progressStr := fmt.Sprintf("%s %s", status, id)
231 _ = setLog(id, progressStr, task)
232 }
233 }
234 return nil
235}
236
237func (c Client) PushImageWithProcessAndOptions(task *task.Task, imageName string, options image.PushOptions) error {
238 out, err := c.cli.ImagePush(context.Background(), imageName, options)

Callers 1

Calls 2

logProcessFunction · 0.85
setLogFunction · 0.85

Tested by

no test coverage detected