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