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

Introduce global bot name placeholder #979

Merged
merged 2 commits into from
Feb 14, 2023

Conversation

mszostok
Copy link
Contributor

@mszostok mszostok commented Feb 13, 2023

Description

Changes proposed in this pull request:

  • Introduce global bot name placeholder. Now, instead of having direct dependency to a given bot name, you can use {{BotName}} (api.MessageBotNamePlaceholder) placeholder in your messages, and it will be properly handled by a given communication platform. It works not only for commands, but also for all other message properties.
  • Unify sending messages in communication platforms.

Reason
Each bot (Slack, Discord, etc.) exposed the BotName() method and we were passing this across all our source-code. It was only to allow us to construct a proper interactive message. Such approach doesn't scale well. Paweł already introduced the concept of universal bot name placeholder, which is great. However, it was used only in notifier provider. In this PR, I use the universal bot placeholder across all our code base. Now it's up to the bot implementation to render the message with a proper bot name. Such decoupling is needed for extracting kubectl as plugin as we can use api.MessageBotNamePlaceholder instead of passing and using a real bot name in each plugin.

Testing

It's tested e2e, but if you want you can just install Botkube and play with interactive help, and kubectl builder.

Related issue(s)

@mszostok mszostok added the enhancement New feature or request label Feb 13, 2023
@mszostok mszostok marked this pull request as ready for review February 13, 2023 13:48
@mszostok mszostok requested review from a team and PrasadG193 as code owners February 13, 2023 13:48
@mszostok mszostok marked this pull request as draft February 13, 2023 14:02
@mszostok mszostok marked this pull request as ready for review February 13, 2023 14:32
Copy link

@josefkarasek josefkarasek left a comment

Choose a reason for hiding this comment

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

lgtm 👍

errs := multierror.New()
for _, channelID := range b.getChannelsToNotify(sourceBindings) {
b.log.Debugf("Sending message to channel %q: %+v", channelID, msg)

Choose a reason for hiding this comment

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

Can we retain some of the debug logging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is still logged in the send method, so I just removed it to don't have duplicates :)

@josefkarasek josefkarasek force-pushed the kubectl-plugin/bot-name-placeholder branch from 86d0274 to b4b54e1 Compare February 14, 2023 13:45
@mszostok mszostok enabled auto-merge (squash) February 14, 2023 14:04
@mszostok mszostok merged commit b67875f into kubeshop:main Feb 14, 2023
@mszostok mszostok deleted the kubectl-plugin/bot-name-placeholder branch February 14, 2023 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants