Skip to content

Commit

Permalink
Merge pull request #594 from weichou1229/name-escape
Browse files Browse the repository at this point in the history
feat!: Add EnableNameFieldEscape config
  • Loading branch information
cloudxxx8 authored Sep 13, 2023
2 parents ff44a32 + 798cb5d commit 6eaa9ae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
20 changes: 10 additions & 10 deletions bootstrap/handlers/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
})

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

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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
github.com/eclipse/paho.mqtt.golang v1.4.3
github.com/edgexfoundry/go-mod-configuration/v3 v3.1.0-dev.5
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.1.0-dev.9
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.1.0-dev.11
github.com/edgexfoundry/go-mod-messaging/v3 v3.1.0-dev.20
github.com/edgexfoundry/go-mod-registry/v3 v3.1.0-dev.5
github.com/edgexfoundry/go-mod-secrets/v3 v3.1.0-dev.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQ
github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE=
github.com/edgexfoundry/go-mod-configuration/v3 v3.1.0-dev.5 h1:wTs2qOG/RHeizCHcPp8KOQcSzGrvNOhVQnK+JdAHJNs=
github.com/edgexfoundry/go-mod-configuration/v3 v3.1.0-dev.5/go.mod h1:mZyBGQ7eX+K63b46/K/OdiWSHtYbl/TK2GTfc0eOM6Q=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.1.0-dev.9 h1:ZvCeuB1CXzNzg2WhpLCEKhkPSZpS0Geoh0AqTbj08X4=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.1.0-dev.9/go.mod h1:L7i97+A+bMpvXFo1M6t0WHeRrsSocTgDEl3ayfVxCmo=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.1.0-dev.11 h1:vYzWq4xbJJ4LVkagj+/01UOD8x4HZTK5k2x7EZh9ZjQ=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.1.0-dev.11/go.mod h1:MztlrH+8hPRX6XNZrbdvbV0RNgkoAN1etcvAtgSHeuQ=
github.com/edgexfoundry/go-mod-messaging/v3 v3.1.0-dev.20 h1:iKhaDrfN0plO95MjPmrOEhfiUrE9gMD9Os7odtOrM10=
github.com/edgexfoundry/go-mod-messaging/v3 v3.1.0-dev.20/go.mod h1:cD3WRffguDrR/G7dIyzYewfoOk44VlJfGSkgbuUzvYM=
github.com/edgexfoundry/go-mod-registry/v3 v3.1.0-dev.5 h1:Xu1Jxk8gjMGMROqOf2C5pLY6lx1nWNYSDife2d623UE=
Expand Down

0 comments on commit 6eaa9ae

Please sign in to comment.