Send the cluster name for all interactive commands #1091
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Changes proposed in this pull request:
-Send the cluster name for all interactive commands
The current implementation is quite hacky. The main problem is that only buttons are easily to handle as we know the whole command up front and we can simply add
--cluster-name
flag.For all others, like selects, inputs, etc. the command is constructed either via
botkube/pkg/bot/socketslack.go
Lines 517 to 544 in 428e624
or by using state
botkube/internal/executor/kubectl/builder/kubectl.go
Line 393 in 428e624
This introduces additional complexity that we need to handle when we are injecting the
--cluster-name
flag as otherwise we will break the parsing on the plugin side.Notes
I tried to use a new field, use ids, and slack message metadata, none of them worked for me 😞 So I ended up with this kinda ugly solution.
Future
Because of the current architecture, I cannot normalize it in a more straightforward way. IMO we should decouple slack commands and slack state. I would see sth like:
metadata
which ismap[string]string
that holds the data that we extract from the Slack state. This way our plugins won't parse the initial slack state and as a result we can hold more details in the state that will be only handled in the core code.Testing