Skip to content

Conversation

danlishka
Copy link
Member

@danlishka danlishka commented Jun 13, 2023

This is a new extension for sending emails via SMTP. This is still a very early experimental version focusing on validating the latest cutting-edge integrations framework.

The README file provides more information on how to use this extension.

closes #158

@danlishka danlishka marked this pull request as draft June 13, 2023 14:21
@danlishka danlishka changed the title feat: Added SMTP extension, refs #158 feat: Added SMTP extension, closes #158 Jun 13, 2023
@danlishka danlishka marked this pull request as ready for review June 13, 2023 14:40
@danlishka danlishka requested a review from migmartri June 13, 2023 14:40
Signed-off-by: Daniel Liszka <daniel@chainloop.dev>
Signed-off-by: Daniel Liszka <daniel@chainloop.dev>
Signed-off-by: Daniel Liszka <daniel@chainloop.dev>
Signed-off-by: Daniel Liszka <daniel@chainloop.dev>
Copy link
Member

@migmartri migmartri left a comment

Choose a reason for hiding this comment

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

Awesome, good start!

I left some comments, most of them suggestions that can be changed in another patch.

For example, by encapsulating the render code in a function + go templates you'll be able to test them.

I'd suggest to also add comments in the code explaining/separating the different blocks. And as a general rule, make sure that initialization of variables/code happens the closest to the code that'll use it as possible (i.e preparing the response in register.

Looking good!

From string `json:"from" jsonschema:"format=email,description=The email address of the sender."`
User string `json:"user" jsonschema:"minLength=1,description=The username to use for the SMTP authentication."`
Password string `json:"password" jsonschema:"description=The password to use for the SMTP authentication."`
Host string `json:"host" jsonschema:"description=The host to use for the SMTP authentication."`
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not supported by our jsonschema library - I can work on the PR though. We would have to use something like: anyof_format=hostname,ipv4

to get

"anyOf": [
{ "format": "hostname" },
{ "format": "ipv4" },
{ "format": "ipv6" }
]

Copy link
Member

Choose a reason for hiding this comment

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

I see, that makes sense. It's not just a host but also an IP address.

return nil
}

func validateExecuteRequest(req *sdk.ExecutionRequest) error {
Copy link
Member

Choose a reason for hiding this comment

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

mental note for myself: this is starting to look more and more like smth that could get automatically validated.

},
{
name: "valid request",
input: map[string]interface{}{"from": "test@example.com", "to": "test@example.com", "host": "localhost", "port": "25", "user": "test", "password": "test"},
Copy link
Member

Choose a reason for hiding this comment

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

probably test email formats and potential hostnames.

Signed-off-by: Daniel Liszka <daniel@chainloop.dev>
@migmartri
Copy link
Member

Please link the issue in the description not in the title of the PR.

@danlishka danlishka changed the title feat: Added SMTP extension, closes #158 feat: Added SMTP extension Jun 14, 2023
Copy link
Member

@migmartri migmartri left a comment

Choose a reason for hiding this comment

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

LGTM!

From string `json:"from" jsonschema:"format=email,description=The email address of the sender."`
User string `json:"user" jsonschema:"minLength=1,description=The username to use for the SMTP authentication."`
Password string `json:"password" jsonschema:"description=The password to use for the SMTP authentication."`
Host string `json:"host" jsonschema:"description=The host to use for the SMTP authentication."`
Copy link
Member

Choose a reason for hiding this comment

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

I see, that makes sense. It's not just a host but also an IP address.

@danlishka danlishka merged commit 700eb42 into chainloop-dev:main Jun 14, 2023
@danlishka danlishka deleted the smtp_ext branch June 14, 2023 09:51
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.

SMTP extension
2 participants