Add volume API/CLI

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2015-06-12 09:25:32 -04:00
parent 01fe6537f1
commit 1858b15498
2 changed files with 13 additions and 5 deletions

View file

@ -15,10 +15,19 @@ import (
) )
const ( const (
versionMimetype = "application/vnd.docker.plugins.v1+json" versionMimetype = "application/vnd.docker.plugins.v1.1+json"
defaultTimeOut = 30 defaultTimeOut = 30
) )
type remoteError struct {
method string
err string
}
func (e *remoteError) Error() string {
return fmt.Sprintf("Plugin Error: %s, %s", e.err, e.method)
}
// NewClient creates a new plugin client (http). // NewClient creates a new plugin client (http).
func NewClient(addr string, tlsConfig tlsconfig.Options) (*Client, error) { func NewClient(addr string, tlsConfig tlsconfig.Options) (*Client, error) {
tr := &http.Transport{} tr := &http.Transport{}
@ -84,9 +93,9 @@ func (c *Client) callWithRetry(serviceMethod string, args interface{}, ret inter
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
remoteErr, err := ioutil.ReadAll(resp.Body) remoteErr, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("Plugin Error: %s", err) return &remoteError{err.Error(), serviceMethod}
} }
return fmt.Errorf("Plugin Error: %s", remoteErr) return &remoteError{string(remoteErr), serviceMethod}
} }
return json.NewDecoder(resp.Body).Decode(&ret) return json.NewDecoder(resp.Body).Decode(&ret)

View file

@ -7,7 +7,6 @@ import (
"go/parser" "go/parser"
"go/token" "go/token"
"reflect" "reflect"
"strings"
) )
var ErrBadReturn = errors.New("found return arg with no name: all args must be named") var ErrBadReturn = errors.New("found return arg with no name: all args must be named")
@ -39,7 +38,7 @@ type arg struct {
} }
func (a *arg) String() string { func (a *arg) String() string {
return strings.ToLower(a.Name) + " " + strings.ToLower(a.ArgType) return a.Name + " " + a.ArgType
} }
// Parses the given file for an interface definition with the given name // Parses the given file for an interface definition with the given name