From 3bd4c65e6afafe8802149f33d8e4020672aad3e6 Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Fri, 3 Jan 2020 16:30:30 +0800 Subject: [PATCH] fix: allow delete cloudaccount with auto-sync enabled --- pkg/compute/models/cloudaccounts.go | 7 ++++--- pkg/compute/models/cloudproviders.go | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/compute/models/cloudaccounts.go b/pkg/compute/models/cloudaccounts.go index 4d8676e4d1..ec4281aae8 100644 --- a/pkg/compute/models/cloudaccounts.go +++ b/pkg/compute/models/cloudaccounts.go @@ -163,9 +163,10 @@ func (self *SCloudaccount) getCloudprovidersInternal(enabled tristate.TriState) } func (self *SCloudaccount) ValidateDeleteCondition(ctx context.Context) error { - if self.EnableAutoSync { - return httperrors.NewInvalidStatusError("automatic syncing is enabled") - } + // allow delete cloudaccount if it is disabled + // if self.EnableAutoSync { + // return httperrors.NewInvalidStatusError("automatic syncing is enabled") + // } if self.Enabled { return httperrors.NewInvalidStatusError("account is enabled") } diff --git a/pkg/compute/models/cloudproviders.go b/pkg/compute/models/cloudproviders.go index 339a2de8b1..9e52e928ea 100644 --- a/pkg/compute/models/cloudproviders.go +++ b/pkg/compute/models/cloudproviders.go @@ -109,10 +109,11 @@ func (self *SCloudprovider) AllowDeleteItem(ctx context.Context, userCred mcclie } func (self *SCloudprovider) ValidateDeleteCondition(ctx context.Context) error { - account := self.GetCloudaccount() - if account != nil && account.EnableAutoSync { - return httperrors.NewInvalidStatusError("auto syncing is enabled on account") - } + // allow delete cloudprovider if it is disabled + // account := self.GetCloudaccount() + // if account != nil && account.EnableAutoSync { + // return httperrors.NewInvalidStatusError("auto syncing is enabled on account") + // } if self.Enabled { return httperrors.NewInvalidStatusError("provider is enabled") }