Skip to content

Commit

Permalink
fix: support globally scoped (not module-scoped) secrets/config (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas authored Feb 28, 2024
1 parent 9914282 commit c03702d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion go-runtime/ftl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func (c *ConfigValue[T]) String() string {
func (c *ConfigValue[T]) Get() (out T) {
value, ok := os.LookupEnv(fmt.Sprintf("FTL_CONFIG_%s_%s", strings.ToUpper(c.module), strings.ToUpper(c.name)))
if !ok {
return out
value, ok = os.LookupEnv(fmt.Sprintf("FTL_CONFIG_%s", strings.ToUpper(c.name)))
if !ok {
return out
}
}
if err := json.Unmarshal([]byte(value), &out); err != nil {
panic(fmt.Errorf("failed to parse %s value %q: %w", c, value, err))
Expand Down
5 changes: 4 additions & 1 deletion go-runtime/ftl/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ func (s *SecretValue[Type]) String() string {
func (s *SecretValue[Type]) Get() (out Type) {
value, ok := os.LookupEnv(fmt.Sprintf("FTL_SECRET_%s_%s", strings.ToUpper(s.module), strings.ToUpper(s.name)))
if !ok {
return out
value, ok = os.LookupEnv(fmt.Sprintf("FTL_SECRET_%s", strings.ToUpper(s.name)))
if !ok {
return out
}
}
if err := json.Unmarshal([]byte(value), &out); err != nil {
panic(fmt.Errorf("failed to parse %s: %w", s, err))
Expand Down

0 comments on commit c03702d

Please sign in to comment.