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

Include playbook url into mail #105

Conversation

danielgoncharov
Copy link
Contributor

No description provided.

Copy link
Member

@JHK JHK left a comment

Choose a reason for hiding this comment

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

This would certainly do the trick, but I find it rather ugly.

How about modify the SendNotification method to accept a template (if nil just use the text string) and provide the template as some kind of config. The config then can be set with an env variable.

@danielgoncharov
Copy link
Contributor Author

I am a bit hesitant to modify the signature of SendNotification, as it is used not only in the AddUnknownClientId case, thus, I keep it as is and just extracted the the logic to the separate method.

@JHK please have a look whenever you have time

Comment on lines 873 to 874
func getNotification(defaultMessage string) string {
templateString, exists := os.LookupEnv("UNKNOWN_CLIENT_ID_MESSAGE_TEMPLATE")
Copy link
Member

Choose a reason for hiding this comment

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

I still think the signature of this method is too narrow. It is there to serve just a very specific use-case, but there are some other occurrences sending messages where a template could make sense.

I understand the idea of not changing the SendNotification method and agree. It is already simple enough and fulfills one purpose.

The getNotification method is very tailored to the exact occurrence of the one environment variable. This variable is hidden deeply in the code and can only be used when you know it upfront.

I would suggest a different interface:

  • The beetle binary gets parameters to set the name of envionment variables (or files?) to read the templates from
  • Those pointers are stored in the ServerOpts struct (a sub struct)
  • The getNotification method gets another parameter, where you can put the pointer to the template reference
  • The getNotificastion method resolves the template (if it exists) and renders it

This would mean the configuration parameter becomes visible to the outside and the implementation becomes more extensible.

@danielgoncharov
Copy link
Contributor Author

@JHK please have another look whenever you have time

@jojahner
Copy link
Contributor

@danielgoncharov is this still something that you would like to get in?

@danielgoncharov
Copy link
Contributor Author

Lets close it, we will deprecate the whole thing anyway soon

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.

3 participants