Merge pull request #51 from fluxcd/s3-bucket-receiver

Add support for S3 buckets to alerts and receivers
This commit is contained in:
Stefan Prodan 2020-09-22 14:36:37 +03:00 committed by GitHub
commit 0a215115c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 4 deletions

View File

@ -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"`

View File

@ -67,6 +67,7 @@ spec:
kind:
description: Kind of the referent
enum:
- Bucket
- GitRepository
- Kustomization
- HelmRelease

View File

@ -64,6 +64,7 @@ spec:
kind:
description: Kind of the referent
enum:
- Bucket
- GitRepository
- Kustomization
- HelmRelease

View File

@ -63,6 +63,8 @@ spec:
eventSources:
- kind: GitRepository
name: webapp
- kind: Bucket
name: secrets
- kind: Kustomization
name: webapp-backend
- kind: Kustomization

View File

@ -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.

2
go.mod
View File

@ -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

4
go.sum
View File

@ -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=

View File

@ -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 {