Skip to content

Commit a83e948

Browse files
committed
Add HTTP provider for bucket source
Signed-off-by: Zhongcheng Lao <[email protected]>
1 parent 0256704 commit a83e948

File tree

4 files changed

+505
-1
lines changed

4 files changed

+505
-1
lines changed

api/v1beta2/bucket_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ const (
4343
// Provides support for authentication using a Service Principal,
4444
// Managed Identity or Shared Key.
4545
AzureBucketProvider string = "azure"
46+
// HttpProvider for an HTTP location as a Bucket.
47+
HttpProvider string = "http"
4648
)
4749

4850
// BucketSpec specifies the required configuration to produce an Artifact for
@@ -51,7 +53,7 @@ type BucketSpec struct {
5153
// Provider of the object storage bucket.
5254
// Defaults to 'generic', which expects an S3 (API) compatible object
5355
// storage.
54-
// +kubebuilder:validation:Enum=generic;aws;gcp;azure
56+
// +kubebuilder:validation:Enum=generic;aws;gcp;azure;http
5557
// +kubebuilder:default:=generic
5658
// +optional
5759
Provider string `json:"provider,omitempty"`

config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ spec:
340340
- aws
341341
- gcp
342342
- azure
343+
- http
343344
type: string
344345
region:
345346
description: Region of the Endpoint where the BucketName is located

controllers/bucket_controller.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929
"time"
3030

3131
"github.com/fluxcd/source-controller/pkg/azure"
32+
"github.com/fluxcd/source-controller/pkg/http"
33+
3234
"golang.org/x/sync/errgroup"
3335
"golang.org/x/sync/semaphore"
3436
corev1 "k8s.io/api/core/v1"
@@ -491,6 +493,17 @@ func (r *BucketReconciler) reconcileSource(ctx context.Context, obj *sourcev1.Bu
491493
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Error())
492494
return sreconcile.ResultEmpty, e
493495
}
496+
case sourcev1.HttpProvider:
497+
if err = http.ValidateSecret(secret); err != nil {
498+
e := &serror.Event{Err: err, Reason: sourcev1.AuthenticationFailedReason}
499+
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Error())
500+
return sreconcile.ResultEmpty, e
501+
}
502+
if provider, err = http.NewClient(ctx, obj.Spec.Endpoint, secret); err != nil {
503+
e := &serror.Event{Err: err, Reason: "ClientError"}
504+
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Error())
505+
return sreconcile.ResultEmpty, e
506+
}
494507
default:
495508
if err = minio.ValidateSecret(secret); err != nil {
496509
e := &serror.Event{Err: err, Reason: sourcev1.AuthenticationFailedReason}

0 commit comments

Comments
 (0)