Files
moby/client/swarm_inspect.go
Sebastiaan van Stijn 8f50d38231 client: SwarmInspect: add options struct
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-21 23:30:21 +02:00

32 lines
754 B
Go

package client
import (
"context"
"encoding/json"
"github.com/moby/moby/api/types/swarm"
)
// SwarmInspectOptions holds options for inspecting a swarm.
type SwarmInspectOptions struct {
// Add future optional parameters here
}
// SwarmInspectResult represents the result of a SwarmInspect operation.
type SwarmInspectResult struct {
Swarm swarm.Swarm
}
// SwarmInspect inspects the swarm.
func (cli *Client) SwarmInspect(ctx context.Context, options SwarmInspectOptions) (SwarmInspectResult, error) {
resp, err := cli.get(ctx, "/swarm", nil, nil)
defer ensureReaderClosed(resp)
if err != nil {
return SwarmInspectResult{}, err
}
var s swarm.Swarm
err = json.NewDecoder(resp.Body).Decode(&s)
return SwarmInspectResult{Swarm: s}, err
}