Delete deletes an existing container an error is returned if the container has running tasks
(ctx context.Context, opts ...DeleteOpts)
| 184 | // Delete deletes an existing container |
| 185 | // an error is returned if the container has running tasks |
| 186 | func (c *container) Delete(ctx context.Context, opts ...DeleteOpts) error { |
| 187 | ctx, span := tracing.StartSpan(ctx, "container.Delete", |
| 188 | tracing.WithAttribute("container.id", c.id), |
| 189 | ) |
| 190 | defer span.End() |
| 191 | if _, err := c.loadTask(ctx, nil); err == nil { |
| 192 | return fmt.Errorf("cannot delete running task %v: %w", c.id, errdefs.ErrFailedPrecondition) |
| 193 | } |
| 194 | r, err := c.get(ctx) |
| 195 | if err != nil { |
| 196 | return err |
| 197 | } |
| 198 | for _, o := range opts { |
| 199 | if err := o(ctx, c.client, r); err != nil { |
| 200 | return err |
| 201 | } |
| 202 | } |
| 203 | return c.client.ContainerService().Delete(ctx, c.id) |
| 204 | } |
| 205 | |
| 206 | func (c *container) Task(ctx context.Context, attach cio.Attach) (Task, error) { |
| 207 | return c.loadTask(ctx, attach) |
nothing calls this directly
no test coverage detected