mirror of https://github.com/docker/cli.git
Change tls to TLS
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
This commit is contained in:
parent
368e309073
commit
d044b55ee0
|
@ -86,7 +86,7 @@ type Client struct {
|
||||||
// NewEnvClient initializes a new API client based on environment variables.
|
// NewEnvClient initializes a new API client based on environment variables.
|
||||||
// Use DOCKER_HOST to set the url to the docker server.
|
// Use DOCKER_HOST to set the url to the docker server.
|
||||||
// Use DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest.
|
// Use DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest.
|
||||||
// Use DOCKER_CERT_PATH to load the tls certificates from.
|
// Use DOCKER_CERT_PATH to load the TLS certificates from.
|
||||||
// Use DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default.
|
// Use DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default.
|
||||||
func NewEnvClient() (*Client, error) {
|
func NewEnvClient() (*Client, error) {
|
||||||
var client *http.Client
|
var client *http.Client
|
||||||
|
|
|
@ -102,11 +102,11 @@ func TestNewEnvClient(t *testing.T) {
|
||||||
// pedantic checking that this is handled correctly
|
// pedantic checking that this is handled correctly
|
||||||
tr := apiclient.client.Transport.(*http.Transport)
|
tr := apiclient.client.Transport.(*http.Transport)
|
||||||
if tr.TLSClientConfig == nil {
|
if tr.TLSClientConfig == nil {
|
||||||
t.Error("no tls config found when DOCKER_TLS_VERIFY enabled")
|
t.Error("no TLS config found when DOCKER_TLS_VERIFY enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
if tr.TLSClientConfig.InsecureSkipVerify {
|
if tr.TLSClientConfig.InsecureSkipVerify {
|
||||||
t.Error("tls verification should be enabled")
|
t.Error("TLS verification should be enabled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SwarmInit initializes the Swarm.
|
// SwarmInit initializes the swarm.
|
||||||
func (cli *Client) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
|
func (cli *Client) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
|
||||||
serverResp, err := cli.post(ctx, "/swarm/init", nil, req, nil)
|
serverResp, err := cli.post(ctx, "/swarm/init", nil, req, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SwarmInspect inspects the Swarm.
|
// SwarmInspect inspects the swarm.
|
||||||
func (cli *Client) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
|
func (cli *Client) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
|
||||||
serverResp, err := cli.get(ctx, "/swarm", nil, nil)
|
serverResp, err := cli.get(ctx, "/swarm", nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SwarmJoin joins the Swarm.
|
// SwarmJoin joins the swarm.
|
||||||
func (cli *Client) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
|
func (cli *Client) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
|
||||||
resp, err := cli.post(ctx, "/swarm/join", nil, req, nil)
|
resp, err := cli.post(ctx, "/swarm/join", nil, req, nil)
|
||||||
ensureReaderClosed(resp)
|
ensureReaderClosed(resp)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SwarmLeave leaves the Swarm.
|
// SwarmLeave leaves the swarm.
|
||||||
func (cli *Client) SwarmLeave(ctx context.Context, force bool) error {
|
func (cli *Client) SwarmLeave(ctx context.Context, force bool) error {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
if force {
|
if force {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SwarmUpdate updates the Swarm.
|
// SwarmUpdate updates the swarm.
|
||||||
func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
|
func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
query.Set("version", strconv.FormatUint(version.Index, 10))
|
query.Set("version", strconv.FormatUint(version.Index, 10))
|
||||||
|
|
|
@ -16,7 +16,7 @@ func (tf transportFunc) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
return tf(req)
|
return tf(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolveTLSConfig attempts to resolve the tls configuration from the
|
// resolveTLSConfig attempts to resolve the TLS configuration from the
|
||||||
// RoundTripper.
|
// RoundTripper.
|
||||||
func resolveTLSConfig(transport http.RoundTripper) *tls.Config {
|
func resolveTLSConfig(transport http.RoundTripper) *tls.Config {
|
||||||
switch tr := transport.(type) {
|
switch tr := transport.(type) {
|
||||||
|
|
Loading…
Reference in New Issue