mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
37 lines
869 B
Go
37 lines
869 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/moby/moby/api/types/swarm"
|
|
)
|
|
|
|
// TaskInspectOptions contains options for inspecting a task.
|
|
type TaskInspectOptions struct {
|
|
// Currently no options are defined.
|
|
}
|
|
|
|
// TaskInspectResult contains the result of a task inspection.
|
|
type TaskInspectResult struct {
|
|
Task swarm.Task
|
|
Raw []byte
|
|
}
|
|
|
|
// TaskInspect returns the task information and its raw representation.
|
|
func (cli *Client) TaskInspect(ctx context.Context, taskID string, options TaskInspectOptions) (TaskInspectResult, error) {
|
|
taskID, err := trimID("task", taskID)
|
|
if err != nil {
|
|
return TaskInspectResult{}, err
|
|
}
|
|
|
|
resp, err := cli.get(ctx, "/tasks/"+taskID, nil, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return TaskInspectResult{}, err
|
|
}
|
|
|
|
var out TaskInspectResult
|
|
out.Raw, err = decodeWithRaw(resp, &out.Task)
|
|
return out, err
|
|
}
|