mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	This moves the engine-api client package to `/docker/docker/client`. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
		
			
				
	
	
		
			33 lines
		
	
	
	
		
			857 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			857 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package client
 | 
						|
 | 
						|
import (
 | 
						|
	"bytes"
 | 
						|
	"encoding/json"
 | 
						|
	"io/ioutil"
 | 
						|
	"net/http"
 | 
						|
 | 
						|
	"github.com/docker/docker/api/types/swarm"
 | 
						|
	"golang.org/x/net/context"
 | 
						|
)
 | 
						|
 | 
						|
// ServiceInspectWithRaw returns the service information and the raw data.
 | 
						|
func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string) (swarm.Service, []byte, error) {
 | 
						|
	serverResp, err := cli.get(ctx, "/services/"+serviceID, nil, nil)
 | 
						|
	if err != nil {
 | 
						|
		if serverResp.statusCode == http.StatusNotFound {
 | 
						|
			return swarm.Service{}, nil, serviceNotFoundError{serviceID}
 | 
						|
		}
 | 
						|
		return swarm.Service{}, nil, err
 | 
						|
	}
 | 
						|
	defer ensureReaderClosed(serverResp)
 | 
						|
 | 
						|
	body, err := ioutil.ReadAll(serverResp.body)
 | 
						|
	if err != nil {
 | 
						|
		return swarm.Service{}, nil, err
 | 
						|
	}
 | 
						|
 | 
						|
	var response swarm.Service
 | 
						|
	rdr := bytes.NewReader(body)
 | 
						|
	err = json.NewDecoder(rdr).Decode(&response)
 | 
						|
	return response, body, err
 | 
						|
}
 |