mirror of
https://github.com/alibaba/higress.git
synced 2026-06-26 02:35:02 +08:00
fix : Add nacos username and password login option (#2170)
This commit is contained in:
@@ -84,6 +84,7 @@ type watcher struct {
|
|||||||
nacosClientConfig *constant.ClientConfig
|
nacosClientConfig *constant.ClientConfig
|
||||||
namespace string
|
namespace string
|
||||||
clusterId string
|
clusterId string
|
||||||
|
authOption provider.AuthOption
|
||||||
}
|
}
|
||||||
|
|
||||||
type WatcherOption func(w *watcher)
|
type WatcherOption func(w *watcher)
|
||||||
@@ -131,6 +132,8 @@ func NewWatcher(cache memory.Cache, opts ...WatcherOption) (provider.Watcher, er
|
|||||||
constant.WithNamespaceId(w.NacosNamespaceId),
|
constant.WithNamespaceId(w.NacosNamespaceId),
|
||||||
constant.WithAccessKey(w.NacosAccessKey),
|
constant.WithAccessKey(w.NacosAccessKey),
|
||||||
constant.WithSecretKey(w.NacosSecretKey),
|
constant.WithSecretKey(w.NacosSecretKey),
|
||||||
|
constant.WithUsername(w.authOption.NacosUsername),
|
||||||
|
constant.WithPassword(w.authOption.NacosPassword),
|
||||||
)
|
)
|
||||||
|
|
||||||
initTimer := time.NewTimer(DefaultInitTimeout)
|
initTimer := time.NewTimer(DefaultInitTimeout)
|
||||||
@@ -241,6 +244,12 @@ func WithClusterId(id string) WatcherOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithAuthOption(authOption provider.AuthOption) WatcherOption {
|
||||||
|
return func(w *watcher) {
|
||||||
|
w.authOption = authOption
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (w *watcher) Run() {
|
func (w *watcher) Run() {
|
||||||
ticker := time.NewTicker(time.Duration(w.NacosRefreshInterval))
|
ticker := time.NewTicker(time.Duration(w.NacosRefreshInterval))
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
@@ -633,6 +642,8 @@ func (w *watcher) buildServiceEntryForMcpServer(mcpServer *provider.McpServer, c
|
|||||||
constant.WithNamespaceId(serviceNamespace),
|
constant.WithNamespaceId(serviceNamespace),
|
||||||
constant.WithAccessKey(w.NacosAccessKey),
|
constant.WithAccessKey(w.NacosAccessKey),
|
||||||
constant.WithSecretKey(w.NacosSecretKey),
|
constant.WithSecretKey(w.NacosSecretKey),
|
||||||
|
constant.WithUsername(w.authOption.NacosUsername),
|
||||||
|
constant.WithPassword(w.authOption.NacosPassword),
|
||||||
)
|
)
|
||||||
client, err := clients.NewNamingClient(vo.NacosClientParam{
|
client, err := clients.NewNamingClient(vo.NacosClientParam{
|
||||||
ClientConfig: namingConfig,
|
ClientConfig: namingConfig,
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ func (r *Reconciler) generateWatcherFromRegistryConfig(registry *apiv1.RegistryC
|
|||||||
mcpserver.WithEnableMcpServer(registry.EnableMCPServer),
|
mcpserver.WithEnableMcpServer(registry.EnableMCPServer),
|
||||||
mcpserver.WithClusterId(r.clusterId),
|
mcpserver.WithClusterId(r.clusterId),
|
||||||
mcpserver.WithNamespace(r.namespace),
|
mcpserver.WithNamespace(r.namespace),
|
||||||
|
mcpserver.WithAuthOption(authOption),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
watcher, err = nacosv2.NewWatcher(
|
watcher, err = nacosv2.NewWatcher(
|
||||||
|
|||||||
Reference in New Issue
Block a user