Skip to content

Commit 101f12d

Browse files
justonedev1teo
authored andcommitted
[apricot] implementation of GetRuntimeEntries rpc call
1 parent 4875f84 commit 101f12d

9 files changed

Lines changed: 587 additions & 371 deletions

File tree

apricot/cacheproxy/service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ func (s Service) SetRuntimeEntry(component string, key string, value string) err
4949
return s.base.SetRuntimeEntry(component, key, value)
5050
}
5151

52+
func (s Service) GetRuntimeEntries(component string) (map[string]string, error) {
53+
return s.base.GetRuntimeEntries(component)
54+
}
55+
5256
func (s Service) ListRuntimeEntries(component string) ([]string, error) {
5357
return s.base.ListRuntimeEntries(component)
5458
}

apricot/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func setFlags() error {
5353
pflag.String("backendUri", viper.GetString("backendUri"), "URI of the Consul server or YAML configuration file")
5454
pflag.Bool("verbose", viper.GetBool("verbose"), "Verbose logging")
5555
pflag.Bool("trimSpaceInVarsFromConsulKV", viper.GetBool("trimSpaceInVarsFromConsulKV"), "When true, the variables imported from the Consul KV are trimmed if the contain whitespaces")
56+
pflag.String("workingDir", viper.GetString("workingDir"), "Working directory for apricot")
5657

5758
pflag.Parse()
5859
return viper.BindPFlags(pflag.CommandLine)

apricot/local/service.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
"github.com/AliceO2Group/Control/configuration/componentcfg"
4646
"github.com/AliceO2Group/Control/configuration/template"
4747
"github.com/flosch/pongo2/v6"
48+
"github.com/hashicorp/go-multierror"
4849
"github.com/sirupsen/logrus"
4950
"github.com/spf13/viper"
5051
)
@@ -477,6 +478,26 @@ func (s *Service) SetRuntimeEntry(component string, key string, value string) er
477478
}
478479
}
479480

481+
func (s *Service) GetRuntimeEntries(component string) (map[string]string, error) {
482+
s.logMethod()
483+
484+
if keys, err := s.ListRuntimeEntries(component); err == nil {
485+
var keysErrors *multierror.Error
486+
entries := make(map[string]string)
487+
for _, key := range keys {
488+
if entry, err := s.GetRuntimeEntry(component, key); err == nil {
489+
entries[key] = entry
490+
} else {
491+
keysErrors = multierror.Append(keysErrors, err)
492+
}
493+
}
494+
return entries, keysErrors.ErrorOrNil()
495+
} else {
496+
return nil, err
497+
}
498+
499+
}
500+
480501
func (s *Service) ListRuntimeEntries(component string) ([]string, error) {
481502
s.logMethod()
482503

0 commit comments

Comments
 (0)