From ead27c72f180f03bc5163d7d3e1cb63a7e768a0d Mon Sep 17 00:00:00 2001 From: yusing Date: Fri, 9 May 2025 11:37:41 +0800 Subject: [PATCH] fix(agent): typo for /distribution endpoint and update related configurations --- agent/pkg/agent/templates/agent.compose.yml | 4 +- agent/pkg/env/env.go | 58 ++++++++++----------- agent/pkg/handler/docker_handler_test.go | 8 +-- agent/pkg/handler/handler.go | 4 +- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/agent/pkg/agent/templates/agent.compose.yml b/agent/pkg/agent/templates/agent.compose.yml index 0167d62..3da60f7 100644 --- a/agent/pkg/agent/templates/agent.compose.yml +++ b/agent/pkg/agent/templates/agent.compose.yml @@ -9,7 +9,7 @@ services: AGENT_PORT: "{{.Port}}" AGENT_CA_CERT: "{{.CACert}}" AGENT_SSL_CERT: "{{.SSLCert}}" - # docker socket proxy + # docker socket proxy: [host]:port # unset DOCKER_SOCKET_ADDR to disable DOCKER_SOCKET_ADDR: 127.0.0.1:2375 POST: false @@ -21,7 +21,7 @@ services: COMMIT: false CONFIGS: false CONTAINERS: false - DISTRIBUTIONS: false + DISTRIBUTION: false EVENTS: true EXEC: false GRPC: false diff --git a/agent/pkg/env/env.go b/agent/pkg/env/env.go index f15fd88..7fe5837 100644 --- a/agent/pkg/env/env.go +++ b/agent/pkg/env/env.go @@ -21,34 +21,34 @@ var ( AgentCACert string AgentSSLCert string - DockerSocketAddr string - DockerPost bool - DockerRestarts bool - DockerStart bool - DockerStop bool - DockerAuth bool - DockerBuild bool - DockerCommit bool - DockerConfigs bool - DockerContainers bool - DockerDistributions bool - DockerEvents bool - DockerExec bool - DockerGrpc bool - DockerImages bool - DockerInfo bool - DockerNetworks bool - DockerNodes bool - DockerPing bool - DockerPlugins bool - DockerSecrets bool - DockerServices bool - DockerSession bool - DockerSwarm bool - DockerSystem bool - DockerTasks bool - DockerVersion bool - DockerVolumes bool + DockerSocketAddr string + DockerPost bool + DockerRestarts bool + DockerStart bool + DockerStop bool + DockerAuth bool + DockerBuild bool + DockerCommit bool + DockerConfigs bool + DockerContainers bool + DockerDistribution bool + DockerEvents bool + DockerExec bool + DockerGrpc bool + DockerImages bool + DockerInfo bool + DockerNetworks bool + DockerNodes bool + DockerPing bool + DockerPlugins bool + DockerSecrets bool + DockerServices bool + DockerSession bool + DockerSwarm bool + DockerSystem bool + DockerTasks bool + DockerVersion bool + DockerVolumes bool ) func init() { @@ -75,7 +75,7 @@ func Load() { DockerCommit = common.GetEnvBool("COMMIT", false) DockerConfigs = common.GetEnvBool("CONFIGS", false) DockerContainers = common.GetEnvBool("CONTAINERS", false) - DockerDistributions = common.GetEnvBool("DISTRIBUTIONS", false) + DockerDistribution = common.GetEnvBool("DISTRIBUTION", false) DockerEvents = common.GetEnvBool("EVENTS", true) DockerExec = common.GetEnvBool("EXEC", false) DockerGrpc = common.GetEnvBool("GRPC", false) diff --git a/agent/pkg/handler/docker_handler_test.go b/agent/pkg/handler/docker_handler_test.go index df9dfcd..a2e6bfb 100644 --- a/agent/pkg/handler/docker_handler_test.go +++ b/agent/pkg/handler/docker_handler_test.go @@ -236,8 +236,8 @@ func TestNewDockerHandler_PathHandling(t *testing.T) { {"Configs path", "/configs", "DockerConfigs", true, http.MethodGet, true}, {"Configs path disabled", "/configs", "DockerConfigs", false, http.MethodGet, false}, - {"Distributions path", "/distributions", "DockerDistributions", true, http.MethodGet, true}, - {"Distributions path disabled", "/distributions", "DockerDistributions", false, http.MethodGet, false}, + {"Distribution path", "/distribution", "DockerDistribution", true, http.MethodGet, true}, + {"Distribution path disabled", "/distribution", "DockerDistribution", false, http.MethodGet, false}, {"Events path", "/events", "DockerEvents", true, http.MethodGet, true}, {"Events path disabled", "/events", "DockerEvents", false, http.MethodGet, false}, @@ -320,8 +320,8 @@ func TestNewDockerHandler_PathHandling(t *testing.T) { env.DockerCommit = tt.envVarValue case "DockerConfigs": env.DockerConfigs = tt.envVarValue - case "DockerDistributions": - env.DockerDistributions = tt.envVarValue + case "DockerDistribution": + env.DockerDistribution = tt.envVarValue case "DockerEvents": env.DockerEvents = tt.envVarValue case "DockerExec": diff --git a/agent/pkg/handler/handler.go b/agent/pkg/handler/handler.go index 20b4da7..6f9de24 100644 --- a/agent/pkg/handler/handler.go +++ b/agent/pkg/handler/handler.go @@ -97,8 +97,8 @@ func NewDockerHandler() http.Handler { if env.DockerConfigs { allowedPaths = append(allowedPaths, "/configs") } - if env.DockerDistributions { - allowedPaths = append(allowedPaths, "/distributions") + if env.DockerDistribution { + allowedPaths = append(allowedPaths, "/distribution") } if env.DockerEvents { allowedPaths = append(allowedPaths, "/events")