Skip to content

Commit

Permalink
feat!: Add EnableNameFieldEscape config
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Add EnableNameFieldEscape config on the service level and allow NameFieldEscape configurable

Signed-off-by: bruce <[email protected]>
  • Loading branch information
weichou1229 committed Sep 7, 2023
1 parent f8054bb commit d9b1415
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 10 additions & 10 deletions bootstrap/handlers/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,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)
},
})

Expand Down Expand Up @@ -127,7 +127,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{
Expand All @@ -139,20 +139,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)
},
})

Expand Down
4 changes: 4 additions & 0 deletions config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d9b1415

Please sign in to comment.