mirror of https://github.com/artifacthub/hub.git
Remove some fields from email required config (#802)
Closes #801 Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
This commit is contained in:
parent
976e6cb952
commit
1b01f49775
|
|
@ -2,7 +2,7 @@ apiVersion: v2
|
|||
name: artifact-hub
|
||||
description: Artifact Hub is a web-based application that enables finding, installing, and publishing Kubernetes packages.
|
||||
type: application
|
||||
version: 0.8.1
|
||||
version: 0.8.2
|
||||
appVersion: 0.8.0
|
||||
home: https://artifacthub.io
|
||||
icon: https://artifacthub.github.io/hub/chart/logo.png
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@
|
|||
"properties": {
|
||||
"from": {
|
||||
"title": "From address used in emails",
|
||||
"description": "This field is required if you want to enable email sending in Artifact Hub.",
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
|
|
@ -142,6 +143,7 @@
|
|||
"properties": {
|
||||
"host": {
|
||||
"title": "SMTP host",
|
||||
"description": "This field is required if you want to enable email sending in Artifact Hub.",
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
|
|
@ -152,6 +154,7 @@
|
|||
},
|
||||
"port": {
|
||||
"title": "SMTP port",
|
||||
"description": "This field is required if you want to enable email sending in Artifact Hub.",
|
||||
"type": "integer",
|
||||
"default": 587
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net/smtp"
|
||||
|
||||
"github.com/domodwyer/mailyak"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
|
@ -33,21 +34,18 @@ type Sender struct {
|
|||
// NewSender creates a new Sender instance and returns it.
|
||||
func NewSender(cfg *viper.Viper) *Sender {
|
||||
requiredConfigFields := []string{
|
||||
"fromName",
|
||||
"from",
|
||||
"replyTo",
|
||||
"smtp.host",
|
||||
"smtp.port",
|
||||
"smtp.username",
|
||||
"smtp.password",
|
||||
}
|
||||
for _, f := range requiredConfigFields {
|
||||
if !cfg.IsSet("email." + f) {
|
||||
log.Warn().Msg("email not setup properly, some required configuration fields are missing")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return &Sender{
|
||||
s := &Sender{
|
||||
fromName: cfg.GetString("email.fromName"),
|
||||
from: cfg.GetString("email.from"),
|
||||
replyTo: cfg.GetString("email.replyTo"),
|
||||
|
|
@ -56,13 +54,13 @@ func NewSender(cfg *viper.Viper) *Sender {
|
|||
cfg.GetString("email.smtp.host"),
|
||||
cfg.GetInt("email.smtp.port"),
|
||||
),
|
||||
smtpAuth: smtp.PlainAuth(
|
||||
"",
|
||||
cfg.GetString("email.smtp.username"),
|
||||
cfg.GetString("email.smtp.password"),
|
||||
cfg.GetString("email.smtp.host"),
|
||||
),
|
||||
}
|
||||
username := cfg.GetString("email.smtp.username")
|
||||
password := cfg.GetString("email.smtp.password")
|
||||
if username != "" && password != "" {
|
||||
s.smtpAuth = smtp.PlainAuth("", username, password, cfg.GetString("email.smtp.host"))
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// SendEmail creates an email using the data provided and sends it.
|
||||
|
|
|
|||
Loading…
Reference in New Issue