From 0541ec3ec9cd4ede550029465fa9dd7e4d717068 Mon Sep 17 00:00:00 2001 From: avallete Date: Wed, 2 Oct 2024 12:31:17 +0200 Subject: [PATCH] fix: email templates for monorepos Fixes: https://github.com/supabase/cli/issues/2721 --- pkg/config/config.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 3636e7e9c..3fd483eea 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -708,7 +708,7 @@ func (c *config) Load(path string, fsys fs.FS) error { } c.Functions[slug] = function } - if err := c.baseConfig.Validate(); err != nil { + if err := c.baseConfig.Validate(fsys); err != nil { return err } c.Remotes = make(map[string]baseConfig, len(c.Overrides)) @@ -725,7 +725,7 @@ func (c *config) Load(path string, fsys fs.FS) error { } else if undecoded := metadata.Undecoded(); len(undecoded) > 0 { fmt.Fprintf(os.Stderr, "Unknown config fields: %+v\n", undecoded) } - if err := base.Validate(); err != nil { + if err := base.Validate(fsys); err != nil { return err } c.Remotes[name] = base @@ -733,7 +733,7 @@ func (c *config) Load(path string, fsys fs.FS) error { return nil } -func (c *baseConfig) Validate() error { +func (c *baseConfig) Validate(fsys fs.FS) error { if c.ProjectId == "" { return errors.New("Missing required field in config: project_id") } else if sanitized := sanitizeProjectId(c.ProjectId); sanitized != c.ProjectId { @@ -828,8 +828,10 @@ func (c *baseConfig) Validate() error { } // Validate email config for name, tmpl := range c.Auth.Email.Template { - if len(tmpl.ContentPath) > 0 && !fs.ValidPath(filepath.Clean(tmpl.ContentPath)) { - return errors.Errorf("Invalid config for auth.email.%s.content_path: %s", name, tmpl.ContentPath) + if len(tmpl.ContentPath) > 0 { + if _, err = fs.Stat(fsys, filepath.Clean(tmpl.ContentPath)); err != nil { + return errors.Errorf("Invalid config for auth.email.%s.content_path: %s", name, tmpl.ContentPath) + } } } if c.Auth.Email.Smtp.Pass, err = maybeLoadEnv(c.Auth.Email.Smtp.Pass); err != nil {