From bd94daec0ca83069d376e6ca1f5e10a4e4ac72b6 Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Sat, 16 Mar 2019 20:29:04 +0800 Subject: [PATCH] minor updates --- pkg/compute/models/cloudaccounts.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/compute/models/cloudaccounts.go b/pkg/compute/models/cloudaccounts.go index 8291d5ed29..d514765bdc 100644 --- a/pkg/compute/models/cloudaccounts.go +++ b/pkg/compute/models/cloudaccounts.go @@ -182,22 +182,24 @@ func (self *SCloudaccount) ValidateUpdateData(ctx context.Context, userCred mccl data.Set("sync_interval_seconds", jsonutils.NewInt(syncIntervalSecs)) } if data.Contains("options") || data.Contains("remove_options") { - toRemoveKeys, _ := data.GetArray("remove_options") - removes := make([]string, 0) - if len(toRemoveKeys) > 0 { - for i := range toRemoveKeys { - key, _ := toRemoveKeys[i].GetString() - removes = append(removes, key) - } - } var optionsJson *jsonutils.JSONDict if self.Options != nil { + toRemoveKeys, _ := data.GetArray("remove_options") + removes := make([]string, 0) + if len(toRemoveKeys) > 0 { + for i := range toRemoveKeys { + key, _ := toRemoveKeys[i].GetString() + removes = append(removes, key) + } + } optionsJson = self.Options.CopyExcludes(removes...) } else { optionsJson = jsonutils.NewDict() } toUpdate, _ := data.Get("options") - optionsJson.Update(toUpdate) + if toUpdate != nil { + optionsJson.Update(toUpdate) + } data.Set("options", optionsJson) } return self.SEnabledStatusStandaloneResourceBase.ValidateUpdateData(ctx, userCred, query, data)