Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unified nacos user and password obtaining path #1645

Merged
merged 2 commits into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions config/config_center_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions config_center/nacos/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}),
Expand Down
4 changes: 4 additions & 0 deletions metadata/report/nacos/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down