mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +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
886 B
Go
36 lines
886 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/moby/moby/api/types/swarm"
|
|
)
|
|
|
|
// SecretInspectOptions holds options for inspecting a secret.
|
|
type SecretInspectOptions struct {
|
|
// Add future optional parameters here
|
|
}
|
|
|
|
// SecretInspectResult holds the result from the [Client.SecretInspect]. method.
|
|
type SecretInspectResult struct {
|
|
Secret swarm.Secret
|
|
Raw json.RawMessage
|
|
}
|
|
|
|
// SecretInspect returns the secret information with raw data.
|
|
func (cli *Client) SecretInspect(ctx context.Context, id string, options SecretInspectOptions) (SecretInspectResult, error) {
|
|
id, err := trimID("secret", id)
|
|
if err != nil {
|
|
return SecretInspectResult{}, err
|
|
}
|
|
resp, err := cli.get(ctx, "/secrets/"+id, nil, nil)
|
|
if err != nil {
|
|
return SecretInspectResult{}, err
|
|
}
|
|
|
|
var out SecretInspectResult
|
|
out.Raw, err = decodeWithRaw(resp, &out.Secret)
|
|
return out, err
|
|
}
|