Commit Graph

121 Commits

Author SHA1 Message Date
Stefan Prodan 3aba5bbd39
Update Helm APIs to v1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-05-02 21:00:30 +03:00
Stefan Prodan 6ba1a713fe
Sanitize provider data loaded from secret
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-04-09 18:35:01 +03:00
adam b4949b6e05 Implement CDEvents Receiver
Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Added CDEvents Receiver

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Added CDEvent Validation + Tests

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Small changes to CDEvent Receiver

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

More CDEvents Tests and Docs added

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Adding imports to go.mod

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

small changes + manifests and formatting

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Changing string compare to EqualFold

Signed-off-by: adamkenihan <adam.kenihan@est.tech>
2024-03-27 10:36:51 +00:00
Sunny 68c38244cc Exclude eventv1.MetaTokenKey from event metadata
eventv1.MetaTokenKey is required to be considered in rate limiting but
it is only for internal use by flux components and should not be sent to
the alert provider. Remove eventv1.MetaTokenKey from the metadata of
event before processing the event for various matching alerts.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-12-13 23:13:38 +05:30
Matheus Pimenta 143a0b3ee0 Remove URL syntax validation for provider address entirely
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-12-12 19:01:31 +00:00
Max Jonas Werner 52d8945284
Cap provider address at 2048 bytes
The provider address is already capped at 2048 bytes in the CRD and
this commit adds the same upper limit when reading the address from a
Secret.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-11-28 12:31:20 +01:00
Sunny 6df2c74b2a event_handler: Use proper ctx for post fail log
Use the context containing proper information about the event for
logging. Previously, the logged error didn't contain any information
about the event, alert or the involved object.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Sunny 19a60e98ea event handler: Add k8s events for Alerts
Emit events in the event handler along with logs on the respective alert
to make the message visible on the alert it belongs to.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Sunny 80f7237673 Refactor event handler
- Break down the EventServer.handleEvent() implementation into multiple
  smaller functions which are extensively tested on their own.
  - New implementation of filter Alerts for Event
  - New implementation of Event matches Alert
- Remove any readiness check on Alert or Provider.
- Add kubebuilder marker for generating RBAC permissions to create and
  patch events, and query Alert and Provider objects.
- Convert the event handler test from controllers/ dir to work with
  just EventServer without any reconciler, keeping all the test cases
  and slightly modified test set up code.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Hidde Beydals 3dce75a07e
