Don't use deprecated api

Signed-off-by: David Gageot <david.gageot@docker.com>
This commit is contained in:
David Gageot 2022-10-03 14:10:15 +02:00
parent d589bd18f1
commit 4df610741d
No known key found for this signature in database
GPG Key ID: 93C3F22BE5D3A40B

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"errors" "errors"
"io" "io"
"os"
"github.com/containerd/containerd/reference" "github.com/containerd/containerd/reference"
dockertypes "github.com/docker/docker/api/types" dockertypes "github.com/docker/docker/api/types"
@ -15,13 +14,15 @@ import (
// Client get a docker client. // Client get a docker client.
func Client() (*client.Client, error) { func Client() (*client.Client, error) {
// for maximum compatibility as we use nothing new options := []client.Opt{
// 1.30 corresponds to Docker 17.06, supported until 2020. // for maximum compatibility as we use nothing new
err := os.Setenv("DOCKER_API_VERSION", "1.30") // 1.30 corresponds to Docker 17.06, supported until 2020.
if err != nil { client.WithVersion("1.30"),
return nil, err client.WithTLSClientConfigFromEnv(),
client.WithHostFromEnv(),
} }
return client.NewEnvClient()
return client.NewClientWithOpts(options...)
} }
// HasImage check if the provided ref is available in the docker cache. // HasImage check if the provided ref is available in the docker cache.