aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/app/config_backend.go
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2021-08-02 22:15:35 +0200
committerLukasz Rajewski <lukasz.rajewski@orange.com>2021-08-02 20:50:31 +0000
commit4544d8a6e5e86b082eca9ed605327e58cb3e9d85 (patch)
tree13f90bef6e049578cbbf90c2aae8cb8cd50bfb8e /src/k8splugin/internal/app/config_backend.go
parentcf5527b09bfc263760ea6472d80bc6f1b438a37e (diff)
Config List handler added to Config API
Config List handler added to Config API Issue-ID: MULTICLOUD-1332 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com> Change-Id: I63355dd6b05e70398cfc89744efa332926286c40
Diffstat (limited to 'src/k8splugin/internal/app/config_backend.go')
-rw-r--r--src/k8splugin/internal/app/config_backend.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/k8splugin/internal/app/config_backend.go b/src/k8splugin/internal/app/config_backend.go
index e2f802c7..4509589f 100644
--- a/src/k8splugin/internal/app/config_backend.go
+++ b/src/k8splugin/internal/app/config_backend.go
@@ -170,6 +170,33 @@ func (c ConfigStore) getConfig() (Config, error) {
return Config{}, pkgerrors.Wrap(err, "Get Config DB Entry")
}
+// Read the config entry in the database
+func (c ConfigStore) getConfigList() ([]Config, error) {
+ rbName, rbVersion, profileName, _, err := resolveModelFromInstance(c.instanceID)
+ if err != nil {
+ return []Config{}, pkgerrors.Wrap(err, "Retrieving model info")
+ }
+ cfgKey := constructKey(rbName, rbVersion, profileName, c.instanceID, tagConfig)
+ values, err := db.Etcd.GetAll(cfgKey)
+ if err != nil {
+ return []Config{}, pkgerrors.Wrap(err, "Get Config DB List")
+ }
+ //value is a byte array
+ if values != nil {
+ result := make([]Config, 0)
+ for _, value := range values {
+ cfg := Config{}
+ err = db.DeSerialize(string(value), &cfg)
+ if err != nil {
+ return []Config{}, pkgerrors.Wrap(err, "Unmarshaling Config Value")
+ }
+ result = append(result, cfg)
+ }
+ return result, nil
+ }
+ return []Config{}, pkgerrors.Wrap(err, "Get Config DB List")
+}
+
// Delete the config entry in the database
func (c ConfigStore) deleteConfig() (Config, error) {