gopkg.in/docker/docker.v20@v20.10.27/client/config_inspect.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "bytes" 5 "context" 6 "encoding/json" 7 "io" 8 9 "github.com/docker/docker/api/types/swarm" 10 ) 11 12 // ConfigInspectWithRaw returns the config information with raw data 13 func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) { 14 if id == "" { 15 return swarm.Config{}, nil, objectNotFoundError{object: "config", id: id} 16 } 17 if err := cli.NewVersionError("1.30", "config inspect"); err != nil { 18 return swarm.Config{}, nil, err 19 } 20 resp, err := cli.get(ctx, "/configs/"+id, nil, nil) 21 defer ensureReaderClosed(resp) 22 if err != nil { 23 return swarm.Config{}, nil, wrapResponseError(err, resp, "config", id) 24 } 25 26 body, err := io.ReadAll(resp.body) 27 if err != nil { 28 return swarm.Config{}, nil, err 29 } 30 31 var config swarm.Config 32 rdr := bytes.NewReader(body) 33 err = json.NewDecoder(rdr).Decode(&config) 34 35 return config, body, err 36 }