Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apricot] implementation of GetRuntimeEntries rpc call #517

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
teo marked this conversation as resolved.
Show resolved Hide resolved
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
Loading