From c03702d7e51e3f53310f3f60674d1e07edcc8b15 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Wed, 28 Feb 2024 14:05:23 +1100 Subject: [PATCH] fix: support globally scoped (not module-scoped) secrets/config (#1000) --- go-runtime/ftl/config.go | 5 ++++- go-runtime/ftl/secrets.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/go-runtime/ftl/config.go b/go-runtime/ftl/config.go index 2773d86c5c..debd42794d 100644 --- a/go-runtime/ftl/config.go +++ b/go-runtime/ftl/config.go @@ -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)) diff --git a/go-runtime/ftl/secrets.go b/go-runtime/ftl/secrets.go index 5e1841c7cf..79d628ea76 100644 --- a/go-runtime/ftl/secrets.go +++ b/go-runtime/ftl/secrets.go @@ -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))