MCPcopy
hub / github.com/google/cadvisor / GetExitCode

Method GetExitCode

container/docker/handler.go:420–432  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

418}
419
420func (h *containerHandler) GetExitCode() (int, error) {
421 res, err := h.client.ContainerInspect(context.Background(), h.reference.Id, dclient.ContainerInspectOptions{})
422 if err != nil {
423 return -1, fmt.Errorf("failed to inspect container %s: %w", h.reference.Id, err)
424 }
425 ctnr := res.Container
426
427 if ctnr.State.Running {
428 return -1, fmt.Errorf("container %s is still running", h.reference.Id)
429 }
430
431 return ctnr.State.ExitCode, nil
432}

Callers 1

TestGetExitCodeFunction · 0.95

Calls 2

ContainerInspectMethod · 0.80
ErrorfMethod · 0.80

Tested by 1

TestGetExitCodeFunction · 0.76