Skip to content

Commit

Permalink
[apricot] implementation of GetRuntimeEntries rpc call
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Tichák committed Feb 15, 2024
1 parent 4875f84 commit c2320f2
Show file tree
Hide file tree
Showing 9 changed files with 587 additions and 371 deletions.
4 changes: 4 additions & 0 deletions apricot/cacheproxy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func (s Service) SetRuntimeEntry(component string, key string, value string) err
return s.base.SetRuntimeEntry(component, key, value)
}

func (s Service) GetRuntimeEntries(component string) (map[string]string, error) {
return s.base.GetRuntimeEntries(component)
}

func (s Service) ListRuntimeEntries(component string) ([]string, error) {
return s.base.ListRuntimeEntries(component)
}
Expand Down
1 change: 1 addition & 0 deletions apricot/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func setFlags() error {
pflag.String("backendUri", viper.GetString("backendUri"), "URI of the Consul server or YAML configuration file")
pflag.Bool("verbose", viper.GetBool("verbose"), "Verbose logging")
pflag.Bool("trimSpaceInVarsFromConsulKV", viper.GetBool("trimSpaceInVarsFromConsulKV"), "When true, the variables imported from the Consul KV are trimmed if the contain whitespaces")
pflag.String("workingDir", viper.GetString("workingDir"), "Working directory for apricot")

pflag.Parse()
return viper.BindPFlags(pflag.CommandLine)
Expand Down
21 changes: 21 additions & 0 deletions apricot/local/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/AliceO2Group/Control/configuration/componentcfg"
"github.com/AliceO2Group/Control/configuration/template"
"github.com/flosch/pongo2/v6"
"github.com/hashicorp/go-multierror"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -477,6 +478,26 @@ func (s *Service) SetRuntimeEntry(component string, key string, value string) er
}
}

func (s *Service) GetRuntimeEntries(component string) (map[string]string, error) {
s.logMethod()

if keys, err := s.ListRuntimeEntries(component); err == nil {
var keysErrors *multierror.Error
entries := make(map[string]string)
for _, key := range keys {
if entry, err := s.GetRuntimeEntry(component, key); err == nil {
entries[key] = entry
} else {
keysErrors = multierror.Append(keysErrors, err)
}
}
return entries, keysErrors.ErrorOrNil()
} else {
return nil, err
}

}

func (s *Service) ListRuntimeEntries(component string) ([]string, error) {
s.logMethod()

Expand Down
Loading

0 comments on commit c2320f2

Please sign in to comment.