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

move notification formatting to each of the integrations #254

Open
MagnusRef opened this issue Nov 26, 2024 · 0 comments
Open

move notification formatting to each of the integrations #254

MagnusRef opened this issue Nov 26, 2024 · 0 comments

Comments

@MagnusRef
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Hello

Currently as of writing the format of the message string returned in getNotificationMessage includes a static description of the related cluster plus the actual message(s).

func getNotificationMessage(clusterNamespace, clusterName string, clusterType libsveltosv1beta1.ClusterType,
conditions []libsveltosv1beta1.Condition, logger logr.Logger) (string, bool) {
passing := true
message := fmt.Sprintf("cluster %s:%s/%s \n", clusterType, clusterNamespace, clusterName)
for i := range conditions {
c := &conditions[i]
if c.Status != corev1.ConditionTrue {
passing = false
message += fmt.Sprintf("liveness check %q failing \n", c.Type)
message += fmt.Sprintf("%s \n", c.Message)
}
}
if passing {
message += "all liveness checks are passing"
logger.V(logs.LogDebug).Info("all liveness checks are passing")
} else {
logger.V(logs.LogDebug).Info("some of the liveness checks are not passing")
}
return message, passing
}

This makes it rather difficult to implement custom formatting for each of the notification implementation. (e.g. Slack, Teams).

For example I would like in the future to propose changing the Teams notification to use a more rich format instead of the current bland messages.

Describe the solution you'd like

My suggestion would be to just return the message string without the fmt.Sprintf("cluster %s:%s/%s \n", clusterType, clusterNamespace, clusterName) prefix, and let each implementation choose how it should be shown.

This would make it more flexible for each of the notification integration to tailor how it should look, since they are quite different from each other and each of them have different features available.

Describe alternatives you've considered

Alternatively beside the original message string, you could also just return a list of the messages, so each integration can pick and choose between original format or a more free format. This would keep it more DRY, since Im guessing that most of the notifications integration will keep the original format.

Additional context

in #162 I hinted at this

Currently these Messages are quite simple, so it would be cool in the furture if you could get a more parsable return from getNotificationMessage(), as Teams adaptive cards have a lot of features like formatting.

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

No branches or pull requests

1 participant