api should return 503 when Harbor is not deployed with clair, and add more comments

This commit is contained in:
Tan Jiang 2017-06-16 15:01:14 +08:00
parent 41346fe8c0
commit 04b9ee5cfd

View File

@ -620,8 +620,13 @@ func (ra *RepositoryAPI) GetSignatures() {
ra.ServeJSON() ra.ServeJSON()
} }
//ScanImage handles //ScanImage handles request POST /api/repository/$repository/tags/$tag/scan to trigger image scan manually.
func (ra *RepositoryAPI) ScanImage() { func (ra *RepositoryAPI) ScanImage() {
if !config.WithClair() {
logger.Warningf("Harbor is not deployed with Clair, scan is disabled.")
ra.RenderError(http.StatusServiceUnavailable, "")
return
}
repoName := ra.GetString(":splat") repoName := ra.GetString(":splat")
tag := ra.GetString(":tag") tag := ra.GetString(":tag")
projectName, _ := utils.ParseRepository(repoName) projectName, _ := utils.ParseRepository(repoName)