mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-05-06 22:12:23 +08:00
Improve maintainability by using constant for Docker API version
Extracted hardcoded API version into a named constant `dockerAPIVersion` for better maintainability. Co-authored-by: 0xJacky <13096985+0xJacky@users.noreply.github.com>
This commit is contained in:
@@ -6,13 +6,17 @@ import (
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
// dockerAPIVersion specifies the Docker API version to use for all client operations.
|
||||
// Version 1.41 is stable and widely supported, ensuring compatibility with archive endpoints
|
||||
// used by ContainerStatPath and other container operations.
|
||||
const dockerAPIVersion = "1.41"
|
||||
|
||||
// Initialize Docker client from environment variables
|
||||
// Uses API version 1.41 explicitly to ensure compatibility with archive endpoints
|
||||
// API version 1.41 is stable and widely supported across Docker versions
|
||||
// Uses explicit API version to ensure compatibility with archive endpoints
|
||||
func initClient() (cli *client.Client, err error) {
|
||||
// Use explicit API version instead of negotiation to avoid compatibility issues
|
||||
// with endpoints like ContainerStatPath that may not be available in all API versions
|
||||
cli, err = client.NewClientWithOpts(client.FromEnv, client.WithVersion("1.41"))
|
||||
cli, err = client.NewClientWithOpts(client.FromEnv, client.WithVersion(dockerAPIVersion))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user