Commit Graph

228 Commits

Author SHA1 Message Date
Sunny 937da68766
Handle delete before adding finalizer
In Reconcile() methods, move the object deletion above add finalizer.
Finalizers can't be set when an object is being deleted.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-07-26 00:24:13 +05:30
Martin Kemp dbdc4dee73
Add support for PagerDuty
Signed-off-by: Martin Kemp <me@martinke.mp>
2023-06-27 10:52:24 +02: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
Max Jonas Werner 61cd4d0365
Improve error messages in Gitea notifier
This change makes identifying the source of certain errors easier,
e.g. in test failures or container logs.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-06-21 08:42:57 +02:00
Max Jonas Werner 1e851d47fa
Make Gitea tests independent of 3rd-party service
try.gitea.io, used before this change for testing the Gitea notifier,
has been provisioned with a bug that broke the tests. Now, the tests
are run against a mock HTTP server mimicking parts of Gitea's API so
that the tests don't rely on that 3rd-pary service, anymore.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-06-20 15:10:20 +02:00
Matheus Pimenta 04cea9d51e Add Provider for Google Pub/Sub Topic
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Co-authored-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
Co-authored-by: Max Jonas Werner <makkes@users.noreply.github.com>
Co-authored-by: Sunny <darkowlzz@protonmail.com>
2023-06-16 17:08:11 +01:00
Matheus Pimenta bd1c659ffb Fix TestProviderReconciler_Reconcile/finalizes_suspended_object to use patch instead of update
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-06-16 13:25:19 +01: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
Stefan Prodan 963b3da8a7
Rename controllers to controller
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-05-24 10:58:18 +03:00
Sanskar Jaiswal 24b84e29b6
update deps and Kubernetes to 1.27.2
* github.com/fluxcd/pkg/apis/event => v0.5.0
* github.com/fluxcd/pkg/apis/meta => v1.1.0
* github.com/fluxcd/pkg/git => v0.12.1
* github.com/fluxcd/pkg/runtime => v0.37.0
* github.com/fluxcd/pkg/ssa => v0.28.0
* github.com/getsentry/sentry-go => v0.21.0
* github.com/ktrysmt/go-bitbucket => v0.9.58
* github.com/onsi/gomega => v1.27.7
* github.com/stretchr/testify => v1.8.3
* golang.org/x/oauth2 => v0.8.0
* k8s.io/api => v0.27.2
* k8s.io/apimachinery => v0.27.2
* k8s.io/client-go => v0.27.2
* sigs.k8s.io/controller-runtime => v0.15.0-beta.0

Changes made due to breaking changes in controller-runtime v0.15:

* Watches requires a plain `client.Object` instead of a `source.Kind` object.
* `handler.MapFunc` requires a Go context.
* `ctrl.Options.Namespace` was moved to `ctrlcache.Options.Namespaces`.
* `ctrl.Options.ClientDisableCacheFor` was moved to `ctrlclient.CacheOptions.DisableFor`.
* `ctrl.Options.Port` has been deprecated and removed.
* Use `MaxConcurrentReconciles` and `RecoverPanice` in `config.Controller` instead of `controller.Options`.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-05-24 10:36:20 +03: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 13081a2602
Merge pull request #514 from bigkevmcd/azure-summary
Append the Alert summary to Azure DevOps genre field
2023-05-09 17:11:29 +03:00
Sunny d3c2d87e8b
Merge pull request #521 from fluxcd/eventhandler-test-improv
Improve event handler tests
2023-05-09 19:10:58 +05:30
Kevin McDermott 73499fb6a4 Add the event summary into the genre.
This appends the metadata summary field in the genre (if one exists)
otherwise retains the fluxcd entry.

