From 8a2d725595eacf528ae452fc9e85f1fb5487f910 Mon Sep 17 00:00:00 2001 From: sawyersong2 Date: Mon, 16 Aug 2021 14:50:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20dockerhost=E6=A0=B9=E6=8D=AEgatewaytag?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E6=B5=81=E9=87=8F=20#4946?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/dockerhost/config/DockerHostConfig.kt | 4 ++-- .../devops/dockerhost/dispatch/AbstractBuildResourceApi.kt | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/config/DockerHostConfig.kt b/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/config/DockerHostConfig.kt index 7565db0f15d..a990dc87fdb 100644 --- a/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/config/DockerHostConfig.kt +++ b/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/config/DockerHostConfig.kt @@ -190,8 +190,8 @@ class DockerHostConfig { @Value("\${dockerhost.dispatch.urlPrefix:ms/dispatch-docker}") var dispatchUrlPrefix: String? = "ms/dispatch-docker" - @Value("\${dockerhost.gatewayHeaderProject:#{null}}") - var gatewayHeaderProject: String? = null + @Value("\${dockerhost.gatewayHeaderTag:#{null}}") + var gatewayHeaderTag: String? = null @Value("\${dockerhost.localIp:#{null}}") var dockerhostLocalIp: String? = null diff --git a/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/dispatch/AbstractBuildResourceApi.kt b/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/dispatch/AbstractBuildResourceApi.kt index fc2e8950108..7e8cf416866 100644 --- a/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/dispatch/AbstractBuildResourceApi.kt +++ b/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/dispatch/AbstractBuildResourceApi.kt @@ -31,6 +31,7 @@ import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_AGENT_ID import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_AGENT_SECRET_KEY import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_BUILD_TYPE import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_PROJECT_ID +import com.tencent.devops.common.api.auth.AUTH_HEADER_GATEWAY_TAG import com.tencent.devops.common.api.util.JsonUtil import com.tencent.devops.dockerhost.common.Constants import com.tencent.devops.dockerhost.config.DockerHostConfig @@ -144,9 +145,9 @@ abstract class AbstractBuildResourceApi constructor( } private fun getAllHeaders(headers: Map): Map { - if (dockerHostConfig.gatewayHeaderProject != null) { - logger.info("Now is ${dockerHostConfig.gatewayHeaderProject} environment, request with the x-devops-project-id header.") - return buildArgs.plus(headers).plus(mapOf(AUTH_HEADER_DEVOPS_PROJECT_ID to dockerHostConfig.gatewayHeaderProject!!)) + if (dockerHostConfig.gatewayHeaderTag != null) { + logger.info("Now is ${dockerHostConfig.gatewayHeaderTag} environment, request with the AUTH_HEADER_GATEWAY_TAG header.") + return buildArgs.plus(headers).plus(mapOf(AUTH_HEADER_GATEWAY_TAG to dockerHostConfig.gatewayHeaderTag!!)) } return buildArgs.plus(headers)