package notifier import ( "context" "fmt" "time" "github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2" "github.com/jenkinsci/kubernetes-operator/pkg/log" "github.com/mailgun/mailgun-go/v3" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" ) // Mailgun is service for sending emails type Mailgun struct { Domain string Recipient string From string } // Send is function for sending directly to API func (m Mailgun) Send(n *Notification) error { var selector v1alpha2.SecretKeySelector secret := &corev1.Secret{} i := n.Information err := n.K8sClient.Get(context.TODO(), types.NamespacedName{Name: selector.Name, Namespace: n.Jenkins.Namespace}, secret) if err != nil { n.Logger.V(log.VWarn).Info(fmt.Sprintf("Failed to get secret with name `%s`. %+v", selector.Name, err)) return err } mg := mailgun.NewMailgun(m.Domain, secret.StringData[selector.Name]) content := `
| CR name: | %s |
| Configuration type: | %s |
| Status: | %s |