From b63a5810faa868c4fedd8bb64209569178cd803b Mon Sep 17 00:00:00 2001 From: bruce Date: Wed, 6 Sep 2023 11:30:36 +0800 Subject: [PATCH] feat!: Add EnableNameFieldEscape config BREAKING CHANGE: Add EnableNameFieldEscape config on the service level and allow NameFieldEscape configurable Signed-off-by: bruce --- bootstrap/handlers/clients.go | 20 ++++++++++---------- config/types.go | 4 ++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bootstrap/handlers/clients.go b/bootstrap/handlers/clients.go index 7c3ef51b..ec75e6ed 100644 --- a/bootstrap/handlers/clients.go +++ b/bootstrap/handlers/clients.go @@ -77,22 +77,22 @@ func (cb *ClientsBootstrap) BootstrapHandler( case common.CoreDataServiceKey: dic.Update(di.ServiceConstructorMap{ container.EventClientName: func(get di.Get) interface{} { - return clients.NewEventClient(url, jwtSecretProvider) + return clients.NewEventClient(url, jwtSecretProvider, config.GetBootstrap().Service.EnableNameFieldEscape) }, }) case common.CoreMetaDataServiceKey: dic.Update(di.ServiceConstructorMap{ container.DeviceClientName: func(get di.Get) interface{} { - return clients.NewDeviceClient(url, jwtSecretProvider) + return clients.NewDeviceClient(url, jwtSecretProvider, config.GetBootstrap().Service.EnableNameFieldEscape) }, container.DeviceServiceClientName: func(get di.Get) interface{} { - return clients.NewDeviceServiceClient(url, jwtSecretProvider) + return clients.NewDeviceServiceClient(url, jwtSecretProvider, config.GetBootstrap().Service.EnableNameFieldEscape) }, container.DeviceProfileClientName: func(get di.Get) interface{} { - return clients.NewDeviceProfileClient(url, jwtSecretProvider) + return clients.NewDeviceProfileClient(url, jwtSecretProvider, config.GetBootstrap().Service.EnableNameFieldEscape) }, container.ProvisionWatcherClientName: func(get di.Get) interface{} { - return clients.NewProvisionWatcherClient(url, jwtSecretProvider) + return clients.NewProvisionWatcherClient(url, jwtSecretProvider, config.GetBootstrap().Service.EnableNameFieldEscape) }, }) @@ -124,7 +124,7 @@ func (cb *ClientsBootstrap) BootstrapHandler( lc.Infof("Using messaging for '%s' clients", serviceKey) } else { - client = clients.NewCommandClient(url, jwtSecretProvider) + client = clients.NewCommandClient(url, jwtSecretProvider, config.GetBootstrap().Service.EnableNameFieldEscape) } dic.Update(di.ServiceConstructorMap{ @@ -136,20 +136,20 @@ func (cb *ClientsBootstrap) BootstrapHandler( case common.SupportNotificationsServiceKey: dic.Update(di.ServiceConstructorMap{ container.NotificationClientName: func(get di.Get) interface{} { - return clients.NewNotificationClient(url, jwtSecretProvider) + return clients.NewNotificationClient(url, jwtSecretProvider, config.GetBootstrap().Service.EnableNameFieldEscape) }, container.SubscriptionClientName: func(get di.Get) interface{} { - return clients.NewSubscriptionClient(url, jwtSecretProvider) + return clients.NewSubscriptionClient(url, jwtSecretProvider, config.GetBootstrap().Service.EnableNameFieldEscape) }, }) case common.SupportSchedulerServiceKey: dic.Update(di.ServiceConstructorMap{ container.IntervalClientName: func(get di.Get) interface{} { - return clients.NewIntervalClient(url, jwtSecretProvider) + return clients.NewIntervalClient(url, jwtSecretProvider, config.GetBootstrap().Service.EnableNameFieldEscape) }, container.IntervalActionClientName: func(get di.Get) interface{} { - return clients.NewIntervalActionClient(url, jwtSecretProvider) + return clients.NewIntervalActionClient(url, jwtSecretProvider, config.GetBootstrap().Service.EnableNameFieldEscape) }, }) diff --git a/config/types.go b/config/types.go index ccd0a62e..10bffbad 100644 --- a/config/types.go +++ b/config/types.go @@ -62,6 +62,10 @@ type ServiceInfo struct { // RequestTimeout specifies a timeout (in milliseconds) for // processing REST request calls from other services. RequestTimeout string + // EnableNameFieldEscape indicates whether enables NameFieldEscape in this service + // The name field escape could allow the system to use special or Chinese characters in the different name fields, including device, profile, and so on. If the EnableNameFieldEscape is false, some special characters might cause system error. + // TODO: remove in EdgeX 4.0 + EnableNameFieldEscape bool // CORSConfiguration defines the cross-origin resource sharing related settings CORSConfiguration CORSConfigurationInfo }