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

Output filtering #808

Merged
merged 34 commits into from
Oct 17, 2022
Merged

Output filtering #808

merged 34 commits into from
Oct 17, 2022

Conversation

ezodude
Copy link
Contributor

@ezodude ezodude commented Oct 11, 2022

Description

Changes proposed in this pull request:

  • Enables output filtering of executor based commands with a text output.

Analytics Reporting

ReportCommand(platform config.CommPlatformIntegration, command string, isButtonClickOrigin, withFilter bool) error has been extended to include withFilter to indicate whether a filter was used when running the command.

Testing

Install BotKube:

cat > /tmp/results-filter.yaml << ENDOFFILE
executors:
  'kubectl-enabled':
    kubectl:
      namespaces:
        include:
          - ".*"
        exclude: []
      enabled: true
      commands:
        verbs: ["api-resources", "api-versions", "cluster-info", "describe", "explain", "get", "logs", "top"]
        resources: ["deployments", "pods", "namespaces", "daemonsets", "statefulsets", "storageclasses", "nodes", "configmaps", "services"]
      defaultNamespace: default
      restrictAccess: false

communications:
  'default-group':
    socketSlack:
      enabled: true
      channels:
        'default':
          name: 'random'
          bindings:
            executors:
              - kubectl-enabled
            sources:
              - k8s-err-events
              - k8s-recommendation-events
      botToken: 'xoxb-...'
      appToken: 'xapp-...'
      notification:
        type: short

settings:
  clusterName: kind

  log:
    level: debug
    disableColors: false

analytics:
  disable: true

image:
  repository: kubeshop/pr/botkube
  tag: '808-PR'
  pullPolicy: Always  
ENDOFFILE

helm install botkube ./helm/botkube -n botkube --create-namespace /tmp/results-filter.yaml

Run commands on botkube-test channel on Slack:

@BotKube get po -n kube-system --filter="proxy"
@Botkube commands list --filter=“api”
@BotKube get po -n kube-system --filter=proxy
@BotKube get po --filter="proxy" -n kube-system
@BotKube logs pods/kube-proxy-9qzj2 -n kube-system --filter="Detected node"

Related issue(s)

Resolves #742

@ezodude ezodude requested review from a team and PrasadG193 as code owners October 11, 2022 14:20
@ezodude ezodude requested a review from mszostok October 11, 2022 14:20
@ezodude ezodude marked this pull request as draft October 11, 2022 14:20
@ezodude ezodude marked this pull request as ready for review October 11, 2022 15:19
@ezodude ezodude marked this pull request as draft October 11, 2022 15:20
@ezodude ezodude marked this pull request as ready for review October 11, 2022 15:48
@mszostok mszostok self-assigned this Oct 11, 2022
pkg/execute/executor.go Outdated Show resolved Hide resolved
pkg/execute/executor_filter.go Show resolved Hide resolved
pkg/execute/executor_filter_test.go Outdated Show resolved Hide resolved
test/e2e/bots_test.go Outdated Show resolved Hide resolved
pkg/execute/executor_filter.go Outdated Show resolved Hide resolved
pkg/execute/executor_filter.go Outdated Show resolved Hide resolved
pkg/execute/executor_filter_test.go Show resolved Hide resolved
@mszostok
Copy link
Contributor

Please add proper labels to this PR. Thanks!

@ezodude ezodude added the enhancement New feature or request label Oct 12, 2022
@ezodude
Copy link
Contributor Author

ezodude commented Oct 14, 2022

@mszostok rebased from master and ready - that was painful!

The executor was changed a lot while I was also working on it.

Copy link
Contributor

@mszostok mszostok left a comment

Choose a reason for hiding this comment

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

From the unit-test point of view, the behavior LGTM 👍
However, e2e it doesn't work yet, but as discussed I will go back to testing once you will do the final round of rebasing and rechecking 👍

pkg/execute/executor.go Outdated Show resolved Hide resolved
pkg/execute/executor.go Outdated Show resolved Hide resolved
pkg/execute/executor.go Outdated Show resolved Hide resolved
pkg/execute/executor.go Outdated Show resolved Hide resolved
pkg/execute/executor.go Outdated Show resolved Hide resolved
pkg/execute/executor.go Outdated Show resolved Hide resolved
@ezodude
Copy link
Contributor Author

ezodude commented Oct 14, 2022

  • Updates to ensure command names are visible for commands like ping.
  • E2E tests are now fixed.

@ezodude ezodude requested a review from mszostok October 14, 2022 15:39
Copy link
Contributor

@mszostok mszostok left a comment

Choose a reason for hiding this comment

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

I found one more panic, but besides that it LGTM 👍

pkg/execute/executor.go Outdated Show resolved Hide resolved
@ezodude ezodude merged commit cedde61 into kubeshop:main Oct 17, 2022
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.

Output Filtering
2 participants