Skip to content

Commit

Permalink
Rename x plugin to exec
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Jul 12, 2023
1 parent 26b95ab commit 31098f6
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 67 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/process-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
HELM_DOCS_VERSION: 1.11.0
CHART_REPOSITORY: https://charts.botkube.io/
LATEST_PLUGIN_INDEX_URL: https://storage.googleapis.com/botkube-plugins-latest/plugins-index.yaml
LATEST_X_PLUGIN_TPLS_URL: github.com/kubeshop/botkube//cmd/executor/x/templates?ref=main
LATEST_X_PLUGIN_TPLS_URL: github.com/kubeshop/botkube//cmd/executor/exec/templates?ref=main

on:
workflow_call:
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
find ${HELM_FOLDER} -name "*.yaml" -exec sed -i "s/${CHART_CURRENT_VERSION}/${{ inputs.next-version }}/g" {} +
find ${HELM_FOLDER} -name "*.yaml" -exec sed -i "s/${CHART_DEV_VERSION}/${{ inputs.next-version }}/g" {} +
find ${HELM_FOLDER} -name "*.yaml" -exec sed -i "s~${LATEST_PLUGIN_INDEX_URL}~https://github.com/kubeshop/botkube/releases/download/${{ inputs.next-version }}/plugins-index.yaml~g" {} +
find ${HELM_FOLDER} -name "*.yaml" -exec sed -i "s~${LATEST_X_PLUGIN_TPLS_URL}~github.com/kubeshop/botkube//cmd/executor/x/templates?ref=${{ inputs.next-version }}~g" {} +
find ${HELM_FOLDER} -name "*.yaml" -exec sed -i "s~${LATEST_X_PLUGIN_TPLS_URL}~github.com/kubeshop/botkube//cmd/executor/exec/templates?ref=${{ inputs.next-version }}~g" {} +
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.2.1
Expand Down
6 changes: 3 additions & 3 deletions .goreleaser.plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ builds:
goarch: *goarch
goarm: *goarm

- id: x
main: cmd/executor/x/main.go
binary: executor_x_{{ .Os }}_{{ .Arch }}
- id: exec
main: cmd/executor/exec/main.go
binary: executor_exec_{{ .Os }}_{{ .Arch }}

