diff --git a/api/v1alpha1/reference_types.go b/api/v1alpha1/reference_types.go index d14c874..b91581c 100644 --- a/api/v1alpha1/reference_types.go +++ b/api/v1alpha1/reference_types.go @@ -24,7 +24,7 @@ type CrossNamespaceObjectReference struct { APIVersion string `json:"apiVersion,omitempty"` // Kind of the referent - // +kubebuilder:validation:Enum=GitRepository;Kustomization;HelmRelease;HelmChart;HelmRepository + // +kubebuilder:validation:Enum=Bucket;GitRepository;Kustomization;HelmRelease;HelmChart;HelmRepository // +required Kind string `json:"kind,omitempty"` diff --git a/config/crd/bases/notification.toolkit.fluxcd.io_alerts.yaml b/config/crd/bases/notification.toolkit.fluxcd.io_alerts.yaml index 8c676ce..48c80be 100644 --- a/config/crd/bases/notification.toolkit.fluxcd.io_alerts.yaml +++ b/config/crd/bases/notification.toolkit.fluxcd.io_alerts.yaml @@ -67,6 +67,7 @@ spec: kind: description: Kind of the referent enum: + - Bucket - GitRepository - Kustomization - HelmRelease diff --git a/config/crd/bases/notification.toolkit.fluxcd.io_receivers.yaml b/config/crd/bases/notification.toolkit.fluxcd.io_receivers.yaml index 5f7626e..1ba5d45 100644 --- a/config/crd/bases/notification.toolkit.fluxcd.io_receivers.yaml +++ b/config/crd/bases/notification.toolkit.fluxcd.io_receivers.yaml @@ -64,6 +64,7 @@ spec: kind: description: Kind of the referent enum: + - Bucket - GitRepository - Kustomization - HelmRelease diff --git a/docs/spec/v1alpha1/alert.md b/docs/spec/v1alpha1/alert.md index 1144444..f5b90b3 100644 --- a/docs/spec/v1alpha1/alert.md +++ b/docs/spec/v1alpha1/alert.md @@ -63,6 +63,8 @@ spec: eventSources: - kind: GitRepository name: webapp + - kind: Bucket + name: secrets - kind: Kustomization name: webapp-backend - kind: Kustomization diff --git a/docs/spec/v1alpha1/receiver.md b/docs/spec/v1alpha1/receiver.md index 5e509f6..a8a82cc 100644 --- a/docs/spec/v1alpha1/receiver.md +++ b/docs/spec/v1alpha1/receiver.md @@ -178,6 +178,8 @@ spec: name: webapp - kind: HelmRepository name: webapp + - kind: Bucket + name: secrets ``` When the receiver type is set to `generic`, the controller will not perform token validation nor event filtering. diff --git a/go.mod b/go.mod index 3955702..4d544aa 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/fluxcd/notification-controller/api v0.0.10 github.com/fluxcd/pkg/recorder v0.0.6 github.com/fluxcd/pkg/runtime v0.0.1 - github.com/fluxcd/source-controller/api v0.0.16 + github.com/fluxcd/source-controller/api v0.0.17 github.com/go-logr/logr v0.1.0 github.com/google/go-github/v32 v32.0.0 github.com/hashicorp/go-retryablehttp v0.6.6 diff --git a/go.sum b/go.sum index 8667af6..aa68939 100644 --- a/go.sum +++ b/go.sum @@ -69,8 +69,8 @@ github.com/fluxcd/pkg/recorder v0.0.6 h1:me/n8syeeGXz50OXoPX3jgIj9AtinvhHdKT9Dy+ github.com/fluxcd/pkg/recorder v0.0.6/go.mod h1:IfQxfVRSNsWs3B0Yp5B6ObEWwKHILlAx8N7XkoDdhFg= github.com/fluxcd/pkg/runtime v0.0.1 h1:h8jztHVF9UMGD7XBQSfXDdw80bpT6BOkd0xe4kknPL0= github.com/fluxcd/pkg/runtime v0.0.1/go.mod h1:cU1t0+Ld39pZjMyrrHukw1E++OZFNHxG2qAExfDWQ34= -github.com/fluxcd/source-controller/api v0.0.16 h1:Mk+X2H+5CX7vfmrVhGT/TR8EnZ8UmZ20TpPyP3e8ZBs= -github.com/fluxcd/source-controller/api v0.0.16/go.mod h1:PUe+EYQ/s+KPnz2iOCgdf+L6clM0SWkyvdXIpbfpkQE= +github.com/fluxcd/source-controller/api v0.0.17 h1:LQR6VR/CATAV+RDcK3rPgA66IW5CFbhAH4Prm0UBL5Y= +github.com/fluxcd/source-controller/api v0.0.17/go.mod h1:PUe+EYQ/s+KPnz2iOCgdf+L6clM0SWkyvdXIpbfpkQE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= diff --git a/internal/server/receiver_handlers.go b/internal/server/receiver_handlers.go index af96e37..b060cb6 100644 --- a/internal/server/receiver_handlers.go +++ b/internal/server/receiver_handlers.go @@ -217,6 +217,18 @@ func (s *ReceiverServer) annotate(ctx context.Context, resource v1alpha1.CrossNa } switch resource.Kind { + case sourcev1.BucketKind: + var source sourcev1.Bucket + if err := s.kubeClient.Get(ctx, resourceName, &source); err != nil { + return fmt.Errorf("unable to read Bucket '%s' error: %w", resourceName, err) + } + if source.Annotations == nil { + source.Annotations = make(map[string]string) + } + source.Annotations[consts.ReconcileAtAnnotation] = metav1.Now().String() + if err := s.kubeClient.Update(ctx, &source); err != nil { + return fmt.Errorf("unable to annotate Bucket '%s' error: %w", resourceName, err) + } case sourcev1.GitRepositoryKind: var source sourcev1.GitRepository if err := s.kubeClient.Get(ctx, resourceName, &source); err != nil {