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

Support quotes for the --cluster-name flag #800

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/bot/interactive/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Help(platform config.CommPlatformIntegration, clusterName, botName string)
Header: "Using multiple instances",
Description: fmt.Sprintf("If you are running multiple Botkube instances in the same channel to interact with %s, make sure to specify the cluster name when typing commands.", clusterName),
Body: Body{
CodeBlock: fmt.Sprintf("--cluster-name=%q\n", clusterName),
CodeBlock: fmt.Sprintf("--cluster-name=%s\n", clusterName),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Botkube is now active for "testing" cluster :rocket:
*Using multiple instances*
If you are running multiple Botkube instances in the same channel to interact with testing, make sure to specify the cluster name when typing commands.
```
--cluster-name="testing"
--cluster-name=testing
```

*Manage incoming notifications*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Botkube is now active for "testing" cluster :rocket:<br><br>**Using multiple instances**<br>If you are running multiple Botkube instances in the same channel to interact with testing, make sure to specify the cluster name when typing commands.<br>```
--cluster-name="testing"
--cluster-name=testing
```<br><br>**Manage incoming notifications**<br>```
@Botkube notifier [start|stop|status]
```<br> - `@Botkube notifier start`<br> - `@Botkube notifier stop`<br> - `@Botkube notifier status`<br><br>**Notification settings for this channel**<br>By default, Botkube will notify only about cluster errors and recommendations.<br> - `@Botkube edit SourceBindings`<br><br>**Ping your cluster**<br>Check the status of connected Kubernetes cluster(s).<br> - `@Botkube ping`<br><br>**Run kubectl commands (if enabled)**<br>You can run kubectl commands directly from Platform!<br> - `@Botkube kubectl get services`<br> - `@Botkube kubectl get pods`<br> - `@Botkube kubectl get deployments`<br><br>To list all supported kubectl commands<br> - `@Botkube commands list`<br><br>**Filters (advanced)**<br>You can extend Botkube functionality by writing additional filters that can check resource specs, validate some checks and add messages to the Event struct. Learn more at https://botkube.io/filters<br><br>**Angry? Amazed?**<br>Give feedback: https://feedback.botkube.io<br><br>Read our docs: https://botkube.io/docs<br>Join our Slack: https://join.botkube.io<br>Follow us on Twitter: https://twitter.com/botkube_io<br>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Using multiple instances
If you are running multiple Botkube instances in the same channel to interact with testing, make sure to specify the cluster name when typing commands.
--cluster-name="testing"
--cluster-name=testing


Manage incoming notifications
Expand Down
9 changes: 8 additions & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"regexp"
"strconv"
"strings"

coreV1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -122,7 +123,13 @@ func GetClusterNameFromKubectlCmd(cmd string) string {
if len(matchedArray) >= 2 {
s = matchedArray[1]
}
return s

str, err := strconv.Unquote(s)
if err != nil {
pkosiec marked this conversation as resolved.
Show resolved Hide resolved
return s
}

return str
}

// GVRToString converts GVR formats to string
Expand Down
1 change: 1 addition & 0 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestGetClusterNameFromKubectlCmd(t *testing.T) {
{input: "--cluster-name minikube1", expected: "minikube1"},
{input: "--cluster-name minikube2 -n default", expected: "minikube2"},
{input: "--cluster-name minikube -n=default", expected: "minikube"},
{input: `--cluster-name="minikube"`, expected: "minikube"},
{input: "--cluster-name", expected: ""},
{input: "--cluster-name ", expected: ""},
{input: "--cluster-name=", expected: ""},
Expand Down