Skip to content

Commit

Permalink
ci: Switching to amqp mailer
Browse files Browse the repository at this point in the history
  • Loading branch information
ViBiOh committed Jan 10, 2021
1 parent 7376036 commit 34d7107
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
5 changes: 4 additions & 1 deletion cmd/ketchup/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ func main() {
repositoryServiceApp := repositoryService.New(repositoryStore.New(ketchupDb), github.New(githubConfig), helm.New())
ketchupServiceApp := ketchupService.New(ketchupStore.New(ketchupDb), repositoryServiceApp)

schedulerApp := scheduler.New(schedulerConfig, repositoryServiceApp, ketchupServiceApp, mailer.New(mailerConfig))
mailerApp, err := mailer.New(mailerConfig)
logger.Fatal(err)
defer mailerApp.Close()

publicRendererApp, err := renderer.New(rendererConfig, ketchup.FuncMap)
logger.Fatal(err)

schedulerApp := scheduler.New(schedulerConfig, repositoryServiceApp, ketchupServiceApp, mailerApp)
ketchupApp := ketchup.New(publicRendererApp, ketchupServiceApp, userServiceApp, repositoryServiceApp)

publicHandler := publicRendererApp.Handler(ketchupApp.PublicTemplateFunc)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/ViBiOh/auth/v2 v2.6.4
github.com/ViBiOh/httputils/v3 v3.36.4
github.com/ViBiOh/mailer v1.10.0
github.com/ViBiOh/mailer v1.11.1
github.com/lib/pq v1.9.0
gopkg.in/yaml.v2 v2.4.0
)
9 changes: 3 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/ViBiOh/httputils/v3 v3.35.1 h1:CJ3BcpYzxlI2MoxJbUwqzBXTe7BHXoAFkFDwCO
github.com/ViBiOh/httputils/v3 v3.35.1/go.mod h1:l4sdVJfRu99dY7rNJfMinJHYb0pJZU9FEz7C83dX6gE=
github.com/ViBiOh/httputils/v3 v3.36.4 h1:ddehKRmFWe0x7rjVAVEiG/E9hszEQEe4K7ssdMjht6Q=
github.com/ViBiOh/httputils/v3 v3.36.4/go.mod h1:l4sdVJfRu99dY7rNJfMinJHYb0pJZU9FEz7C83dX6gE=
github.com/ViBiOh/mailer v1.10.0 h1:R4pcuP6v6ZZ7g960NoMBCwU6rthd6paDSdBUgFzu6d0=
github.com/ViBiOh/mailer v1.10.0/go.mod h1:IKDtPPmi2Wc87mfP4njtbdX0Zji3eNfhX1B/Lz5lXBY=
github.com/ViBiOh/mailer v1.11.1 h1:J1+c2tD8lx+aTNEu/orooee4rigfo1qvxu6MMeaCjqE=
github.com/ViBiOh/mailer v1.11.1/go.mod h1:D+VW012tqsf8RKLGDRMJ9BOWvzQYFSCg8amsh3ce1rk=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down Expand Up @@ -272,6 +272,7 @@ github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 h1:WhxRHzgeVGETMlmVfqhRn8RIeeNoPr2Czh33I4Zdccw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand All @@ -283,8 +284,6 @@ github.com/tdewolff/minify/v2 v2.9.10 h1:p+ifTTl+JMFFLDYNAm7nxQ9XuCG10HTW00wlPAZ
github.com/tdewolff/minify/v2 v2.9.10/go.mod h1:U1Nc+/YBSB0FPEarqcgkYH3Ep4DNyyIbOyl5P4eWMuo=
github.com/tdewolff/parse/v2 v2.5.5 h1:b7ICJa4I/54JQGEGgTte8DiyJPKcC5g8V773QMzkeUM=
github.com/tdewolff/parse/v2 v2.5.5/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
github.com/tdewolff/parse/v2 v2.5.7 h1:9JGh56thUIzOjJdMbAF98FJZ53/zxElrMTj37PojEhs=
github.com/tdewolff/parse/v2 v2.5.7/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4=
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
Expand Down Expand Up @@ -369,8 +368,6 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e h1:AyodaIpKjppX+cBfTASF2E1US3H2JFBj920Ot3rtDjs=
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo=
golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
12 changes: 6 additions & 6 deletions infra/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
chart:
spec:
chart: app
version: '0.0.42'
version: "0.0.42"
sourceRef:
kind: HelmRepository
name: vibioh
Expand All @@ -19,19 +19,19 @@ spec:
image:
repository: vibioh/ketchup:latest # {"$imagepolicy": "default:ketchup"}
config:
KETCHUP_LOGGER_JSON: 'true'
KETCHUP_MAILER_URL: http://mailer
KETCHUP_LOGGER_JSON: "true"
KETCHUP_DB_HOST: ketchup-db
KETCHUP_DB_PORT: '80'
KETCHUP_DB_PORT: "80"
KETCHUP_DB_NAME: ketchup
KETCHUP_DB_USER: ketchup
secrets:
KETCHUP_DB_PASS: AgDOK5Ph8WD8SbBi+Mn/ywPirM59KRfhAjkAqaOqDePJJDd3uIQhoJCKN5HCwYsUoux173go8RrPtyhc5CxKm+/sc6JiqeajZVv/mc/EVPa0MyNpCN376jXIvo0P+joasjBGys/rtqEauhdn7hWGr87PnJbL5A2k+XD3kMauzcKJtMXSYkz2QSTx7TW1kW+5zJs/Cgp3FS9qHZ8buvktggnKeffhd0paYJJrLmtyKxKzmkXcyL8Q3i3QnAbXC3u4vSPxP5PMFMEqDZNrmmYiEJVOmNcW+R0jO7u6q3gwWkATL7E0bbtWuanp6/FXgUhlgpmD+i9BSwTEzrglFHEGPESlg+uYDqXDXOKGBzmQPcq7aAU+/jcEyh5ozkF8aVod7fVxFo+g1nGCbwAhXK5E+iT+KZ1Q50mFkhRIOYSQ9aesHONBPpiaLp8y00OJ6oEmbCSmuDNOBTYXo/JIjUnJ5LFIIskcT5MWKPkYV3hlSzshQBR9JPXLqdaiIEiRicjnfU/qWrwel0PlEaU2L1FL1qsikxPkfGu1HHwj0CusGpGduD3DKC1mTEc1U4zAVvmqSMpoSguyfOYf/2C/m+jcd5YTkiS9JpTGUx4OVFvBD6Ug9uT7igLI8nNFZeTHMCnCerG7GES0wapWehYX/wYFaqw9K1ym0Jz2fHByCVNEt8XH0GxFszdTw2iF6Q4AIH4D8lLB9umdTPP91L5hYVSIOpv9qQPUa9pxB5aNwEG9Q+BQt31mM/zNEglv033PqYOAM12Ks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j6i8k3ia7y2jHGV5M97Y7TQYdcezngcUWsy9vY8W9vrGIVXihSu5FWVD9mDuzcs7viUYtw2Za0EMvdCxGoZEOWkeicMYV82dzjrrI+9hzb2vOzthje2guG1HhgbKr70gadi5ewXBPQ3JhiPOIs0zm7d3bVCwmwV9r4E02jLmx/pwXNskBO2GhSjQPEa2gxEX9NY8JpE0HvL81V9B8scwradPtewOioBzB234DMPcB1naJ0k+Ph7+RSSb/fFAbsu54ppk/LTT1qbLkIe43bPq+q40Bp7I/lkQiFLfh1PqohgFeXCo4vT4tI8FRQ3o4wm68x7sXg/AoF8ouVnThrNNg6qz4uZywzWZa3M/G3MqSSRWWI0UAt48di9W1UNHfZEJQ6An+PpzYGyW1HRDRrZqD9zzuNp/ptfLYzmULM1RQ2EDJZbekZD8u5VbgMXE4t7qqrRJyZr2jMbaxE/dZAJaI1tRhUJt4+k1ww10C976hvh5bKa9YXvr4Iu1tkxmXHhFjBirwVIHNBT14PGkDs1cKX+LAX2GF2ao6
ingress:
enabled: true
hosts:
- ketchup.vibioh.fr
- ketchup.vibioh.fr
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
Expand All @@ -43,7 +43,7 @@ spec:
chart:
spec:
chart: postgres
version: '0.0.15'
version: "0.0.15"
sourceRef:
kind: HelmRepository
name: vibioh
Expand Down
9 changes: 5 additions & 4 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ViBiOh/ketchup/pkg/service/ketchup"
"github.com/ViBiOh/ketchup/pkg/service/repository"
mailer "github.com/ViBiOh/mailer/pkg/client"
mailerModel "github.com/ViBiOh/mailer/pkg/model"
)

var (
Expand Down Expand Up @@ -207,14 +208,14 @@ func (a app) sendNotification(ctx context.Context, ketchupToNotify map[model.Use
"releases": releases,
}

email := mailer.NewEmail().Template("ketchup").From("[email protected]").As("Ketchup").To(user.Email).Data(payload)
mailRequest := mailerModel.NewMailRequest().Template("ketchup").From("[email protected]").As("Ketchup").To(user.Email).Data(payload)
if len(releases) > 1 {
email.WithSubject("Ketchup - New releases")
mailRequest.WithSubject("Ketchup - New releases")
} else {
email.WithSubject("Ketchup - New release")
mailRequest.WithSubject("Ketchup - New release")
}

if err := email.Send(ctx, a.mailerApp); err != nil {
if err := a.mailerApp.Send(ctx, *mailRequest); err != nil {
return fmt.Errorf("unable to send email to %s: %s", user.Email, err)
}
}
Expand Down

0 comments on commit 34d7107

Please sign in to comment.