MCPcopy
hub / github.com/nektos/act / GetHealth

Method GetHealth

pkg/container/docker_run.go:174–197  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

172}
173
174func (cr *containerReference) GetHealth(ctx context.Context) Health {
175 inspectResult, err := cr.cli.ContainerInspect(ctx, cr.id, client.ContainerInspectOptions{})
176 logger := common.Logger(ctx)
177 if err != nil {
178 logger.Errorf("failed to query container health %s", err)
179 return HealthUnHealthy
180 }
181 resp := inspectResult.Container
182 if resp.Config == nil || resp.Config.Healthcheck == nil || resp.State == nil || resp.State.Health == nil || len(resp.Config.Healthcheck.Test) == 1 && strings.EqualFold(resp.Config.Healthcheck.Test[0], "NONE") {
183 logger.Debugf("no container health check defined")
184 return HealthHealthy
185 }
186
187 logger.Infof("container health of %s (%s) is %s", cr.id, resp.Config.Image, resp.State.Health.Status)
188 switch resp.State.Health.Status {
189 case "starting":
190 return HealthStarting
191 case "healthy":
192 return HealthHealthy
193 case "unhealthy":
194 return HealthUnHealthy
195 }
196 return HealthUnHealthy
197}
198
199func (cr *containerReference) ReplaceLogWriter(stdout io.Writer, stderr io.Writer) (io.Writer, io.Writer) {
200 out := cr.input.Stdout

Callers

nothing calls this directly

Calls 1

LoggerFunction · 0.92

Tested by

no test coverage detected