misc: fix hypothetical implicit memory aliasing
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-11 15:02:56 +02:00
Hidde Beydals edb6a54e23
misc: take errs into account
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-11 15:01:35 +02:00
Hidde Beydals 23d57eb9d3
misc: use `strings.EqualFold`
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-10 12:07:31 +02:00
Hidde Beydals 30db06d0df
misc: do not capitalize err strings
Except for where names are being used (e.g. `Authorization` header,
Nexus, etc.)

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-10 12:07:30 +02:00
Somtochi Onyekwere 23e733b9c7 use kubernetes tls style secret in provider
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2023-08-23 14:06:15 +01:00
Somtochi Onyekwere 4f5d2dfdb8 use TrimPrefix instead of TrimLeft
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2023-08-01 16:31:15 +01:00
Stefan Prodan 749a6c4cb7
Update dependencies
- k8s.io/* v0.27.3
- cloud.google.com/go/pubsub v1.31.0
- github.com/Azure/azure-event-hubs-go/v3 v3.6.0
- github.com/getsentry/sentry-go v0.22.0
- github.com/google/go-github/v53 v53.2.0
- github.com/ktrysmt/go-bitbucket v0.9.60
- github.com/xanzy/go-gitlab v0.86.0
- github.com/fluxcd/pkg/runtime v0.39.0

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-06-27 11:16:42 +03:00
Matheus Pimenta ae6cc4b4f6 Reduce logging repeated code in event server
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-06-12 14:26:59 +01:00
Hidde Beydals b7cccbee81 Prefix event key attributes with identifier
This to prevent collisions between different event attributes.

For example when first an event with revision `foo` is received
without a token, after which a token `foo` is received without a
revision.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-05-24 15:52:46 +02:00
Matheus Pimenta 8c11d8a19b Fix Alert .spec.eventMetadata behavior
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-05-24 11:27:27 +01:00
Matheus Pimenta 4e05bc8ee2 Include eventv1.MetaTokenKey on event rate limiting key calculation
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-05-24 11:30:14 +02:00
Hidde Beydals 49122b90b1
Merge pull request #517 from matheuscscp/fix-rate-limit
Fix revision discarded on event rate limiting key calculation
2023-05-17 09:33:50 +02:00
Matheus Pimenta a8af5647e8 Fix revision discarded on event rate limiting key calculation
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-05-11 20:10:38 +01:00
Matheus Pimenta e9d1fb3d86 Add event metadata field to Alert spec
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-05-11 18:14:49 +01:00
Stefan Prodan 13fe515890
Update dependencies
- github.com/Azure/azure-amqp-common-go/v4 v4.1.0
- github.com/Azure/azure-event-hubs-go/v3 v3.5.0
- github.com/fluxcd/pkg/runtime v0.35.0
- github.com/getsentry/sentry-go v0.20.0
- github.com/go-logr/logr v1.2.4
- github.com/google/go-github/v52 v52.0.0
- github.com/ktrysmt/go-bitbucket v0.9.56
- github.com/xanzy/go-gitlab v0.83.0
- golang.org/x/oauth2 v0.7.0
- sigs.k8s.io/controller-runtime v0.14.6

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-05-08 16:34:30 +03:00
Hidde Beydals 4effb1542d
Merge pull request #506 from aryan9600/indexing
index receivers using webhook path as key
2023-05-03 13:49:26 +02:00
Sanskar Jaiswal 00fab6693b
index receivers using webhook path as key
Use `.status.webhookPath` as a key to index Receivers. Use this key
while listing Receivers during the handling of a payload.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-05-03 16:32:38 +05:30
Matheus Pimenta 9b7a80942f Add InclusionList to Alert CRD
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Co-authored-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-05-02 10:05:16 +01:00
Max Jonas Werner 75b1cc109f
Use GitRepository v1 as default version in receiver handler
v1 will be the default version in the upcoming version of n-c.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-03-30 15:48:42 +02:00
Max Jonas Werner ec03bd20a3
Introduce v1 API and bump Receiver version to v1
This commit bumps the Receiver API version to v1 in preparation of
the Flux GitOps GA milestone
(https://fluxcd.io/roadmap/#flux-gitops-ga-q1-2023).

We are now actively maintaining two versions of the notification API
group in parallel: v1 which currently only holds the Receiver kind and
v1beta2 for all other kinds.

Since we haven't run into this situation before, I had to change the
way we expose the API docs in ./docs/api: The directory now has
sub-directories for each active API version. Therefore we need to
change our scripts in the website repository to take this change into
account so that we expose both API group version at
https://fluxcd.io/flux/components/notification/api/. This change is
implemented in https://github.com/fluxcd/website/pull/1427.

refs #436

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-03-30 15:40:54 +02:00
Somtochi Onyekwere 4fcde0026d add docs and log when no objects are found
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2023-03-20 22:20:54 +01:00
Raffael Sahli 57f62f400c
feat: support multi receiver by matchLabels
Signed-off-by: Raffael Sahli <raffael.sahli@doodle.com>
2023-03-20 08:11:30 +00:00
Hidde Beydals 7448a667a0
receiver: update default ImageRepository version
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-02-28 11:14:42 +01:00
Hidde Beydals fd86289062 Add digest metadata event key to ignore list
Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-02-13 10:28:34 +01:00
Stefan Prodan d16588a193 Deprecate `Receiver.status.url` in favor of `.status.webhookPath`
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-12-09 12:05:51 +00:00
Stefan Prodan 5fd17e6220 Refactor the Receiver URL generation
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-12-09 12:05:51 +00:00
Stefan Prodan 9f2d0e1a6c Generate unique commit status updates
Use the Provider cluster assigned UID to compose a unique commit status
ID to avoid name collisions when multiple clusters write to the same
repository.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-12-09 12:05:51 +00:00
Stefan Prodan 974a77da00 Refactor reconcilers and introduce v1beta2 API
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-12-09 11:03:53 +00:00
Sunny ac17d75bc3 receiver: Use new ServeMux
Use its own ServeMux.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2022-12-01 18:30:20 +05:30
Stefan Prodan 224b12a2b8 Refactor notifiers to use Event API v1beta1
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-11-22 11:00:25 +00:00
Somtochi Onyekwere 25eeaf46dd Add .spec.timeout to Provider
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-31 11:25:09 +01:00
Philip Laine 82253a9558 Fix context cancel defer
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2022-08-26 18:02:47 +02:00
Somtochi Onyekwere 472858f7fb remove status
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-10 23:49:02 +01:00
Somtochi Onyekwere 55f3c6bf29 test validate func
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-10 23:46:32 +01:00
Somtochi Onyekwere db485228dd remove code for parsing github payload
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-10 21:19:22 +01:00
Philip Laine 2c69c847d3 Add context to Post function
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2022-07-27 18:26:28 +02:00
Somtochi Onyekwere 9b8586e35d remove line overriding err
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-07-04 16:31:50 +01:00
Somtochi Onyekwere b5f67d4f59 use masktoken pkg for redacting token
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-07-04 16:15:10 +01:00
Soule BA 44f5b43a4c
Update flux types api versions
Signed-off-by: Soule BA <bah.soule@gmail.com>
2022-06-07 15:44:40 +02:00
Paulo Gomes a0dc84e36a
Small fixes
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-05-24 07:20:15 +01:00
Somtochi Onyekwere b30e2458d8 return actual error when regex.Compile fails
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-04-08 16:26:52 +01:00