This rearranges the tests a little to make it easier to test for
events being filtered (not forwarded).
Signed-off-by: Michael Bridgen <michael@weave.works>
This adds some scaffolding for testing that events are forwarded as
specified by alerts.
The controllers themselves aren't needed; but since the
internal/server package refer directly to Kubernetes resources, the
tests share prerequisites with controller tests. For that reason I
have started by putting these tests in controllers/.
I have tried not to touch the server code itself, but it was necessary
to change it to use a fresh http.ServerMux rather than the (global)
default, so that the tests can create an event server each.
Signed-off-by: Michael Bridgen <michael@weave.works>
Running the following command works on macOS (`LibreSSL 2.8.3`) but prints polluted output on Linux (`OpenSSL 1.1.1i 8 Dec 2020`)
```bash
printf '{}' | openssl dgst -sha1 -hmac "<secret-key>"
(macOS)> c75d9c41825117acf1f7a80b366fa1d47caf6962
(linux)> (stdin)= c75d9c41825117acf1f7a80b366fa1d47caf6962
```
The coreutils format output, with `-r`, adds `*stdin` at the end, removing it with `awk` make it works on both environments.
```bash
printf '{}' | openssl dgst -sha1 -r -hmac "<secret-key>" | awk '{print $1}'
(macOS)> c75d9c41825117acf1f7a80b366fa1d47caf6962
(linux)> c75d9c41825117acf1f7a80b366fa1d47caf6962
```
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
Using the helper from `pkg/runtime/pprof`, which follows the suggestion
from controller-runtime to use `AddMetricsExtraHandler`.
Signed-off-by: Hidde Beydals <hello@hidde.co>
As with ImageUpdateAutomation, it's useful to allow alerts to process
events from ImagePolicy objects. Letting them be the target of webhook
triggers is not useful, since they don't support the reconcile request
protocol -- but is better than making a special case for them.
Signed-off-by: Michael Bridgen <michael@weave.works>
This adds ImageUpdateAutomation as a kind allowed by cross-namespace
object references here. That has two effects:
- ImageUpdateAutomation objects can be the source of events; and,
- ImageUpdateAutomation objects can be the target of webhook
triggers.
Of these, the first is certainly desirable (e.g,. now you can post a
Slack message when automation fails). The second may be useful, though
automations will more usually be triggered by ImageRepository objects
changing, and anyway doesn't hurt.
Signed-off-by: Michael Bridgen <michael@weave.works>