dockerutil

package
v5.31.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package dockerutil provides Docker client lifecycle management utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDockerClient

func WithDockerClient(cmd *cobra.Command, operation func(client.APIClient) error) error

WithDockerClient creates a Docker client, executes the given operation function, and ensures cleanup. The Docker client is automatically closed after the operation completes, regardless of success or failure.

This function is suitable for production use. For testing with mock clients, use WithDockerClientInstance instead.

Returns an error if client creation fails or if the operation function returns an error.

func WithDockerClientInstance

func WithDockerClientInstance(
	cmd *cobra.Command,
	dockerClient client.APIClient,
	operation func(client.APIClient) error,
) error

WithDockerClientInstance executes an operation with a provided Docker client and handles cleanup. The client will be closed after the operation completes, even if the operation returns an error.

This function is particularly useful for testing with mock clients, as it allows you to provide a pre-configured client instance. Any error during client cleanup is logged but does not cause the function to return an error if the operation itself succeeded.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL