github.com/lacework-dev/go-moby@v20.10.12+incompatible/client/secret_inspect.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "bytes" 5 "context" 6 "encoding/json" 7 "io/ioutil" 8 9 "github.com/docker/docker/api/types/swarm" 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 if id == "" { 18 return swarm.Secret{}, nil, objectNotFoundError{object: "secret", id: id} 19 } 20 resp, err := cli.get(ctx, "/secrets/"+id, nil, nil) 21 defer ensureReaderClosed(resp) 22 if err != nil { 23 return swarm.Secret{}, nil, wrapResponseError(err, resp, "secret", id) 24 } 25 26 body, err := ioutil.ReadAll(resp.body) 27 if err != nil { 28 return swarm.Secret{}, nil, err 29 } 30 31 var secret swarm.Secret 32 rdr := bytes.NewReader(body) 33 err = json.NewDecoder(rdr).Decode(&secret) 34 35 return secret, body, err 36 }