Signed-off-by: Kevin McDermott <bigkevmcd@gmail.com>
2023-05-09 14:30:57 +01:00
Sunny 7e678487c2
fix eventhandler test sideeffects with fixture
Introduce event fixtures in the eventhandler test to prevent
sideeffects from the previous test case. The event fixtures are used
to reset the event used in the test cases to an initial fixed value.
The reset is moved to the beginning of subtest to ensure those variables
always get reset at the beginning of a subtest. The previous
implementation in which the reset was done at the end doesn't get
executed when a test fails.
This helps ensure that two consecutive test cases don't use the same
event value.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-05-09 03:10:04 +05:30
Sunny 88e2cf0e8b
event handler test improvements
- Update usage of old GitRepository API.
- In eventhandler test, create new `g` per subtest and pass it to the
  assertion helpers to resolve confusing error message. Without this,
  when a subtest fails, root level `g` of the test complains that a
  subtest may have called FailNow on parent test. Also, mark the
  assertion helpers as test helpers.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-05-09 03:01:43 +05:30
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
Sunny 24509ce458
receiver/v1: Remove deprecated .status.url field
Receiver .status.url was deprecated in v1beta2 API and replaced with
.status.webhookPath. Remove it from v1 API and all references to it.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-04-21 20:38:09 +05:30
Max Jonas Werner 0c0109a4bd
move all controllers to `internal` package
closes #499

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-03-30 15:53:04 +02: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 f00561e07d Extract commit SHA from RFC-0005 revision fmt
Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-02-13 11:14:41 +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
Hidde Beydals c90e58eca7 Disable caching of Secrets and ConfigMaps
You can re-enable caching by starting the controller with the argument
`--feature-gates=CacheSecretsAndConfigMaps=true`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-01-30 15:10:56 +00:00
Stefan Prodan a75b04398a
Update dependencies
- k8s.io/* v0.26.1
- sigs.k8s.io/controller-runtime v0.14.2
- github.com/Azure/azure-amqp-common-go/v4 v4.0.0
- github.com/Azure/azure-event-hubs-go/v3 v3.4.0
- github.com/ktrysmt/go-bitbucket v0.9.55
- github.com/xanzy/go-gitlab v0.79.0
- github.com/getsentry/sentry-go v0.17.0
- github.com/fluxcd/pkg/runtime v0.27.0

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-01-30 14:36:22 +02:00
ttyS3 d302029447
feat: add gitea notifier
Signed-off-by: ttyS3 <ttys3.rust@gmail.com>
2022-12-14 01:27:20 +08: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 caec764ccc Refactor notifies to use Flux Event API v1beta1
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 a9ac01a2aa Avoid key collision for BitBucket status updates
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
Paulo Gomes 8d95dc087a
build: Improve fuzz tests' reliability
Establish conventions which aligns with what is supported upstream
today, whilst expanding on documentation to ensure folks have
pointers on how to debug/check for issues going forwards.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-11-23 14:56:32 +00:00
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
Max Jonas Werner a76b9a0c63
Add "generic-hmac" Provider
This commit adds the "generic-hmac" Provider type for authenticating
webhook requests coming from notification-controller. I extended the
`Forwarder` notifier to accept an optional key used for generating the
HMAC. If the key is nil or empty no HMAC header is generated and the
forwarder behaves as before. If it is provided an `X-Signature` HTTP
header is added to the request carrying the HMAC.

I transformed the `TestForwarder_Post` test into a table-driven test
so that we can use the same setup and testing code for testing HMAC
and non-HMAC forwarder instances.

Any existing `X-Signature` header value set through
a `Provider.spec.secretRef` Secret's `header` field will be
overwritten.

closes #99

Signed-off-by: Max Jonas Werner <max@e13.dev>
2022-10-04 18:41:45 +02:00
Paulo Gomes 5b1d1b1721
fuzz: Refactor Fuzzers based on Go native fuzzing
The existing fuzzers were converted into the Go native format.
Based on how the code was structured on this project, the fuzzers
can be quite effective, allowing for entire E2E fuzzing in some
cases, but with very low execution cost.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-09-07 10:46:29 +01: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