mirror of
https://github.com/moby/moby.git
synced 2026-01-11 02:31:44 +00:00
For methods using the decodeWithRaw utility, we were handling closing of the body twice. The ensureReaderClosed utility also drains the response to let the transport reuse the connnection. Let's use that utility in decodeWithRaw as well. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
36 lines
875 B
Go
36 lines
875 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/moby/moby/api/types/swarm"
|
|
)
|
|
|
|
// ConfigInspectOptions holds options for inspecting a config.
|
|
type ConfigInspectOptions struct {
|
|
// Add future optional parameters here
|
|
}
|
|
|
|
// ConfigInspectResult holds the result from the ConfigInspect method.
|
|
type ConfigInspectResult struct {
|
|
Config swarm.Config
|
|
Raw json.RawMessage
|
|
}
|
|
|
|
// ConfigInspect returns the config information with raw data
|
|
func (cli *Client) ConfigInspect(ctx context.Context, id string, options ConfigInspectOptions) (ConfigInspectResult, error) {
|
|
id, err := trimID("config", id)
|
|
if err != nil {
|
|
return ConfigInspectResult{}, err
|
|
}
|
|
resp, err := cli.get(ctx, "/configs/"+id, nil, nil)
|
|
if err != nil {
|
|
return ConfigInspectResult{}, err
|
|
}
|
|
|
|
var out ConfigInspectResult
|
|
out.Raw, err = decodeWithRaw(resp, &out.Config)
|
|
return out, err
|
|
}
|