Call plugins with custom transports.

Small refactor to be able to use custom transports
to call remote plugins.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera 2016-03-01 20:16:40 -05:00
parent 98943aafae
commit 44005e59d4
5 changed files with 123 additions and 23 deletions

View file

@ -4,10 +4,12 @@ import (
"io"
"net/http"
"net/http/httptest"
"net/url"
"reflect"
"testing"
"time"
"github.com/docker/docker/pkg/plugins/transport"
"github.com/docker/go-connections/tlsconfig"
)
@ -48,7 +50,7 @@ func TestEchoInputOutput(t *testing.T) {
}
header := w.Header()
header.Set("Content-Type", versionMimetype)
header.Set("Content-Type", transport.VersionMimetype)
io.Copy(w, r.Body)
})
@ -119,9 +121,14 @@ func TestClientScheme(t *testing.T) {
}
for addr, scheme := range cases {
c, _ := NewClient(addr, tlsconfig.Options{InsecureSkipVerify: true})
if c.scheme != scheme {
t.Fatalf("URL scheme mismatch, expected %s, got %s", scheme, c.scheme)
u, err := url.Parse(addr)
if err != nil {
t.Fatal(err)
}
s := httpScheme(u)
if s != scheme {
t.Fatalf("URL scheme mismatch, expected %s, got %s", scheme, s)
}
}
}