(task *task.Task, imageName string, options image.PushOptions)
| 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) |
| 239 | if err != nil { |
| 240 | return err |
| 241 | } |
| 242 | defer out.Close() |
| 243 | decoder := json.NewDecoder(out) |
| 244 | for { |
| 245 | var progress map[string]interface{} |
| 246 | if err = decoder.Decode(&progress); err != nil { |
| 247 | if err == io.EOF { |
| 248 | break |
| 249 | } |
| 250 | return err |
| 251 | } |
| 252 | if msg, ok := progress["errorDetail"]; ok { |
| 253 | return fmt.Errorf("image push failed, err: %v", msg) |
| 254 | } |
| 255 | if msg, ok := progress["error"]; ok { |
| 256 | return fmt.Errorf("image push failed, err: %v", msg) |
| 257 | } |
| 258 | status, _ := progress["status"].(string) |
| 259 | switch status { |
| 260 | case "Pushing": |
| 261 | logProcess(progress, task) |
| 262 | case "Pushed": |
| 263 | id, _ := progress["id"].(string) |
| 264 | progressStr := fmt.Sprintf("%s %s", status, id) |
| 265 | _ = setLog(id, progressStr, task) |
| 266 | default: |
| 267 | progressStr, _ := json.Marshal(progress) |
| 268 | task.Log(string(progressStr)) |
| 269 | } |
| 270 | } |
| 271 | return nil |
| 272 | } |
| 273 | |
| 274 | func (c Client) BuildImageWithProcessAndOptions(task *task.Task, tar io.ReadCloser, options types.ImageBuildOptions) error { |
| 275 | out, err := c.cli.ImageBuild(context.Background(), tar, options) |
no test coverage detected