Skip to content

Commit

Permalink
fix: email templates for monorepos (#2723)
Browse files Browse the repository at this point in the history
* fix: email templates for monorepos

Fixes: #2721

* Update pkg/config/config.go

* Revert "Update pkg/config/config.go"

This reverts commit 2dbc9f0.

---------

Co-authored-by: Han Qiao <sweatybridge@gmail.com>
Co-authored-by: Qiao Han <qiao@supabase.io>
  • Loading branch information
3 people authored Oct 4, 2024
1 parent 0efc21d commit 333a2ca
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,11 @@ func (c *config) Load(path string, fsys fs.FS) error {
}
c.Functions[slug] = function
}

if err := c.Db.Seed.loadSeedPaths(builder.SupabaseDirPath, fsys); err != nil {
return err
}
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))
Expand All @@ -730,15 +731,15 @@ 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
}
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 {
Expand Down Expand Up @@ -833,8 +834,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 {
Expand Down

0 comments on commit 333a2ca

Please sign in to comment.