Documentation
¶
Overview ¶
Package docker provides Docker client lifecycle management for CLI commands.
This package contains utilities for creating and managing Docker client connections with automatic cleanup, suitable for use in Cobra command handlers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithClient ¶
WithClient 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 WithClientInstance instead.
Returns an error if client creation fails or if the operation function returns an error.
func WithClientInstance ¶
func WithClientInstance( cmd *cobra.Command, dockerClient client.APIClient, operation func(client.APIClient) error, ) error
WithClientInstance 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.