mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
commit
76cbd80ca6
@ -73,8 +73,8 @@ before_script:
|
||||
script:
|
||||
- sudo ./tests/testprepare.sh
|
||||
- docker-compose -f Deploy/docker-compose.test.yml up -d
|
||||
- go list ./... | grep -v -E 'vendor|tests|api' | xargs -L1 fgt golint
|
||||
- go list ./... | grep -v -E 'vendor|tests|api' | xargs -L1 go vet
|
||||
- go list ./... | grep -v -E 'vendor|tests' | xargs -L1 fgt golint
|
||||
- go list ./... | grep -v -E 'vendor|tests' | xargs -L1 go vet
|
||||
- IP=`ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'`
|
||||
- export MYSQL_HOST=$IP
|
||||
- export REGISTRY_URL=http://$IP:5000
|
||||
|
@ -352,38 +352,38 @@ func (pa *RepPolicyAPI) UpdateEnablement() {
|
||||
|
||||
// Delete : policies which are disabled and have no running jobs
|
||||
// can be deleted
|
||||
func (r *RepPolicyAPI) Delete() {
|
||||
id := r.GetIDFromURL()
|
||||
func (pa *RepPolicyAPI) Delete() {
|
||||
id := pa.GetIDFromURL()
|
||||
policy, err := dao.GetRepPolicy(id)
|
||||
if err != nil {
|
||||
log.Errorf("failed to get policy %d: %v", id, err)
|
||||
r.CustomAbort(http.StatusInternalServerError, "")
|
||||
pa.CustomAbort(http.StatusInternalServerError, "")
|
||||
}
|
||||
|
||||
if policy == nil || policy.Deleted == 1 {
|
||||
r.CustomAbort(http.StatusNotFound, "")
|
||||
pa.CustomAbort(http.StatusNotFound, "")
|
||||
}
|
||||
|
||||
if policy.Enabled == 1 {
|
||||
r.CustomAbort(http.StatusPreconditionFailed, "plicy is enabled, can not be deleted")
|
||||
pa.CustomAbort(http.StatusPreconditionFailed, "plicy is enabled, can not be deleted")
|
||||
}
|
||||
|
||||
jobs, err := dao.GetRepJobByPolicy(id)
|
||||
if err != nil {
|
||||
log.Errorf("failed to get jobs of policy %d: %v", id, err)
|
||||
r.CustomAbort(http.StatusInternalServerError, "")
|
||||
pa.CustomAbort(http.StatusInternalServerError, "")
|
||||
}
|
||||
|
||||
for _, job := range jobs {
|
||||
if job.Status == models.JobRunning ||
|
||||
job.Status == models.JobRetrying ||
|
||||
job.Status == models.JobPending {
|
||||
r.CustomAbort(http.StatusPreconditionFailed, "policy has running/retrying/pending jobs, can not be deleted")
|
||||
pa.CustomAbort(http.StatusPreconditionFailed, "policy has running/retrying/pending jobs, can not be deleted")
|
||||
}
|
||||
}
|
||||
|
||||
if err = dao.DeleteRepPolicy(id); err != nil {
|
||||
log.Errorf("failed to delete policy %d: %v", id, err)
|
||||
r.CustomAbort(http.StatusInternalServerError, "")
|
||||
pa.CustomAbort(http.StatusInternalServerError, "")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user