diff --git a/charts/artifact-hub/Chart.yaml b/charts/artifact-hub/Chart.yaml index bc53961d..e867dbb3 100644 --- a/charts/artifact-hub/Chart.yaml +++ b/charts/artifact-hub/Chart.yaml @@ -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 diff --git a/charts/artifact-hub/values.schema.json b/charts/artifact-hub/values.schema.json index 0d658509..10aa655f 100644 --- a/charts/artifact-hub/values.schema.json +++ b/charts/artifact-hub/values.schema.json @@ -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 }, diff --git a/internal/email/email.go b/internal/email/email.go index f62131e4..79d7eae1 100644 --- a/internal/email/email.go +++ b/internal/email/email.go @@ -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.