From c69fffcca6bf1bf55e0426b7c7b64a53d9cf10a6 Mon Sep 17 00:00:00 2001 From: yhua Date: Tue, 30 Aug 2016 12:35:38 +0800 Subject: [PATCH] merge code 20160830 --- .travis.yml | 4 ++-- api/replication_policy.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index c10f64fb1..7565dba06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/api/replication_policy.go b/api/replication_policy.go index 633cb9356..bcfa18791 100644 --- a/api/replication_policy.go +++ b/api/replication_policy.go @@ -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, "") } }