@@ -29,7 +29,7 @@ import (
29
29
"time"
30
30
31
31
helmgetter "helm.sh/helm/v3/pkg/getter"
32
- "helm.sh/helm/v3/pkg/registry"
32
+ helmreg "helm.sh/helm/v3/pkg/registry"
33
33
corev1 "k8s.io/api/core/v1"
34
34
apierrs "k8s.io/apimachinery/pkg/api/errors"
35
35
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -60,6 +60,7 @@ import (
60
60
serror "github.com/fluxcd/source-controller/internal/error"
61
61
"github.com/fluxcd/source-controller/internal/helm/chart"
62
62
"github.com/fluxcd/source-controller/internal/helm/getter"
63
+ "github.com/fluxcd/source-controller/internal/helm/registry"
63
64
"github.com/fluxcd/source-controller/internal/helm/repository"
64
65
sreconcile "github.com/fluxcd/source-controller/internal/reconcile"
65
66
"github.com/fluxcd/source-controller/internal/reconcile/summarize"
@@ -380,7 +381,7 @@ func (r *HelmChartReconciler) reconcileSource(ctx context.Context, obj *sourcev1
380
381
381
382
// Assert source has an artifact
382
383
if s .GetArtifact () == nil || ! r .Storage .ArtifactExist (* s .GetArtifact ()) {
383
- if helmRepo , ok := s .(* sourcev1.HelmRepository ); ! ok || ! registry .IsOCI (helmRepo .Spec .URL ) {
384
+ if helmRepo , ok := s .(* sourcev1.HelmRepository ); ! ok || ! helmreg .IsOCI (helmRepo .Spec .URL ) {
384
385
conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , "NoSourceArtifact" ,
385
386
"no artifact available for %s source '%s'" , obj .Spec .SourceRef .Kind , obj .Spec .SourceRef .Name )
386
387
r .eventLogf (ctx , obj , events .EventTypeTrace , "NoSourceArtifact" ,
@@ -447,7 +448,7 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj *
447
448
repo * sourcev1.HelmRepository , b * chart.Build ) (sreconcile.Result , error ) {
448
449
var (
449
450
tlsConfig * tls.Config
450
- logOpts []registry .LoginOption
451
+ loginOpts []helmreg .LoginOption
451
452
)
452
453
453
454
// Construct the Getter options from the HelmRepository data
@@ -492,7 +493,7 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj *
492
493
}
493
494
494
495
// Build registryClient options from secret
495
- logOpt , err := loginOptionFromSecret ( * secret )
496
+ loginOpt , err := registry . LoginOptionFromSecret ( repo . Spec . URL , * secret )
496
497
if err != nil {
497
498
e := & serror.Event {
498
499
Err : fmt .Errorf ("failed to configure Helm client with secret data: %w" , err ),
@@ -503,14 +504,14 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj *
503
504
return sreconcile .ResultEmpty , e
504
505
}
505
506
506
- logOpts = append ([]registry .LoginOption {}, logOpt )
507
+ loginOpts = append ([]helmreg .LoginOption {}, loginOpt )
507
508
}
508
509
509
510
// Initialize the chart repository
510
511
var chartRepo chart.Remote
511
512
switch repo .Spec .Type {
512
513
case sourcev1 .HelmRepositoryTypeOCI :
513
- if ! registry .IsOCI (repo .Spec .URL ) {
514
+ if ! helmreg .IsOCI (repo .Spec .URL ) {
514
515
err := fmt .Errorf ("invalid OCI registry URL: %s" , repo .Spec .URL )
515
516
return chartRepoErrorReturn (err , obj )
516
517
}
@@ -519,7 +520,7 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj *
519
520
// this is needed because otherwise the credentials are stored in ~/.docker/config.json.
520
521
// TODO@souleb: remove this once the registry move to Oras v2
521
522
// or rework to enable reusing credentials to avoid the unneccessary handshake operations
522
- registryClient , file , err := r .RegistryClientGenerator (logOpts != nil )
523
+ registryClient , file , err := r .RegistryClientGenerator (loginOpts != nil )
523
524
if err != nil {
524
525
return chartRepoErrorReturn (err , obj )
525
526
}
@@ -540,14 +541,13 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj *
540
541
541
542
// If login options are configured, use them to login to the registry
542
543
// The OCIGetter will later retrieve the stored credentials to pull the chart
543
- if logOpts != nil {
544
- err = ociChartRepo .Login (logOpts ... )
544
+ if loginOpts != nil {
545
+ err = ociChartRepo .Login (loginOpts ... )
545
546
if err != nil {
546
547
return chartRepoErrorReturn (err , obj )
547
548
}
548
549
}
549
550
default :
550
- var httpChartRepo * repository.ChartRepository
551
551
httpChartRepo , err := repository .NewChartRepository (repo .Spec .URL , r .Storage .LocalPath (* repo .GetArtifact ()), r .Getters , tlsConfig , clientOpts ,
552
552
repository .WithMemoryCache (r .Storage .LocalPath (* repo .GetArtifact ()), r .Cache , r .TTL , func (event string ) {
553
553
r .IncCacheEvents (event , obj .Name , obj .Namespace )
0 commit comments