Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/TencentBlueKing/bk-repo i…
Browse files Browse the repository at this point in the history
…nto issue_2898
  • Loading branch information
owenlxu committed Jan 6, 2025
2 parents b9fc954 + b2f4d42 commit ff2bfea
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,13 @@ data class DevXProperties(
var authToken: String = "",

/**
* 搜索云桌面接口url
* 查询团队云桌面接口url
*/
var workspaceSearchUrl: String = "",
var groupWorkspaceUrl: String = "",

/**
* 查询个人云桌面接口url
*/
var personalWorkspaceUrl: String = "",

)
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
package com.tencent.bkrepo.websocket.service

import com.tencent.bkrepo.auth.pojo.enums.PermissionAction
import com.tencent.bkrepo.common.api.constant.HttpHeaders
import com.tencent.bkrepo.common.api.constant.MediaTypes
import com.tencent.bkrepo.common.api.constant.StringPool
import com.tencent.bkrepo.common.api.util.readJsonString
import com.tencent.bkrepo.common.api.util.toJsonString
import com.tencent.bkrepo.common.metadata.permission.PermissionManager
Expand Down Expand Up @@ -86,24 +85,34 @@ class ClipboardService(
if (userId != copyPDU.userId) {
throw PermissionException("can't send copy pdu with userId[${copyPDU.userId}]")
}
if (devXProperties.workspaceSearchUrl.isEmpty()) {
if (devXProperties.groupWorkspaceUrl.isEmpty() || devXProperties.personalWorkspaceUrl.isEmpty()) {
return null
}
return if (copyPDU.projectId.startsWith(StringPool.UNDERSCORE)) {
checkWorkspace(devXProperties.personalWorkspaceUrl, copyPDU)
} else {
checkWorkspace(devXProperties.groupWorkspaceUrl, copyPDU)
}
}

private fun checkWorkspace(url: String, copyPDU: CopyPDU): String? {
val userId = copyPDU.userId
val apiAuth = ApiAuth(devXProperties.appCode, devXProperties.appSecret)
val token = apiAuth.toJsonString().replace(System.lineSeparator(), "")
val request = Request.Builder().url(
"${devXProperties.workspaceSearchUrl}?projectId=${copyPDU.projectId}&workspaceName=${copyPDU.workspaceName}"
"$url?projectId=${copyPDU.projectId}&workspaceName=${copyPDU.workspaceName}"
)
.header("X-Bkapi-Authorization", token)
.header("X-Devops-Uid", userId)
.header(HttpHeaders.CONTENT_TYPE, MediaTypes.APPLICATION_JSON)
.get()
.build()
try {
httpClient.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
logger.error("request url failed: " +
"${request.url}, ${response.code}, ${response.headers["X-Devops-RID"]}")
logger.error(
"request url failed: " +
"${request.url}, ${response.code}, ${response.headers["X-Devops-RID"]}"
)
return null
}
val workspace = response.body!!.string().readJsonString<Response<DevXWorkSpace>>().data
Expand Down
2 changes: 1 addition & 1 deletion support-files/kubernetes/images/backend/preview.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM blueking/bk-repo-preview-base:0.0.1
FROM bkrepo/bkrepo-preview-base:0.0.1

LABEL maintainer="Tencent BlueKing Devops"

Expand Down

0 comments on commit ff2bfea

Please sign in to comment.