github.com/LazyboyChen7/engine@v17.12.1-ce-rc2+incompatible/client/config_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 // ConfigInspectWithRaw returns the config information with raw data 13 func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) { 14 if err := cli.NewVersionError("1.30", "config inspect"); err != nil { 15 return swarm.Config{}, nil, err 16 } 17 resp, err := cli.get(ctx, "/configs/"+id, nil, nil) 18 if err != nil { 19 return swarm.Config{}, nil, wrapResponseError(err, resp, "config", id) 20 } 21 defer ensureReaderClosed(resp) 22 23 body, err := ioutil.ReadAll(resp.body) 24 if err != nil { 25 return swarm.Config{}, nil, err 26 } 27 28 var config swarm.Config 29 rdr := bytes.NewReader(body) 30 err = json.NewDecoder(rdr).Decode(&config) 31 32 return config, body, err 33 }