Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 更新devops-framework到0.0.7 #73 #390

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -41,11 +41,9 @@ import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam

@FeignClient(SCANNER_SERVICE_NAME, contextId = "ScanClient")
@RequestMapping("/service/scan")
@FeignClient(SCANNER_SERVICE_NAME, contextId = "ScanClient", path = "/service/scan")
interface ScanClient {

/**
Expand Down
Expand Up @@ -39,9 +39,11 @@ import com.tencent.bkrepo.analyst.pojo.request.ScanRequest
import com.tencent.bkrepo.analyst.service.ScanService
import com.tencent.bkrepo.analyst.service.SpdxLicenseService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/service/scan")
class ScanController @Autowired constructor(
private val scanService: ScanService,
private val licenseService: SpdxLicenseService
Expand Down
Expand Up @@ -27,6 +27,15 @@

package com.tencent.bkrepo.analyst.event

import com.tencent.bkrepo.analyst.dao.ProjectScanConfigurationDao
import com.tencent.bkrepo.analyst.dao.ScanPlanDao
import com.tencent.bkrepo.analyst.pojo.ScanTriggerType
import com.tencent.bkrepo.analyst.pojo.request.ScanRequest
import com.tencent.bkrepo.analyst.pojo.rule.RuleArtifact
import com.tencent.bkrepo.analyst.service.ScanService
import com.tencent.bkrepo.analyst.service.ScannerService
import com.tencent.bkrepo.analyst.service.SpdxLicenseService
import com.tencent.bkrepo.analyst.utils.RuleConverter
import com.tencent.bkrepo.common.api.constant.CharPool
import com.tencent.bkrepo.common.api.util.readJsonString
import com.tencent.bkrepo.common.artifact.constant.PUBLIC_GLOBAL_PROJECT
Expand All @@ -37,36 +46,28 @@ import com.tencent.bkrepo.common.artifact.event.packages.VersionCreatedEvent
import com.tencent.bkrepo.common.artifact.pojo.RepositoryType
import com.tencent.bkrepo.common.query.matcher.RuleMatcher
import com.tencent.bkrepo.common.query.model.Rule
import com.tencent.bkrepo.common.service.otel.util.AsyncUtils.trace
import com.tencent.bkrepo.repository.pojo.node.NodeDetail
import com.tencent.bkrepo.repository.pojo.packages.PackageSummary
import com.tencent.bkrepo.analyst.dao.ProjectScanConfigurationDao
import com.tencent.bkrepo.analyst.dao.ScanPlanDao
import com.tencent.bkrepo.analyst.pojo.ScanTriggerType
import com.tencent.bkrepo.analyst.pojo.request.ScanRequest
import com.tencent.bkrepo.analyst.pojo.rule.RuleArtifact
import com.tencent.bkrepo.analyst.service.ScanService
import com.tencent.bkrepo.analyst.service.ScannerService
import com.tencent.bkrepo.analyst.service.SpdxLicenseService
import com.tencent.bkrepo.analyst.utils.RuleConverter
import org.slf4j.LoggerFactory
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
import org.springframework.stereotype.Component
import java.util.function.Consumer

/**
* 构件事件消费者,用于触发制品更新扫描
* 制品有新的推送时,筛选已开启自动扫描的方案进行扫描
* 对应binding name为scanEventConsumer-in-0
*/
@Component
@Configuration
class ScanEventConsumer(
private val spdxLicenseService: SpdxLicenseService,
private val scanService: ScanService,
private val scannerService: ScannerService,
private val scanPlanDao: ScanPlanDao,
private val projectScanConfigurationDao: ProjectScanConfigurationDao,
private val executor: ThreadPoolTaskExecutor
) : Consumer<ArtifactEvent> {
) {

/**
* 允许接收的事件类型
Expand All @@ -77,19 +78,20 @@ class ScanEventConsumer(
EventType.VERSION_UPDATED
)

override fun accept(event: ArtifactEvent) {
if (!acceptTypes.contains(event.type)) {
return
}

executor.execute {
when (event.type) {
EventType.NODE_CREATED -> {
scanOnNodeCreatedEvent(event)
importLicenseEvent(event)
}
EventType.VERSION_CREATED, EventType.VERSION_UPDATED -> scanOnVersionCreated(event)
else -> throw UnsupportedOperationException()
@Bean("artifactEvent")
fun artifactEvent(): (ArtifactEvent) -> Unit {
return { event ->
if (acceptTypes.contains(event.type)) {
executor.execute(Runnable {
when (event.type) {
EventType.NODE_CREATED -> {
scanOnNodeCreatedEvent(event)
importLicenseEvent(event)
}
EventType.VERSION_CREATED, EventType.VERSION_UPDATED -> scanOnVersionCreated(event)
else -> throw UnsupportedOperationException()
}
}.trace())
}
}
}
Expand Down
@@ -1,6 +1,8 @@
server.port: 25814

spring:
main:
allow-circular-references: true
application:
name: analyst
task:
Expand Down
Expand Up @@ -42,13 +42,11 @@ import org.springframework.context.annotation.Primary
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam

@Api(tags = ["SERVICE_ACCOUNT"], description = "服务-账号接口")
@Primary
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServiceAccountResource")
@RequestMapping(AUTH_SERVICE_ACCOUNT_PREFIX)
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServiceAccountResource", path = AUTH_SERVICE_ACCOUNT_PREFIX)
interface ServiceAccountResource {

@ApiOperation("校验ak/sk")
Expand Down
Expand Up @@ -34,11 +34,13 @@ import com.tencent.bkrepo.common.api.pojo.Response
import io.swagger.annotations.Api
import org.springframework.cloud.openfeign.FeignClient
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping

@Api(tags = ["SERVICE_EXTERNAL_PERMISSION"], description = "服务-外部权限接口")
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServiceExternalPermissionResource")
@RequestMapping(AUTH_SERVICE_EXT_PERMISSION_PREFIX)
@FeignClient(
AUTH_SERVICE_NAME,
contextId = "ServiceExternalPermissionResource",
path = AUTH_SERVICE_EXT_PERMISSION_PREFIX
)
interface ServiceExternalPermissionResource {

@GetMapping
Expand Down
Expand Up @@ -36,13 +36,11 @@ import io.swagger.annotations.ApiOperation
import org.springframework.cloud.openfeign.FeignClient
import org.springframework.context.annotation.Primary
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam

@Api(tags = ["SERVICE_OAUTHAUTHORIZATION"], description = "服务-Oauth授权接口")
@Primary
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServiceOauthAuthorizationResource")
@RequestMapping(AUTH_SERVICE_OAUTH_PREFIX)
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServiceOauthAuthorizationResource", path = AUTH_SERVICE_OAUTH_PREFIX)
interface ServiceOauthAuthorizationResource {

@ApiOperation("获取oauth token信息")
Expand Down
Expand Up @@ -43,13 +43,11 @@ import org.springframework.context.annotation.Primary
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam

@Api(tags = ["SERVICE_PERMISSION"], description = "服务-权限接口")
@Primary
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServicePermissionResource")
@RequestMapping(AUTH_SERVICE_PERMISSION_PREFIX)
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServicePermissionResource", path = AUTH_SERVICE_PERMISSION_PREFIX)
interface ServicePermissionResource {

@ApiOperation("list有权限仓库仓库")
Expand Down
Expand Up @@ -40,13 +40,11 @@ import io.swagger.annotations.ApiParam
import org.springframework.cloud.openfeign.FeignClient
import org.springframework.context.annotation.Primary
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam

@Api(tags = ["SERVICE_PERMISSION"], description = "服务-权限接口")
@Primary
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServicePipelineResource")
@RequestMapping(AUTH_SERVICE_PERMISSION_PREFIX)
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServicePipelineResource", path = AUTH_SERVICE_PERMISSION_PREFIX)
interface ServicePipelineResource {

@ApiOperation("获取有权限的流水线")
Expand Down
Expand Up @@ -41,12 +41,10 @@ import org.springframework.cloud.openfeign.FeignClient
import org.springframework.context.annotation.Primary
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping

@Api(tags = ["SERVICE_ROLE"], description = "服务-角色接口")
@Primary
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServiceRoleResource")
@RequestMapping(AUTH_SERVICE_ROLE_PREFIX)
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServiceRoleResource", path = AUTH_SERVICE_ROLE_PREFIX)
interface ServiceRoleResource {

@ApiOperation("创建项目管理员")
Expand Down
Expand Up @@ -44,12 +44,10 @@ import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping

@Api("临时token服务接口")
@Primary
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServiceTemporaryTokenResource")
@RequestMapping("/service/temporary/token")
interface ServiceTemporaryTokenResource {

@ApiOperation("创建临时token")
Expand Down
Expand Up @@ -46,13 +46,11 @@ import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam

@Api(tags = ["SERVICE_USER"], description = "服务-用户接口")
@Primary
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServiceUserResource")
@RequestMapping(AUTH_SERVICE_USER_PREFIX)
@FeignClient(AUTH_SERVICE_NAME, contextId = "ServiceUserResource", path = AUTH_SERVICE_USER_PREFIX)
interface ServiceUserResource {

@ApiOperation("创建用户")
Expand Down
Expand Up @@ -32,14 +32,17 @@
package com.tencent.bkrepo.auth.resource

import com.tencent.bkrepo.auth.api.ServiceAccountResource
import com.tencent.bkrepo.auth.constant.AUTH_SERVICE_ACCOUNT_PREFIX
import com.tencent.bkrepo.auth.service.AccountService
import com.tencent.bkrepo.auth.service.PermissionService
import com.tencent.bkrepo.common.api.pojo.Response
import com.tencent.bkrepo.common.service.util.ResponseBuilder
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping(AUTH_SERVICE_ACCOUNT_PREFIX)
class ServiceAccountResourceImpl @Autowired constructor(
private val accountService: AccountService,
permissionService: PermissionService
Expand Down
Expand Up @@ -28,13 +28,16 @@
package com.tencent.bkrepo.auth.resource

import com.tencent.bkrepo.auth.api.ServiceExternalPermissionResource
import com.tencent.bkrepo.auth.constant.AUTH_SERVICE_EXT_PERMISSION_PREFIX
import com.tencent.bkrepo.auth.pojo.externalPermission.ExternalPermission
import com.tencent.bkrepo.auth.service.ExternalPermissionService
import com.tencent.bkrepo.common.api.pojo.Response
import com.tencent.bkrepo.common.service.util.ResponseBuilder
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping(AUTH_SERVICE_EXT_PERMISSION_PREFIX)
class ServiceExternalPermissionResourceImpl(
private val externalPermissionService: ExternalPermissionService
): ServiceExternalPermissionResource {
Expand Down
Expand Up @@ -28,14 +28,17 @@
package com.tencent.bkrepo.auth.resource

import com.tencent.bkrepo.auth.api.ServiceOauthAuthorizationResource
import com.tencent.bkrepo.auth.constant.AUTH_SERVICE_OAUTH_PREFIX
import com.tencent.bkrepo.auth.pojo.oauth.OauthToken
import com.tencent.bkrepo.auth.service.OauthAuthorizationService
import com.tencent.bkrepo.common.api.pojo.Response
import com.tencent.bkrepo.common.service.util.ResponseBuilder
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping(AUTH_SERVICE_OAUTH_PREFIX)
class ServiceOauthAuthorizationResourceImpl @Autowired constructor(
private val oauthAuthorizationService: OauthAuthorizationService
) : ServiceOauthAuthorizationResource {
Expand Down
Expand Up @@ -32,14 +32,17 @@
package com.tencent.bkrepo.auth.resource

import com.tencent.bkrepo.auth.api.ServicePermissionResource
import com.tencent.bkrepo.auth.constant.AUTH_SERVICE_PERMISSION_PREFIX
import com.tencent.bkrepo.auth.pojo.permission.CheckPermissionRequest
import com.tencent.bkrepo.auth.service.PermissionService
import com.tencent.bkrepo.common.api.pojo.Response
import com.tencent.bkrepo.common.service.util.ResponseBuilder
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping(AUTH_SERVICE_PERMISSION_PREFIX)
class ServicePermissionResourceImpl @Autowired constructor(
private val permissionService: PermissionService
) : ServicePermissionResource, OpenResourceImpl(permissionService) {
Expand Down
Expand Up @@ -32,13 +32,16 @@
package com.tencent.bkrepo.auth.resource

import com.tencent.bkrepo.auth.api.ServicePipelineResource
import com.tencent.bkrepo.auth.constant.AUTH_SERVICE_PERMISSION_PREFIX
import com.tencent.bkrepo.auth.service.bkauth.BkAuthPipelineService
import com.tencent.bkrepo.common.api.pojo.Response
import com.tencent.bkrepo.common.service.util.ResponseBuilder
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping(AUTH_SERVICE_PERMISSION_PREFIX)
class ServicePipelineResourceImpl @Autowired constructor(
private val bkAuthPipelineService: BkAuthPipelineService
) : ServicePipelineResource {
Expand Down
Expand Up @@ -32,6 +32,7 @@
package com.tencent.bkrepo.auth.resource

import com.tencent.bkrepo.auth.api.ServiceRoleResource
import com.tencent.bkrepo.auth.constant.AUTH_SERVICE_ROLE_PREFIX
import com.tencent.bkrepo.auth.constant.PROJECT_MANAGE_ID
import com.tencent.bkrepo.auth.constant.PROJECT_MANAGE_NAME
import com.tencent.bkrepo.auth.constant.REPO_MANAGE_ID
Expand All @@ -42,9 +43,11 @@ import com.tencent.bkrepo.auth.service.RoleService
import com.tencent.bkrepo.common.api.pojo.Response
import com.tencent.bkrepo.common.service.util.ResponseBuilder
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping(AUTH_SERVICE_ROLE_PREFIX)
class ServiceRoleResourceImpl @Autowired constructor(
private val roleService: RoleService
) : ServiceRoleResource {
Expand Down
Expand Up @@ -37,12 +37,14 @@ import com.tencent.bkrepo.auth.pojo.token.TemporaryTokenInfo
import com.tencent.bkrepo.auth.service.TemporaryTokenService
import com.tencent.bkrepo.common.api.pojo.Response
import com.tencent.bkrepo.common.service.util.ResponseBuilder
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
* 临时token服务接口实现类
*/
@RestController
@RequestMapping("/service/temporary/token")
class ServiceTemporaryTokenResourceImpl(
private val temporaryTokenService: TemporaryTokenService
) : ServiceTemporaryTokenResource {
Expand Down
Expand Up @@ -32,16 +32,19 @@
package com.tencent.bkrepo.auth.resource

import com.tencent.bkrepo.auth.api.ServiceUserResource
import com.tencent.bkrepo.auth.constant.AUTH_SERVICE_USER_PREFIX
import com.tencent.bkrepo.auth.pojo.user.CreateUserRequest
import com.tencent.bkrepo.auth.pojo.user.User
import com.tencent.bkrepo.auth.pojo.user.UserInfo
import com.tencent.bkrepo.auth.service.UserService
import com.tencent.bkrepo.common.api.pojo.Response
import com.tencent.bkrepo.common.service.util.ResponseBuilder
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping(AUTH_SERVICE_USER_PREFIX)
class ServiceUserResourceImpl @Autowired constructor(
private val userService: UserService
) : ServiceUserResource {
Expand Down