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

Introduce support for Source events incoming as external requests #1217

Merged
merged 1 commit into from
Sep 5, 2023

Conversation

pkosiec
Copy link
Member

@pkosiec pkosiec commented Aug 29, 2023

Description

Changes proposed in this pull request:

  • Introduce support for Source events incoming as external requests

Follow-ups:

  • Introduce docs
  • [nice to have] Validate incoming requests with provided JSON schema from metadata

Testing

Integration tests cover this piece of functionality. However, you can test it by yourself with cm-watcher:

Checkout this PR:

gh pr checkout 1217

Build plugins:

PLUGIN_DOWNLOAD_URL_BASE_PATH="http://localhost:64538/plugin-dist" make gen-plugins-index
npx serve --listen 64538

Prepare Botkube config:

sources:
  'cm-watcher':
    displayName: "K8s ConfigMaps changes"
    botkube/cm-watcher:
      enabled: true
      context:
        rbac:
          group:
            type: Static
            static:
              values: [ "priv-channel" ]
      config:
        configMap:
          name: cm-watcher-trigger
          namespace: botkube
          event: ADDED

communications:
  "default-group":
    socketSlack:
      enabled: true
      appToken: "xapp-"
      botToken: "xoxb-"
      channels:
        "default":
          name: "botkube-demo"
          bindings:
            executors: []
            sources:
              - cm-watcher
              - k8s-all-events

plugins:
  repositories:
    botkube:
       url: http://localhost:64538/plugins-dev-index.yaml

Run Botkube:

export KUBECONFIG=/Users/pkosiec/oci-playground/kubeconfi
export BOTKUBE_SETTINGS_LOG_LEVEL=debug
export BOTKUBE_PLUGINS_CACHE__DIR="/tmp/plugins"
export BOTKUBE_CONFIG_PATHS="$(pwd)/helm/botkube/values.yaml,$(pwd)/comm_config.yaml"
export LOG_LEVEL_SOURCE_BOTKUBE_CM_WATCHER="debug"
go run ./cmd/botkube-agent/main.go

Run requests:

This will fail:

curl --request POST \
  --url http://localhost:2115/sources/v1/k8s-all-events \
  --header 'Content-Type: application/json' \
  --data '{
	"message": "Foo"
}'

But this will succeed:

curl --request POST \
  --url http://localhost:2115/sources/v1/cm-watcher \
  --header 'Content-Type: application/json' \
  --data '{
	"message": "Foo"
}'

Related issue(s)

#1175

@pkosiec pkosiec added the enhancement New feature or request label Aug 29, 2023
@pkosiec pkosiec marked this pull request as ready for review August 30, 2023 09:38
@pkosiec pkosiec requested review from PrasadG193 and a team as code owners August 30, 2023 09:38
@pkosiec pkosiec enabled auto-merge (squash) September 5, 2023 13:58
@pkosiec pkosiec merged commit 4798f8f into kubeshop:main Sep 5, 2023
14 checks passed
@pkosiec pkosiec deleted the handle-external-requests branch September 5, 2023 14:40
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