Skip to content

Commit bdd5c51

Browse files
authored
Merge pull request docker#100 from thaJeztah/use_interfaces
use docker API client interfaces instead of concrete type
2 parents e8f21cc + d5e885f commit bdd5c51

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

cmd/cli/pkg/gpu/gpu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const (
1717
)
1818

1919
// ProbeGPUSupport determines whether or not the Docker engine has GPU support.
20-
func ProbeGPUSupport(ctx context.Context, dockerClient *client.Client) (GPUSupport, error) {
20+
func ProbeGPUSupport(ctx context.Context, dockerClient client.SystemAPIClient) (GPUSupport, error) {
2121
info, err := dockerClient.Info(ctx)
2222
if err != nil {
2323
return GPUSupportNone, err

cmd/cli/pkg/standalone/containers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var concurrentInstallMatcher = regexp.MustCompile(`is already in use by containe
3030
// FindControllerContainer searches for a running controller container. It
3131
// returns the ID of the container (if found), the container name (if any), the
3232
// full container summary (if found), or any error that occurred.
33-
func FindControllerContainer(ctx context.Context, dockerClient *client.Client) (string, string, container.Summary, error) {
33+
func FindControllerContainer(ctx context.Context, dockerClient client.ContainerAPIClient) (string, string, container.Summary, error) {
3434
// Before listing, prune any stopped controller containers.
3535
if err := PruneControllerContainers(ctx, dockerClient, true, NoopPrinter()); err != nil {
3636
return "", "", container.Summary{}, fmt.Errorf("unable to prune stopped model runner containers: %w", err)
@@ -61,7 +61,7 @@ func FindControllerContainer(ctx context.Context, dockerClient *client.Client) (
6161
// determineBridgeGatewayIP attempts to identify the engine's host gateway IP
6262
// address on the bridge network. It may return an empty IP address even with a
6363
// nil error if no IP could be identified.
64-
func determineBridgeGatewayIP(ctx context.Context, dockerClient *client.Client) (string, error) {
64+
func determineBridgeGatewayIP(ctx context.Context, dockerClient client.NetworkAPIClient) (string, error) {
6565
bridge, err := dockerClient.NetworkInspect(ctx, "bridge", network.InspectOptions{})
6666
if err != nil {
6767
return "", err
@@ -75,7 +75,7 @@ func determineBridgeGatewayIP(ctx context.Context, dockerClient *client.Client)
7575
}
7676

7777
// waitForContainerToStart waits for a container to start.
78-
func waitForContainerToStart(ctx context.Context, dockerClient *client.Client, containerID string) error {
78+
func waitForContainerToStart(ctx context.Context, dockerClient client.ContainerAPIClient, containerID string) error {
7979
// Unfortunately the Docker API's /containers/{id}/wait API (and the
8080
// corresponding Client.ContainerWait method) don't allow waiting for
8181
// container startup, so instead we'll take a polling approach.
@@ -201,7 +201,7 @@ func CreateControllerContainer(ctx context.Context, dockerClient *client.Client,
201201

202202
// PruneControllerContainers stops and removes any model runner controller
203203
// containers.
204-
func PruneControllerContainers(ctx context.Context, dockerClient *client.Client, skipRunning bool, printer StatusPrinter) error {
204+
func PruneControllerContainers(ctx context.Context, dockerClient client.ContainerAPIClient, skipRunning bool, printer StatusPrinter) error {
205205
// Identify all controller containers.
206206
containers, err := dockerClient.ContainerList(ctx, container.ListOptions{
207207
All: true,

cmd/cli/pkg/standalone/images.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func controllerImageTagCUDA() string {
3939
}
4040

4141
// EnsureControllerImage ensures that the controller container image is pulled.
42-
func EnsureControllerImage(ctx context.Context, dockerClient *client.Client, gpu gpupkg.GPUSupport, printer StatusPrinter) error {
42+
func EnsureControllerImage(ctx context.Context, dockerClient client.ImageAPIClient, gpu gpupkg.GPUSupport, printer StatusPrinter) error {
4343
// Determine the target image.
4444
var imageName string
4545
switch gpu {
@@ -78,7 +78,7 @@ func EnsureControllerImage(ctx context.Context, dockerClient *client.Client, gpu
7878
}
7979

8080
// PruneControllerImages removes any unused controller container images.
81-
func PruneControllerImages(ctx context.Context, dockerClient *client.Client, printer StatusPrinter) error {
81+
func PruneControllerImages(ctx context.Context, dockerClient client.ImageAPIClient, printer StatusPrinter) error {
8282
// Remove the standard image, if present.
8383
imageNameCPU := ControllerImage + ":" + controllerImageTagCPU()
8484
if _, err := dockerClient.ImageRemove(ctx, imageNameCPU, image.RemoveOptions{}); err == nil {

cmd/cli/pkg/standalone/volumes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const modelStorageVolumeName = "docker-model-runner-models"
1515
// EnsureModelStorageVolume ensures that a model storage volume exists, creating
1616
// it if necessary. It returns the name of the storage volume or any error that
1717
// occurred.
18-
func EnsureModelStorageVolume(ctx context.Context, dockerClient *client.Client, printer StatusPrinter) (string, error) {
18+
func EnsureModelStorageVolume(ctx context.Context, dockerClient client.VolumeAPIClient, printer StatusPrinter) (string, error) {
1919
// Try to identify the storage volume.
2020
volumes, err := dockerClient.VolumeList(ctx, volume.ListOptions{
2121
Filters: filters.NewArgs(
@@ -48,7 +48,7 @@ func EnsureModelStorageVolume(ctx context.Context, dockerClient *client.Client,
4848
}
4949

5050
// PruneModelStorageVolumes removes any unused model storage volume(s).
51-
func PruneModelStorageVolumes(ctx context.Context, dockerClient *client.Client, printer StatusPrinter) error {
51+
func PruneModelStorageVolumes(ctx context.Context, dockerClient client.VolumeAPIClient, printer StatusPrinter) error {
5252
pruned, err := dockerClient.VolumesPrune(ctx, filters.NewArgs(
5353
filters.Arg("all", "true"),
5454
filters.Arg("label", labelRole+"="+roleModelStorage),

0 commit comments

Comments
 (0)