kyverno / policy-reporter

Monitoring and Observability Tool for the PolicyReport CRD with an optional UI.
https://kyverno.github.io/policy-reporter/
MIT License
270 stars 79 forks source link

Slack Channel Override does not work #458

Closed jescarri closed 2 months ago

jescarri commented 2 months ago

The configuration schema supports setting the slack channel per each notification channel, like this:

slack:
  channels:
    - channel: kyverno-reports1
      customFields:
        cluster: Avocado
      filter:
        namespaces:
          include:
          - foo
          - bar
        policies:
          include:
          - test-policy
        priorities:
          include: warning
      name: team1
      skipExistingOnStartup: false
      sources:
      - kyverno
      webhook: SlackWebhook

However slack messages end up in the default channel of the webhook, I have traced the issue to the slack newPayload function, it does not set the slack channel in the payload.

I see the client config etc properly populating the channel and config read from the file.

I have it fixed by adding code like this:

+       if s.channel != "" {
+               p.Channel = s.channel
+       }

I can submit a patch if this is an issue and it's not a problem with my config file.

Thanks for the help!.

fjogeleit commented 2 months ago

Thanks for reporting, if you would provide a fix as PR I would appreciate it.

jescarri commented 2 months ago

Sweet, let me get the PR ready.

Thanks for your response.

jescarri commented 2 months ago

Hi @fjogeleit I found another bug regarding slack channels when using the a secret reference for the webhook configuration, I will submit the PR in a bit.

Thanks!

fjogeleit commented 2 months ago

Your changes were released with helm chart v24.0.1

thanks for your support