Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mail support to limes #667

Merged
merged 60 commits into from
Feb 26, 2025
Merged

Add Mail support to limes #667

merged 60 commits into from
Feb 26, 2025

Conversation

VoigtS
Copy link
Member

@VoigtS VoigtS commented Feb 18, 2025

This PR introduces mailing functionality to limes.
Confirmed and expired comitments should queue the commitment information for a project and send the email body to an API that is able to send those emails to their proper recipients.

Checklist:

  • Add functionality for pending commitments that get confirmed (opt-in for the customer)
  • Add functionality to transfer queued mails to an appropriate API.
  • Add functionality for expired commitments
  • I updated the documentation to describe the semantical or interface changes I introduced.

@coveralls
Copy link

coveralls commented Feb 18, 2025

Coverage Status

coverage: 79.422% (-0.2%) from 79.629%
when pulling 9a90e7d on mail_support
into f51211f on master.

@majewsky majewsky self-requested a review February 18, 2025 15:32
VoigtS and others added 22 commits February 24, 2025 15:19
Fix space in Duration attribute of test mail template
Add short-term notified query into process task
Fix: Bug that already notified commitments would be notified on another run
Add a unit test for the case above
fix: add subject to mail configuration.
fix: change naming scheme from MailInfo to CommitmentGroupNotification
client type is a set value now
change MailClient interface and implementation names and add documentation for those types
- make it private since it does not need to be public
- load the entire ProjectCommitment object instead of just a few fields
  (loading everything is not very expensive, and not doing it feels odd)
- fully prepare the mail instead of doing only half the work in the
  helper function
This is nominally more code, but the code in NewCluster() repeats itself
less.
When suggesting slices.Collect() here earlier, I did not realize that
the sort.Slice() does not do anything special. So this can be simplified
further.
The inciting motivation here was to make the full ProjectCommitment
object available to the template, like in
e3daee2.

This required splitting the discover phase into two separate queries,
one for the commitment objects themselves and one for context joined
from other tables. It then appeared natural to me to make the discover
phase very lean and only load commitments there, and do all the
remaining work in the processing phase.
Copy link
Contributor

@majewsky majewsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made another round of reviews as direct code commits; please counter-review these. If these look good, we're pretty close to done here. One last thing: Please add documentation.

  • docs/operators/config.md should explain the new required environment variable, and what kind of API we expect to have available under that endpoint.
  • Each public declaration (i.e. every upper-cased type, func, var) should have at least one or two sentences of documentation, such that godoc output or https://pkg.go.dev/github.com/sapcc/limes/internal/core etc. can be navigated in a useful way.

VoigtS and others added 2 commits February 26, 2025 10:55
add godoc documentation for each public type, func, var
Also, upon further consideration, it is indeed weird that I wanted to
have the mail endpoint coming in as an env var when the rest of the mail
config is in the config file. So this commit groups everything together
in the config file.
@VoigtS VoigtS merged commit 7cc255c into master Feb 26, 2025
6 checks passed
@majewsky majewsky deleted the mail_support branch February 26, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants