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 global aliases for commands #956

Merged
merged 10 commits into from
Jan 31, 2023
Merged

Conversation

pkosiec
Copy link
Member

@pkosiec pkosiec commented Jan 30, 2023

Description

Changes proposed in this pull request:

  • Expand aliases when executing commands
  • Add @Botkube list aliases command
  • Modify @Botkube list executors to include aliases for executors
  • Unify output of @Botkube list sources command
  • Update help
    • Remove notice about required prefix
    • Add ability to list aliases
  • Update E2E tests
  • Add basic validation for aliases commands
    • I thought about checking executor names, but I wouldn't like to limit users. It's good to allow defining aliases for Botkube commands as well. Such validation would be too cumbersome for us to maintain (import cycles when it comes to cmd verbs) so I'd postpone this until someone reports an issue.

TODO

  • Update documentation - in a separate PR to botkube-docs.

Screenshots

Help

image

List executors

image

List sources

image

Executing commands

image

image

List aliases

image

image

image

Filtering

image

Testing

Check out the PR

Use the following config:

plugins:
  repositories:
    botkube:
      url: https://storage.googleapis.com/botkube-plugins-latest/plugins-index.yaml

communications:
  "default-group":
    socketSlack:
      enabled: true
      appToken: "xapp-..."
      botToken: "xoxb-..."
      notification:
        type: "short"
      channels:
        "default":
          name: botkube-demo
          bindings:
            executors:
              - kubectl-read-only
              - helm
              - plugin-based
            sources:
              - k8s-all-events
              - k8s-recommendation-events
              - plugin-based

executors:
  'kubectl-read-only':
    kubectl:
      enabled: true
  helm:
     botkube/helm:
       config:
         helmCacheDir: /tmp/helm/.cache
         helmConfigDir: /tmp/helm/
         helmDriver: secret
       enabled: true
  'plugin-based':
    botkube/[email protected]:
      enabled: false
      config:
        changeResponseToUpperCase: true

aliases:
  kc:
    command: kubectl
    displayName: "Kubectl alias"
  k:
    command: kubectl
    displayName: "Kubectl alias"
  kgp:
    command: kubectl get pods
    displayName: "Get pods"
  h:
    command: helm
    displayName: "Helm alias"
  e:
    command: echo
    displayName: "Echo alias"

sources:
  'plugin-based':
    displayName: "K8s ConfigMaps changes"
    botkube/cm-watcher:
      enabled: true
      config:
        configMap:
          name: cm-watcher-trigger
          namespace: botkube
          event: ADDED

settings:
  clusterName: "dev"
  upgradeNotifier: false

Run a few commands:

@Botkube kgp -n botkube
@Botkube h version
@Botkube k get po

Run @Botkube list aliases
Run @Botkube list executors

Related issue(s)

#870

@pkosiec pkosiec added the enhancement New feature or request label Jan 30, 2023
@pkosiec pkosiec added this to the v0.18.0 milestone Jan 30, 2023
@pkosiec pkosiec force-pushed the executor-aliases branch 4 times, most recently from 4c99f74 to 8743452 Compare January 30, 2023 16:34
@pkosiec pkosiec marked this pull request as ready for review January 31, 2023 13:20
@pkosiec pkosiec requested review from a team and PrasadG193 as code owners January 31, 2023 13:20
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.

Overall LGMT. With minor nits.

pkg/config/config.go Outdated Show resolved Hide resolved
pkg/execute/alias.go Outdated Show resolved Hide resolved
pkg/execute/executor.go Show resolved Hide resolved
pkg/execute/kubectl_cmd_builder.go Outdated Show resolved Hide resolved
@pkosiec pkosiec enabled auto-merge (squash) January 31, 2023 16:09
@pkosiec pkosiec merged commit a329c8e into kubeshop:main Jan 31, 2023
@pkosiec pkosiec deleted the executor-aliases branch January 31, 2023 16:26
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