github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/client/secret_inspect.go (about) 1 package client 2 3 import ( 4 "bytes" 5 "encoding/json" 6 "io/ioutil" 7 8 "github.com/docker/docker/api/types/swarm" 9 "golang.org/x/net/context" 10 ) 11 12 // SecretInspectWithRaw returns the secret information with raw data 13 func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error) { 14 if err := cli.NewVersionError("1.25", "secret inspect"); err != nil { 15 return swarm.Secret{}, nil, err 16 } 17 resp, err := cli.get(ctx, "/secrets/"+id, nil, nil) 18 if err != nil { 19 return swarm.Secret{}, nil, wrapResponseError(err, resp, "secret", id) 20 } 21 defer ensureReaderClosed(resp) 22 23 body, err := ioutil.ReadAll(resp.body) 24 if err != nil { 25 return swarm.Secret{}, nil, err 26 } 27 28 var secret swarm.Secret 29 rdr := bytes.NewReader(body) 30 err = json.NewDecoder(rdr).Decode(&secret) 31 32 return secret, body, err 33 }