Skip to content

Commit

Permalink
fix: email templates for monorepos
Browse files Browse the repository at this point in the history
Fixes: #2721
  • Loading branch information
avallete committed Oct 2, 2024
1 parent 4ee741f commit 0541ec3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -725,15 +725,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 @@ -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 {
Expand Down

0 comments on commit 0541ec3

Please sign in to comment.