From 0defb614a44be56d303e76aeed7897d0f0711e4c Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 4 Aug 2022 15:38:04 +0200 Subject: [PATCH] docker api: use helper to parse context docker endpoint metadata Signed-off-by: CrazyMax --- commands/util.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/commands/util.go b/commands/util.go index 2239992a..e03afb8f 100644 --- a/commands/util.go +++ b/commands/util.go @@ -107,8 +107,6 @@ func driversForNodeGroup(ctx context.Context, dockerCli command.Cli, ng *store.N di.Err = err return nil } - // TODO: replace the following line with dockerclient.WithAPIVersionNegotiation option in clientForEndpoint - dockerapi.NegotiateAPIVersion(ctx) contextStore := dockerCli.ContextStore() @@ -183,13 +181,9 @@ func clientForEndpoint(dockerCli command.Cli, name string) (dockerclient.APIClie } for _, l := range list { if l.Name == name { - dep, ok := l.Endpoints["docker"] - if !ok { - return nil, errors.Errorf("context %q does not have a Docker endpoint", name) - } - epm, ok := dep.(docker.EndpointMeta) - if !ok { - return nil, errors.Errorf("endpoint %q is not of type EndpointMeta, %T", dep, dep) + epm, err := docker.EndpointFromContext(l) + if err != nil { + return nil, err } ep, err := docker.WithTLSData(dockerCli.ContextStore(), name, epm) if err != nil {