From 67a5401ff952580c6db3464a4937881ff020b40d Mon Sep 17 00:00:00 2001 From: Leonard Goodell Date: Fri, 10 Mar 2023 06:49:49 -0700 Subject: [PATCH] feat: Consume watch for common Writable config changes Signed-off-by: Leonard Goodell --- go.mod | 2 +- go.sum | 4 ++-- internal/core/command/config/config.go | 5 +++++ internal/core/data/config/config.go | 5 +++++ internal/core/metadata/config/config.go | 5 +++++ internal/security/bootstrapper/config/config.go | 6 ++++++ internal/security/bootstrapper/mosquitto/config/config.go | 6 ++++++ internal/security/bootstrapper/redis/config/config.go | 6 ++++++ internal/security/common/tokenpolicy_test.go | 2 -- internal/security/fileprovider/config/config.go | 6 ++++++ internal/security/fileprovider/util_test.go | 2 -- internal/security/proxyauth/config/config.go | 5 +++++ internal/security/secretstore/config/config.go | 6 ++++++ internal/security/spiffetokenprovider/config/config.go | 5 +++++ internal/support/notifications/config/config.go | 5 +++++ internal/support/scheduler/config/config.go | 5 +++++ 16 files changed, 68 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 4ba7a361e0..cb193a34a1 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/edgexfoundry/edgex-go require ( github.com/eclipse/paho.mqtt.golang v1.4.2 - github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.41 + github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.44 github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7 github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.27 github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.16 diff --git a/go.sum b/go.sum index a285d98554..7425bc2d80 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/eclipse/paho.mqtt.golang v1.4.2 h1:66wOzfUHSSI1zamx7jR6yMEI5EuHnT1G6rNA5PM12m4= github.com/eclipse/paho.mqtt.golang v1.4.2/go.mod h1:JGt0RsEwEX+Xa/agj90YJ9d9DH2b7upDZMK9HRbFvCA= -github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.41 h1:eBWdDMOvYHiHtG/ne3caTfVawk+j4BzkU/UW6XOMqBk= -github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.41/go.mod h1:qiG4HABtB+mnFBOby/ZUpIWcQD0TZa8jIG7p/jeVuzc= +github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.44 h1:bzROMV3XZzFB5uBFTeQRuqBQyHE8DJjHSl3UWoqacds= +github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.44/go.mod h1:qiG4HABtB+mnFBOby/ZUpIWcQD0TZa8jIG7p/jeVuzc= github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7 h1:pOH2GLDg1KB4EmAzo6IEvl4NEVFAw3ywxPUMa5Wi1Vw= github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7/go.mod h1:ZZbOu7K0/P8B1VKhZygVujLQyhvWuPe0E2vC/k2yscw= github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.27 h1:lKM/NwRBL/pddoSnlXbFIlpgu+XozWbqz608EeB7S94= diff --git a/internal/core/command/config/config.go b/internal/core/command/config/config.go index f15d7532f8..dfa9d5ea3f 100644 --- a/internal/core/command/config/config.go +++ b/internal/core/command/config/config.go @@ -54,6 +54,11 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return &WritableInfo{} } +// GetWritablePtr returns pointer to the writable section +func (c *ConfigurationStruct) GetWritablePtr() any { + return &c.Writable +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific WritableInfo struct // which is then used to overwrite the service's existing configuration's WritableInfo struct. func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) bool { diff --git a/internal/core/data/config/config.go b/internal/core/data/config/config.go index 79887ac6d6..0e956b31a5 100644 --- a/internal/core/data/config/config.go +++ b/internal/core/data/config/config.go @@ -52,6 +52,11 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return &WritableInfo{} } +// GetWritablePtr returns pointer to the writable section +func (c *ConfigurationStruct) GetWritablePtr() any { + return &c.Writable +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific WritableInfo struct // which is then used to overwrite the service's existing configuration's WritableInfo struct. func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) bool { diff --git a/internal/core/metadata/config/config.go b/internal/core/metadata/config/config.go index cb8bcab90b..cc80ee7bfd 100644 --- a/internal/core/metadata/config/config.go +++ b/internal/core/metadata/config/config.go @@ -66,6 +66,11 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return &WritableInfo{} } +// GetWritablePtr returns pointer to the writable section +func (c *ConfigurationStruct) GetWritablePtr() any { + return &c.Writable +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific WritableInfo struct // which is then used to overwrite the service's existing configuration's WritableInfo struct. func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) bool { diff --git a/internal/security/bootstrapper/config/config.go b/internal/security/bootstrapper/config/config.go index 3a7dbd0b7b..dd909fcbdf 100644 --- a/internal/security/bootstrapper/config/config.go +++ b/internal/security/bootstrapper/config/config.go @@ -38,6 +38,12 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return nil } +// GetWritablePtr returns pointer to the writable section +// Not needed for this service, so return nil +func (c *ConfigurationStruct) GetWritablePtr() any { + return nil +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific WritableInfo struct // which is then used to overwrite the service's existing configuration's WritableInfo struct. func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) bool { diff --git a/internal/security/bootstrapper/mosquitto/config/config.go b/internal/security/bootstrapper/mosquitto/config/config.go index 919637844b..f0ce601466 100644 --- a/internal/security/bootstrapper/mosquitto/config/config.go +++ b/internal/security/bootstrapper/mosquitto/config/config.go @@ -46,6 +46,12 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return nil } +// GetWritablePtr returns pointer to the writable section +// Not needed for this service, so return nil +func (c *ConfigurationStruct) GetWritablePtr() any { + return nil +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific // WritableInfo struct which is then used to overwrite the service's existing configuration's // WritableInfo struct. diff --git a/internal/security/bootstrapper/redis/config/config.go b/internal/security/bootstrapper/redis/config/config.go index 072bc13280..5d5cc25758 100644 --- a/internal/security/bootstrapper/redis/config/config.go +++ b/internal/security/bootstrapper/redis/config/config.go @@ -48,6 +48,12 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return nil } +// GetWritablePtr returns pointer to the writable section +// Not needed for this service, so return nil +func (c *ConfigurationStruct) GetWritablePtr() any { + return nil +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific // WritableInfo struct which is then used to overwrite the service's existing configuration's // WritableInfo struct. diff --git a/internal/security/common/tokenpolicy_test.go b/internal/security/common/tokenpolicy_test.go index e26f70db96..a3a68cc485 100644 --- a/internal/security/common/tokenpolicy_test.go +++ b/internal/security/common/tokenpolicy_test.go @@ -1,4 +1,3 @@ -// // Copyright (c) 2019-2023 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except @@ -12,7 +11,6 @@ // the License. // // SPDX-License-Identifier: Apache-2.0 -// package common import ( diff --git a/internal/security/fileprovider/config/config.go b/internal/security/fileprovider/config/config.go index 18126d824d..dc1938cdf8 100644 --- a/internal/security/fileprovider/config/config.go +++ b/internal/security/fileprovider/config/config.go @@ -56,6 +56,12 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return nil } +// GetWritablePtr returns pointer to the writable section +// Not needed for this service, so return nil +func (c *ConfigurationStruct) GetWritablePtr() any { + return nil +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific WritableInfo struct // Not needed for this service, so return false func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) bool { diff --git a/internal/security/fileprovider/util_test.go b/internal/security/fileprovider/util_test.go index c4ae18b992..448c0037e5 100644 --- a/internal/security/fileprovider/util_test.go +++ b/internal/security/fileprovider/util_test.go @@ -1,4 +1,3 @@ -// // Copyright (c) 2019 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except @@ -12,7 +11,6 @@ // the License. // // SPDX-License-Identifier: Apache-2.0 -// package fileprovider import ( diff --git a/internal/security/proxyauth/config/config.go b/internal/security/proxyauth/config/config.go index 2a82950fd2..5a3e9acef1 100644 --- a/internal/security/proxyauth/config/config.go +++ b/internal/security/proxyauth/config/config.go @@ -48,6 +48,11 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return &WritableInfo{} } +// GetWritablePtr returns pointer to the writable section +func (c *ConfigurationStruct) GetWritablePtr() any { + return &c.Writable +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific WritableInfo struct // which is then used to overwrite the service's existing configuration's WritableInfo struct. func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) bool { diff --git a/internal/security/secretstore/config/config.go b/internal/security/secretstore/config/config.go index 4d1ad3bd80..565657b44f 100644 --- a/internal/security/secretstore/config/config.go +++ b/internal/security/secretstore/config/config.go @@ -86,6 +86,12 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return nil } +// GetWritablePtr returns pointer to the writable section +// Not needed for this service, so return nil +func (c *ConfigurationStruct) GetWritablePtr() any { + return nil +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific WritableInfo struct // Not needed for this service, so always return false func (c *ConfigurationStruct) UpdateWritableFromRaw(_ interface{}) bool { diff --git a/internal/security/spiffetokenprovider/config/config.go b/internal/security/spiffetokenprovider/config/config.go index 333845c640..342cdf8758 100644 --- a/internal/security/spiffetokenprovider/config/config.go +++ b/internal/security/spiffetokenprovider/config/config.go @@ -61,6 +61,11 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return &WritableInfo{} } +// GetWritablePtr returns pointer to the writable section +func (c *ConfigurationStruct) GetWritablePtr() any { + return &c.Writable +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific WritableInfo struct // which is then used to overwrite the service's existing configuration's WritableInfo struct. func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) bool { diff --git a/internal/support/notifications/config/config.go b/internal/support/notifications/config/config.go index 717ca3ec78..a0fc6353d4 100644 --- a/internal/support/notifications/config/config.go +++ b/internal/support/notifications/config/config.go @@ -81,6 +81,11 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return &WritableInfo{} } +// GetWritablePtr returns pointer to the writable section +func (c *ConfigurationStruct) GetWritablePtr() any { + return &c.Writable +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific WritableInfo struct // which is then used to overwrite the service's existing configuration's WritableInfo struct. func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) bool { diff --git a/internal/support/scheduler/config/config.go b/internal/support/scheduler/config/config.go index 3fe2a647d2..eefe80babb 100644 --- a/internal/support/scheduler/config/config.go +++ b/internal/support/scheduler/config/config.go @@ -112,6 +112,11 @@ func (c *ConfigurationStruct) EmptyWritablePtr() interface{} { return &WritableInfo{} } +// GetWritablePtr returns pointer to the writable section +func (c *ConfigurationStruct) GetWritablePtr() any { + return &c.Writable +} + // UpdateWritableFromRaw converts configuration received from the registry to a service-specific WritableInfo struct // which is then used to overwrite the service's existing configuration's WritableInfo struct. func (c *ConfigurationStruct) UpdateWritableFromRaw(rawWritable interface{}) bool {