no_unique_dist_dir: true
env: *env
Expand Down
16 changes: 8 additions & 8 deletions cmd/executor/x/main.go → cmd/executor/exec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ import (
// version is set via ldflags by GoReleaser.
var version = "dev"

const pluginName = "x"
const pluginName = "exec"

// XExecutor implements Botkube executor plugin.
type XExecutor struct{}

func (i *XExecutor) Help(_ context.Context) (api.Message, error) {
help := heredoc.Doc(`
Usage:
x run [COMMAND] [FLAGS] Run a specified command with optional flags
x install [SOURCE] Install a binary using the https://github.com/zyedidia/eget syntax.
exec run [COMMAND] [FLAGS] Run a specified command with optional flags
exec install [SOURCE] Install a binary using the https://github.com/zyedidia/eget syntax.
Usage Examples:
# Install the Helm CLI
x install https://get.helm.sh/helm-v3.10.3-linux-amd64.tar.gz --file helm
exec install https://get.helm.sh/helm-v3.10.3-linux-amd64.tar.gz --file helm
# Run the 'helm list -A' command.
x run helm list -A
exec run helm list -A
Options:
-h, --help Show this help message`)
Expand Down Expand Up @@ -151,7 +151,7 @@ func (i *XExecutor) Execute(ctx context.Context, in executor.ExecuteInput) (exec
case cmd.Install != nil:
var (
tool = Normalize(strings.Join(cmd.Install.Tool, " "))
command = x.Parse(fmt.Sprintf("x install %s", tool))
command = x.Parse(fmt.Sprintf("exec install %s", tool))
dir, isCustom = cfg.TmpDir.Get()
downloadCmd = fmt.Sprintf("eget %s", tool)
)
Expand Down Expand Up @@ -210,7 +210,7 @@ func jsonSchema() api.JSONSchema {
return api.JSONSchema{
Value: heredoc.Docf(`{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "x",
"title": "exec",
"description": "Install and run CLIs directly from the chat window without hassle. All magic included.",
"type": "object",
"properties": {
Expand Down Expand Up @@ -247,7 +247,7 @@ func getDefaultTemplateSource() string {
if ver == "dev" {
ver = "main"
}
return fmt.Sprintf("github.com/kubeshop/botkube//cmd/executor/x/templates?ref=%s", ver)
return fmt.Sprintf("github.com/kubeshop/botkube//cmd/executor/exec/templates?ref=%s", ver)
}

func Normalize(in string) string {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ templates:
- trigger:
command:
prefix: "x install github.com/fluxcd/flux2"
prefix: "exec install github.com/fluxcd/flux2"
type: "wrapper"
message:
buttons:
- name: "Quickstart"
command: "{{BotName}} x run quickstart flux"
command: "{{BotName}} exec run quickstart flux"
style: "primary"

- trigger:
Expand All @@ -36,14 +36,14 @@ templates:
header: "Flux Quick Start tutorial"
buttons:
- name: "Check prerequisites"
command: "{{BotName}} x run flux check --pre"
command: "{{BotName}} exec run flux check --pre"
description: "{{BotName}} flux check --pre"
- name: "Install Flux"
command: "{{BotName}} x run flux install"
command: "{{BotName}} exec run flux install"
description: "{{BotName}} flux install"
- name: "Create Git source"
command: |
{{BotName}} x run flux create source git webapp-latest
{{BotName}} exec run flux create source git webapp-latest
--url=https://github.com/stefanprodan/podinfo
--branch=master
--interval=3m
Expand All @@ -53,17 +53,17 @@ templates:
--branch=master
--interval=3m
- name: "List Git sources"
command: "{{BotName}} x run flux get sources git"
command: "{{BotName}} exec run flux get sources git"
description: "{{BotName}} flux get sources git"
- name: "Reconcile Git source"
command: "{{BotName}} x run flux reconcile source git flux-system"
command: "{{BotName}} exec run flux reconcile source git flux-system"
description: "{{BotName}} flux reconcile source git flux-system"
- name: "Export Git sources"
command: "{{BotName}} x run flux export source git --all"
command: "{{BotName}} exec run flux export source git --all"
description: "{{BotName}} flux export source git --all"
- name: "Create Kustomization"
command: |
{{BotName}} x run flux create kustomization webapp-dev
{{BotName}} exec run flux create kustomization webapp-dev
--source=webapp-latest
--path='./deploy/webapp/'
--prune=true
Expand All @@ -72,7 +72,7 @@ templates:
--health-check='Deployment/frontend.webapp'
--health-check-timeout=2m
description: |
{{BotName}} x run flux create kustomization webapp-dev
{{BotName}} exec run flux create kustomization webapp-dev
--source=webapp-latest
--path='./deploy/webapp/'
--prune=true
Expand All @@ -81,29 +81,29 @@ templates:
--health-check='Deployment/frontend.webapp'
--health-check-timeout=2m
- name: "Reconcile Kustomization"
command: "{{BotName}} x run flux reconcile kustomization webapp-dev --with-source"
command: "{{BotName}} exec run flux reconcile kustomization webapp-dev --with-source"
description: "{{BotName}} flux reconcile kustomization webapp-dev --with-source"
- name: "Suspend Kustomization"
command: "{{BotName}} x run flux suspend kustomization webapp-dev"
command: "{{BotName}} exec run flux suspend kustomization webapp-dev"
description: "{{BotName}} flux suspend kustomization webapp-dev"
- name: "Export Kustomizations"
command: "{{BotName}} x run flux export kustomization --all"
command: "{{BotName}} exec run flux export kustomization --all"
description: "{{BotName}} flux export kustomization --all"
- name: "Resume Kustomization"
command: "{{BotName}} x run flux resume kustomization webapp-dev"
command: "{{BotName}} exec run flux resume kustomization webapp-dev"
description: "{{BotName}} flux resume kustomization webapp-dev"
- name: "Delete Kustomization"
command: "{{BotName}} x run flux delete kustomization webapp-dev"
command: "{{BotName}} exec run flux delete kustomization webapp-dev"
description: "{{BotName}} flux delete kustomization webapp-dev"
- name: "Delete Git source"
command: "{{BotName}} x run flux delete source git webapp-latest"
command: "{{BotName}} exec run flux delete source git webapp-latest"
description: "{{BotName}} flux delete source"
- name: "Delete Kustomization"
command: "{{BotName}} x run flux delete kustomization webapp-dev"
command: "{{BotName}} exec run flux delete kustomization webapp-dev"
description: "{{BotName}} flux delete kustomization webapp-dev"
- name: "Delete Git source"
command: "{{BotName}} x run flux delete source git webapp-latest --silent"
command: "{{BotName}} exec run flux delete source git webapp-latest --silent"
description: "{{BotName}} flux delete source git webapp-latest --silent"
- name: "Uninstall Flux"
command: "{{BotName}} x run flux uninstall"
command: "{{BotName}} exec run flux uninstall"
description: "{{BotName}} flux uninstall"
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ templates:
- trigger:
command:
prefix: "x install https://get.helm.sh/helm-v"
prefix: "exec install https://get.helm.sh/helm-v"
type: "wrapper"
message:
buttons:
- name: "Quickstart"
command: "{{BotName}} x run quickstart helm"
command: "{{BotName}} exec run quickstart helm"
style: "primary"

- trigger:
Expand All @@ -38,31 +38,31 @@ templates:
buttons:
- name: "Global Help"
description: "{{BotName}} helm help"
command: "{{BotName}} x run helm help"
command: "{{BotName}} exec run helm help"
- name: "Version"
description: "{{BotName}} helm version"
command: "{{BotName}} x run helm version"
command: "{{BotName}} exec run helm version"
- name: "Install help"
description: "{{BotName}} helm install -h"
command: "{{BotName}} x run helm install -h"
command: "{{BotName}} exec run helm install -h"
- name: "Install by absolute URL"
description: "{{BotName}} helm install\n--repo https://charts.bitnami.com/bitnami psql postgresql\n--set clusterDomain='testing.local'"
command: "{{BotName}} x run helm install\n--repo https://charts.bitnami.com/bitnami psql postgresql\n--set clusterDomain='testing.local'"
command: "{{BotName}} exec run helm install\n--repo https://charts.bitnami.com/bitnami psql postgresql\n--set clusterDomain='testing.local'"
- name: "Install by chart reference:"
description: "{{BotName}} helm install https://charts.bitnami.com/bitnami/postgresql-12.1.0.tgz --create-namespace -n test --generate-name"
command: "{{BotName}} x run helm install https://charts.bitnami.com/bitnami/postgresql-12.1.0.tgz --create-namespace -n test --generate-name"
command: "{{BotName}} exec run helm install https://charts.bitnami.com/bitnami/postgresql-12.1.0.tgz --create-namespace -n test --generate-name"
- name: "List"
description: "{{BotName}} helm list -A"
command: "{{BotName}} x run helm list -A"
command: "{{BotName}} exec run helm list -A"
- name: "List with filter"
description: "{{BotName}} helm list -f 'p' -A"
command: "{{BotName}} x run helm list -f 'p' -A"
command: "{{BotName}} exec run helm list -f 'p' -A"
- name: "Status"
description: "{{BotName}} helm status psql"
command: "{{BotName}} x run helm status psql"
command: "{{BotName}} exec run helm status psql"
- name: "Upgrade"
description: "{{BotName}} helm upgrade --repo https://charts.bitnami.com/bitnami psql postgresql --set clusterDomain='cluster.local'"
command: "{{BotName}} x run helm upgrade --repo https://charts.bitnami.com/bitnami psql postgresql --set clusterDomain='cluster.local'"
command: "{{BotName}} exec run helm upgrade --repo https://charts.bitnami.com/bitnami psql postgresql --set clusterDomain='cluster.local'"
- name: "History"
description: "{{BotName}} helm history psql"
command: "{{BotName}} x run helm history psql"
command: "{{BotName}} exec run helm history psql"
8 changes: 4 additions & 4 deletions helm/botkube/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ Controller for the Botkube Slack app which helps you monitor your Kubernetes clu
| [sources.k8s-all-events.botkube/kubernetes.context.rbac](./values.yaml#L126) | object | `{"group":{"prefix":"","static":{"values":["botkube-plugins-default"]},"type":"Static"}}` | RBAC configuration for this plugin. |
| [sources.k8s-err-events.botkube/kubernetes.context.rbac](./values.yaml#L126) | object | `{"group":{"prefix":"","static":{"values":["botkube-plugins-default"]},"type":"Static"}}` | RBAC configuration for this plugin. |
| [sources.k8s-create-events.botkube/kubernetes.context.rbac](./values.yaml#L126) | object | `{"group":{"prefix":"","static":{"values":["botkube-plugins-default"]},"type":"Static"}}` | RBAC configuration for this plugin. |
| [executors.bins-management.botkube/x.context.rbac](./values.yaml#L126) | object | `{"group":{"prefix":"","static":{"values":["botkube-plugins-default"]},"type":"Static"}}` | RBAC configuration for this plugin. |
| [executors.bins-management.botkube/exec.context.rbac](./values.yaml#L126) | object | `{"group":{"prefix":"","static":{"values":["botkube-plugins-default"]},"type":"Static"}}` | RBAC configuration for this plugin. |
| [executors.k8s-default-tools.botkube/helm.context.rbac](./values.yaml#L126) | object | `{"group":{"prefix":"","static":{"values":["botkube-plugins-default"]},"type":"Static"}}` | RBAC configuration for this plugin. |
| [executors.ai.botkube/doctor.context.rbac](./values.yaml#L126) | object | `{"group":{"prefix":"","static":{"values":["botkube-plugins-default"]},"type":"Static"}}` | RBAC configuration for this plugin. |
| [executors.k8s-default-tools.botkube/kubectl.context.rbac](./values.yaml#L126) | object | `{"group":{"prefix":"","static":{"values":["botkube-plugins-default"]},"type":"Static"}}` | RBAC configuration for this plugin. |
| [sources.k8s-create-events.botkube/kubernetes.context.rbac.group.type](./values.yaml#L129) | string | `"Static"` | Static impersonation for a given username and groups. |
| [executors.bins-management.botkube/x.context.rbac.group.type](./values.yaml#L129) | string | `"Static"` | Static impersonation for a given username and groups. |
| [executors.bins-management.botkube/exec.context.rbac.group.type](./values.yaml#L129) | string | `"Static"` | Static impersonation for a given username and groups. |
| [sources.k8s-err-events.botkube/kubernetes.context.rbac.group.type](./values.yaml#L129) | string | `"Static"` | Static impersonation for a given username and groups. |
| [sources.k8s-all-events.botkube/kubernetes.context.rbac.group.type](./values.yaml#L129) | string | `"Static"` | Static impersonation for a given username and groups. |
| [sources.k8s-err-events-with-ai-support.botkube/kubernetes.context.rbac.group.type](./values.yaml#L129) | string | `"Static"` | Static impersonation for a given username and groups. |
Expand All @@ -74,11 +74,11 @@ Controller for the Botkube Slack app which helps you monitor your Kubernetes clu
| [executors.ai.botkube/doctor.context.rbac.group.prefix](./values.yaml#L131) | string | `""` | Prefix that will be applied to .static.value[*]. |
| [sources.k8s-err-events-with-ai-support.botkube/kubernetes.context.rbac.group.prefix](./values.yaml#L131) | string | `""` | Prefix that will be applied to .static.value[*]. |
| [sources.k8s-all-events.botkube/kubernetes.context.rbac.group.prefix](./values.yaml#L131) | string | `""` | Prefix that will be applied to .static.value[*]. |
| [executors.bins-management.botkube/x.context.rbac.group.prefix](./values.yaml#L131) | string | `""` | Prefix that will be applied to .static.value[*]. |
| [executors.bins-management.botkube/exec.context.rbac.group.prefix](./values.yaml#L131) | string | `""` | Prefix that will be applied to .static.value[*]. |
| [sources.k8s-create-events.botkube/kubernetes.context.rbac.group.prefix](./values.yaml#L131) | string | `""` | Prefix that will be applied to .static.value[*]. |
| [executors.k8s-default-tools.botkube/kubectl.context.rbac.group.prefix](./values.yaml#L131) | string | `""` | Prefix that will be applied to .static.value[*]. |
| [sources.k8s-create-events.botkube/kubernetes.context.rbac.group.static.values](./values.yaml#L134) | list | `["botkube-plugins-default"]` | Name of group.rbac.authorization.k8s.io the plugin will be bound to. |
| [executors.bins-management.botkube/x.context.rbac.group.static.values](./values.yaml#L134) | list | `["botkube-plugins-default"]` | Name of group.rbac.authorization.k8s.io the plugin will be bound to. |
| [executors.bins-management.botkube/exec.context.rbac.group.static.values](./values.yaml#L134) | list | `["botkube-plugins-default"]` | Name of group.rbac.authorization.k8s.io the plugin will be bound to. |
| [sources.k8s-err-events-with-ai-support.botkube/kubernetes.context.rbac.group.static.values](./values.yaml#L134) | list | `["botkube-plugins-default"]` | Name of group.rbac.authorization.k8s.io the plugin will be bound to. |
| [executors.ai.botkube/doctor.context.rbac.group.static.values](./values.yaml#L134) | list | `["botkube-plugins-default"]` | Name of group.rbac.authorization.k8s.io the plugin will be bound to. |
| [sources.k8s-recommendation-events.botkube/kubernetes.context.rbac.group.static.values](./values.yaml#L134) | list | `["botkube-plugins-default"]` | Name of group.rbac.authorization.k8s.io the plugin will be bound to. |
Expand Down
8 changes: 4 additions & 4 deletions helm/botkube/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -555,19 +555,19 @@ executors:
context: *default-plugin-context

bins-management:
## X executor configuration.
## Exec executor configuration.
## Plugin name syntax: <repo>/<plugin>[@<version>]. If version is not provided, the latest version from repository is used.
botkube/x:
botkube/exec:
enabled: false
context: *default-plugin-context
## -- Custom x plugin configuration.
## -- Custom exec plugin configuration.
config:
## -- An array of templates that define how to convert the command output into an interactive message.
templates:
## -- Link to templates source
## It uses the go-getter library, which supports multiple URL formats (such as HTTP, Git repositories, or S3) and is able to unpack archives.
## For more details, see the documentation at https://github.com/hashicorp/go-getter.
- ref: github.com/kubeshop/botkube//cmd/executor/x/templates?ref=main
- ref: github.com/kubeshop/botkube//cmd/executor/exec/templates?ref=main

ai:
## Doctor executor configuration.
Expand Down
16 changes: 8 additions & 8 deletions internal/executor/x/cmd_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ func TestParse(t *testing.T) {
expected Command
}{
{
input: "x run helm list -A",
input: "exec run helm list -A",
expected: Command{
ToExecute: "x run helm list -A",
ToExecute: "exec run helm list -A",
IsRawRequired: false,
},
},
{
input: "x run helm list -A @raw",
input: "exec run helm list -A @raw",
expected: Command{
ToExecute: "x run helm list -A",
ToExecute: "exec run helm list -A",
IsRawRequired: true,
},
},
{
input: "x run kubectl get pods @idx:123",
input: "exec run kubectl get pods @idx:123",
expected: Command{
ToExecute: "x run kubectl get pods",
ToExecute: "exec run kubectl get pods",
IsRawRequired: false,
},
},
{
input: "x run kubectl get pods @idx:abc",
input: "exec run kubectl get pods @idx:abc",
expected: Command{
ToExecute: "x run kubectl get pods @idx:abc",
ToExecute: "exec run kubectl get pods @idx:abc",
IsRawRequired: false,
PageIndex: 1,
},
Expand Down
Loading

0 comments on commit 31098f6

Please sign in to comment.