From eb3d0fc78dc03e389ca920143469e006dc2dd5f2 Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Thu, 14 Oct 2021 15:22:24 +0800 Subject: [PATCH] fix(region): google rds tags sync --- pkg/multicloud/google/dbinstance.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pkg/multicloud/google/dbinstance.go b/pkg/multicloud/google/dbinstance.go index 8ba9276081..d9835a28a1 100644 --- a/pkg/multicloud/google/dbinstance.go +++ b/pkg/multicloud/google/dbinstance.go @@ -118,6 +118,7 @@ type SDBInstanceSetting struct { StorageAutoResize bool DataDiskSizeGb int DatabaseFlags []SDBInstanceParameter + UserLabels map[string]string } type SDBInstanceIpAddress struct { @@ -138,7 +139,6 @@ type SDBInstanceCaCert struct { type SDBInstance struct { multicloud.SDBInstanceBase - multicloud.GoogleTags region *SRegion Kind string @@ -628,3 +628,21 @@ func (region *SRegion) CreateDBInstance(desc *cloudprovider.SManagedDBInstanceCr } return rds, nil } + +func (self *SDBInstance) GetTags() (map[string]string, error) { + return self.Settings.UserLabels, nil +} + +func (self *SDBInstance) GetSysTags() map[string]string { + return nil +} + +func (self *SDBInstance) SetTags(tags map[string]string, replace bool) error { + params := map[string]interface{}{ + "settings": map[string]interface{}{ + "userLabels": tags, + }, + } + err := self.region.rdsPatch(self.GetId(), jsonutils.Marshal(params)) + return errors.Wrapf(err, "rdsPatch") +}