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

Method PushImageWithProcessAndOptions

agent/utils/docker/docker.go:237–272  ·  view source on GitHub ↗
(task *task.Task, imageName string, options image.PushOptions)

Source from the content-addressed store, hash-verified

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)
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
274func (c Client) BuildImageWithProcessAndOptions(task *task.Task, tar io.ReadCloser, options types.ImageBuildOptions) error {
275 out, err := c.cli.ImageBuild(context.Background(), tar, options)

Callers 1

ImagePushMethod · 0.80

Implementers 1

terminalAIClientagent/utils/terminal/ai/client.go

Calls 5

logProcessFunction · 0.85
setLogFunction · 0.85
ImagePushMethod · 0.65
CloseMethod · 0.65
LogMethod · 0.45

Tested by

no test coverage detected