Skip to content

Commit

Permalink
一些bug修改
Browse files Browse the repository at this point in the history
  • Loading branch information
193721 committed Jan 2, 2023
1 parent 626146b commit 576eb6a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
5 changes: 5 additions & 0 deletions openapi/cloudapi_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,9 @@ paths:
type: string
tag:
type: string
required:
- repo
- tag
description: ''
'/project/{projectId}/containers':
parameters:
Expand Down Expand Up @@ -1661,6 +1664,8 @@ paths:
properties:
repo:
type: string
required:
- repo
security:
- Authorization: []
/captcha:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ package cn.edu.buaa.scs.controller.models
* @param repo
*/
data class DeleteProjectProjectIdImageReposRequest(
val repo: kotlin.String? = null
val repo: kotlin.String
)

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package cn.edu.buaa.scs.controller.models
* @param tag
*/
data class DeleteProjectProjectIdImagesRequest(
val repo: kotlin.String? = null,
val tag: kotlin.String? = null
val repo: kotlin.String,
val tag: kotlin.String
)

7 changes: 2 additions & 5 deletions src/main/kotlin/cn/edu/buaa/scs/harbor/HarborClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,18 @@ object HarborClient : IProjectManager {
}
}
fun deleteImageRepo(projectName:String,repositoryName: String): Result<Unit> = runCatching {
return@runCatching repoClient.deleteRepository(
repoClient.deleteRepository(
projectName = projectName,
repositoryName = repositoryName
)

}
fun deleteImage(projectName: String, repositoryName: String,reference: String ): Result<Unit> = runCatching {
return@runCatching artifactClient.deleteArtifact(
artifactClient.deleteArtifact(
projectName = projectName,
repositoryName = repositoryName,
reference = reference
)
}


override suspend fun createUser(userID: String, realName: String, email: String, password: String): Result<String> =
runCatching {
if (userClient.searchUsers(userID).isNotEmpty()) return Result.success(userID)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/cn/edu/buaa/scs/route/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fun Route.projectRoute() {
delete{
val projectID = call.getProjectID()
val req =call.receive<DeleteProjectProjectIdImagesRequest>()
call.project.deleteImage(prijectID, req.repo, req.tag)
call.project.deleteImage(projectID, req.repo, req.tag)
call.respond("OK")
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/main/kotlin/cn/edu/buaa/scs/service/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,6 @@ class ProjectService(val call: ApplicationCall) : IService, FileService.FileDeco

fun deleteImage(projectID: Long, repositoryName: String,reference: String ){
val project = Project.id(projectID)
if (!call.user().isProjectAdmin(project)) {
throw AuthorizationException("You are not the project admin")
}
HarborClient.deleteImage(project.name,repositoryName,reference)
}

Expand Down Expand Up @@ -384,9 +381,6 @@ class ProjectService(val call: ApplicationCall) : IService, FileService.FileDeco
}
fun deleteImageRepo(projectID: Long, repositoryName: String){
val project = Project.id(projectID)
if (!call.user().isProjectAdmin(project)) {
throw AuthorizationException("You are not the project admin")
}
HarborClient.deleteImageRepo(project.name,repositoryName)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/cn/edu/buaa/scs/service/User.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

-package cn.edu.buaa.scs.service
package cn.edu.buaa.scs.service

import cn.edu.buaa.scs.error.BusinessException
import cn.edu.buaa.scs.model.User
Expand Down

0 comments on commit 576eb6a

Please sign in to comment.