@@ -21,6 +21,7 @@ import (
21
21
stdtls "crypto/tls"
22
22
"errors"
23
23
"fmt"
24
+ "net/url"
24
25
"os"
25
26
"path/filepath"
26
27
"strings"
@@ -468,7 +469,13 @@ func (r *BucketReconciler) reconcileSource(ctx context.Context, sp *patch.Serial
468
469
conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , e .Error ())
469
470
return sreconcile .ResultEmpty , e
470
471
}
471
- if provider , err = minio .NewClient (obj , secret , tlsConfig ); err != nil {
472
+ proxyURL , err := r .getProxyURL (ctx , obj )
473
+ if err != nil {
474
+ e := serror .NewGeneric (err , sourcev1 .AuthenticationFailedReason )
475
+ conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , e .Error ())
476
+ return sreconcile .ResultEmpty , e
477
+ }
478
+ if provider , err = minio .NewClient (obj , secret , tlsConfig , proxyURL ); err != nil {
472
479
e := serror .NewGeneric (err , "ClientError" )
473
480
conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , e .Error ())
474
481
return sreconcile .ResultEmpty , e
@@ -703,6 +710,30 @@ func (r *BucketReconciler) getTLSConfig(ctx context.Context, obj *bucketv1.Bucke
703
710
return tlsConfig , nil
704
711
}
705
712
713
+ func (r * BucketReconciler ) getProxyURL (ctx context.Context , obj * bucketv1.Bucket ) (* url.URL , error ) {
714
+ namespace := obj .GetNamespace ()
715
+ proxySecret , err := r .getSecret (ctx , obj .Spec .ProxySecretRef , namespace )
716
+ if err != nil || proxySecret == nil {
717
+ return nil , err
718
+ }
719
+ proxyData := proxySecret .Data
720
+ address , ok := proxyData ["address" ]
721
+ if ! ok {
722
+ return nil , fmt .Errorf ("invalid proxy secret '%s/%s': key 'address' is missing" ,
723
+ obj .Spec .ProxySecretRef .Name , namespace )
724
+ }
725
+ proxyURL , err := url .Parse (string (address ))
726
+ if err != nil {
727
+ return nil , fmt .Errorf ("failed to parse proxy address '%s': %w" , address , err )
728
+ }
729
+ user , hasUser := proxyData ["username" ]
730
+ password , hasPassword := proxyData ["password" ]
731
+ if hasUser || hasPassword {
732
+ proxyURL .User = url .UserPassword (string (user ), string (password ))
733
+ }
734
+ return proxyURL , nil
735
+ }
736
+
706
737
// eventLogf records events, and logs at the same time.
707
738
//
708
739
// This log is different from the debug log in the EventRecorder, in the sense
0 commit comments