Skip to content

Commit

Permalink
Merge pull request #4949 from sawyersong2/issue4946_github_branch
Browse files Browse the repository at this point in the history
feat: dockerhost根据gatewaytag路由流量 #4946
  • Loading branch information
irwinsun authored Aug 17, 2021
2 parents a13dc12 + 8a2d725 commit 8958ac5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -144,9 +145,9 @@ abstract class AbstractBuildResourceApi constructor(
}

private fun getAllHeaders(headers: Map<String, String>): Map<String, String> {
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)
Expand Down

0 comments on commit 8958ac5

Please sign in to comment.