@@ -70,6 +70,7 @@ import (
7070 serror "github.com/fluxcd/source-controller/internal/error"
7171 "github.com/fluxcd/source-controller/internal/helm/chart"
7272 "github.com/fluxcd/source-controller/internal/helm/getter"
73+ "github.com/fluxcd/source-controller/internal/helm/registry"
7374 "github.com/fluxcd/source-controller/internal/helm/repository"
7475 soci "github.com/fluxcd/source-controller/internal/oci"
7576 scosign "github.com/fluxcd/source-controller/internal/oci/cosign"
@@ -132,10 +133,9 @@ type HelmChartReconciler struct {
132133 kuberecorder.EventRecorder
133134 helper.Metrics
134135
135- RegistryClientGenerator RegistryClientGeneratorFunc
136- Storage * storage.Storage
137- Getters helmgetter.Providers
138- ControllerName string
136+ Storage * storage.Storage
137+ Getters helmgetter.Providers
138+ ControllerName string
139139
140140 Cache * cache.Cache
141141 TTL time.Duration
@@ -148,7 +148,7 @@ type HelmChartReconciler struct {
148148// and an optional file name.
149149// The file is used to store the registry client credentials.
150150// The caller is responsible for deleting the file.
151- type RegistryClientGeneratorFunc func (tlsConfig * tls.Config , isLogin , insecure bool ) (* helmreg.Client , string , error )
151+ type RegistryClientGeneratorFunc func (tlsConfig * tls.Config , isLogin , insecure bool ) (* helmreg.Client , error )
152152
153153func (r * HelmChartReconciler ) SetupWithManager (ctx context.Context , mgr ctrl.Manager ) error {
154154 return r .SetupWithManagerAndOptions (ctx , mgr , HelmChartReconcilerOptions {})
@@ -557,25 +557,16 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj *
557557 // this is needed because otherwise the credentials are stored in ~/.docker/config.json.
558558 // TODO@souleb: remove this once the registry move to Oras v2
559559 // or rework to enable reusing credentials to avoid the unneccessary handshake operations
560- registryClient , credentialsFile , err := r . RegistryClientGenerator (clientOpts .TlsConfig , clientOpts . MustLoginToRegistry () , repo .Spec .Insecure )
560+ registryClient , err := registry . NewClient (clientOpts .TlsConfig , repo .Spec .Insecure )
561561 if err != nil {
562562 e := serror .NewGeneric (
563- fmt .Errorf ("failed to construct Helm client : %w" , err ),
563+ fmt .Errorf ("failed to construct Helm clientzzzzz : %w" , err ),
564564 meta .FailedReason ,
565565 )
566566 conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , "%s" , e )
567567 return sreconcile .ResultEmpty , e
568568 }
569569
570- if credentialsFile != "" {
571- defer func () {
572- if err := os .Remove (credentialsFile ); err != nil {
573- r .eventLogf (ctx , obj , corev1 .EventTypeWarning , meta .FailedReason ,
574- "failed to delete temporary credentials file: %s" , err )
575- }
576- }()
577- }
578-
579570 var verifiers []soci.Verifier
580571 if obj .Spec .Verify != nil {
581572 provider := obj .Spec .Verify .Provider
@@ -1027,7 +1018,7 @@ func (r *HelmChartReconciler) namespacedChartRepositoryCallback(ctx context.Cont
10271018
10281019 var chartRepo repository.Downloader
10291020 if helmreg .IsOCI (normalizedURL ) {
1030- registryClient , credentialsFile , err := r . RegistryClientGenerator (clientOpts .TlsConfig , clientOpts . MustLoginToRegistry () , obj .Spec .Insecure )
1021+ registryClient , err := registry . NewClient (clientOpts .TlsConfig , obj .Spec .Insecure )
10311022 if err != nil {
10321023 return nil , fmt .Errorf ("failed to create registry client: %w" , err )
10331024 }
@@ -1038,17 +1029,9 @@ func (r *HelmChartReconciler) namespacedChartRepositoryCallback(ctx context.Cont
10381029 ociChartRepo , err := repository .NewOCIChartRepository (normalizedURL , repository .WithOCIGetter (r .Getters ),
10391030 repository .WithOCIGetterOptions (getterOpts ),
10401031 repository .WithOCIRegistryClient (registryClient ),
1041- repository .WithCertificatesStore (certsTmpDir ),
1042- repository .WithCredentialsFile (credentialsFile ))
1032+ repository .WithCertificatesStore (certsTmpDir ))
10431033 if err != nil {
1044- errs = append (errs , fmt .Errorf ("failed to create OCI chart repository: %w" , err ))
1045- // clean up the credentialsFile
1046- if credentialsFile != "" {
1047- if err := os .Remove (credentialsFile ); err != nil {
1048- errs = append (errs , err )
1049- }
1050- }
1051- return nil , kerrors .NewAggregate (errs )
1034+ return nil , fmt .Errorf ("failed to create OCI chart repository: %w" , err )
10521035 }
10531036
10541037 // If login options are configured, use them to login to the registry
@@ -1310,7 +1293,7 @@ func chartRepoConfigErrorReturn(err error, obj *sourcev1.HelmChart) (sreconcile.
13101293 return sreconcile .ResultEmpty , e
13111294 default :
13121295 e := serror .NewStalling (
1313- fmt .Errorf ("failed to construct Helm client : %w" , err ),
1296+ fmt .Errorf ("failed to construct Helm clienttttt : %w" , err ),
13141297 meta .FailedReason ,
13151298 )
13161299 conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , "%s" , e )
0 commit comments