(out io.Reader, task *task.Task)
| 203 | } |
| 204 | |
| 205 | func 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 | |
| 237 | func (c Client) PushImageWithProcessAndOptions(task *task.Task, imageName string, options image.PushOptions) error { |
| 238 | out, err := c.cli.ImagePush(context.Background(), imageName, options) |
no test coverage detected