You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/12/05 09:43:38 UTC
[dubbo-go] branch 3.0 updated: unified nacos user and password obtaining path (#1645)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 87dd52c unified nacos user and password obtaining path (#1645)
87dd52c is described below
commit 87dd52c2cf3657869ac73c675a20e6739255263e
Author: binbin.zhang <bb...@163.com>
AuthorDate: Sun Dec 5 17:43:32 2021 +0800
unified nacos user and password obtaining path (#1645)
Co-authored-by: LaurenceLiZhixin <38...@qq.com>
---
config/config_center_config.go | 8 +++++---
config_center/nacos/impl.go | 4 ++--
metadata/report/nacos/report.go | 4 ++++
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/config/config_center_config.go b/config/config_center_config.go
index 778e644..9ad399e 100644
--- a/config/config_center_config.go
+++ b/config/config_center_config.go
@@ -94,8 +94,6 @@ func (c *CenterConfig) GetUrlMap() url.Values {
urlMap.Set(constant.ConfigGroupKey, c.Group)
urlMap.Set(constant.ConfigClusterKey, c.Cluster)
urlMap.Set(constant.ConfigAppIDKey, c.AppID)
- urlMap.Set(constant.ConfigUsernameKey, c.Username)
- urlMap.Set(constant.ConfigPasswordKey, c.Password)
urlMap.Set(constant.ConfigTimeoutKey, c.Timeout)
for key, val := range c.Params {
@@ -124,7 +122,11 @@ func (c *CenterConfig) translateConfigAddress() string {
func (c *CenterConfig) toURL() (*common.URL, error) {
return common.NewURL(c.Address,
common.WithProtocol(c.Protocol),
- common.WithParams(c.GetUrlMap()))
+ common.WithParams(c.GetUrlMap()),
+ common.WithUsername(c.Username),
+ common.WithPassword(c.Password),
+ )
+
}
// startConfigCenter will start the config center.
diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go
index 7538375..4d044d2 100644
--- a/config_center/nacos/impl.go
+++ b/config_center/nacos/impl.go
@@ -64,12 +64,12 @@ type nacosDynamicConfiguration struct {
func newNacosDynamicConfiguration(url *common.URL) (*nacosDynamicConfiguration, error) {
url.SetParam(constant.NacosNamespaceID, url.GetParam(constant.ConfigNamespaceKey, ""))
- url.SetParam(constant.NacosUsername, url.GetParam(constant.ConfigUsernameKey, ""))
+ url.SetParam(constant.NacosUsername, url.Username)
+ url.SetParam(constant.NacosPassword, url.Password)
url.SetParam(constant.NacosAccessKey, url.GetParam(constant.ConfigAccessKey, ""))
url.SetParam(constant.NacosSecretKey, url.GetParam(constant.ConfigSecretKey, ""))
url.SetParam(constant.TimeoutKey, url.GetParam(constant.ConfigTimeoutKey, ""))
url.SetParam(constant.NacosGroupKey, url.GetParam(constant.ConfigGroupKey, constant2.DEFAULT_GROUP))
- url.SetParam(constant.NacosNamespaceID, url.GetParam(constant.ConfigNamespaceKey, ""))
c := &nacosDynamicConfiguration{
url: url,
done: make(chan struct{}),
diff --git a/metadata/report/nacos/report.go b/metadata/report/nacos/report.go
index 1118ed8..3f20fc3 100644
--- a/metadata/report/nacos/report.go
+++ b/metadata/report/nacos/report.go
@@ -256,6 +256,10 @@ type nacosMetadataReportFactory struct{}
// nolint
func (n *nacosMetadataReportFactory) CreateMetadataReport(url *common.URL) report.MetadataReport {
url.SetParam(constant.NacosNamespaceID, url.GetParam(constant.MetadataReportNamespaceKey, ""))
+ url.SetParam(constant.TimeoutKey, url.GetParam(constant.TimeoutKey, constant.DefaultRegTimeout))
+ url.SetParam(constant.NacosGroupKey, url.GetParam(constant.MetadataReportGroupKey, constant.ServiceDiscoveryDefaultGroup))
+ url.SetParam(constant.NacosUsername, url.Username)
+ url.SetParam(constant.NacosPassword, url.Password)
client, err := nacos.NewNacosConfigClientByUrl(url)
if err != nil {
logger.Errorf("Could not create nacos metadata report. URL: %s", url.String())