Skip to content

Commit a02e7e0

Browse files
author
York Chen
committed
feat: pass repoRecorder into helm* controllers
1 parent 841b1a3 commit a02e7e0

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

controllers/helmchart_controller.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ type HelmChartReconciler struct {
128128
Cache *cache.Cache
129129
TTL time.Duration
130130
*cache.CacheRecorder
131+
RepoRecorder *repository.Recorder
131132
}
132133

133134
func (r *HelmChartReconciler) SetupWithManager(mgr ctrl.Manager) error {
@@ -585,7 +586,7 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj *
585586
}
586587
}
587588
default:
588-
httpChartRepo, err := repository.NewChartRepository(normalizedURL, r.Storage.LocalPath(*repo.GetArtifact()), r.Getters, tlsConfig, clientOpts,
589+
httpChartRepo, err := repository.NewChartRepository(normalizedURL, r.Storage.LocalPath(*repo.GetArtifact()), r.Getters, tlsConfig, clientOpts, repo.Namespace, r.RepoRecorder,
589590
repository.WithMemoryCache(r.Storage.LocalPath(*repo.GetArtifact()), r.Cache, r.TTL, func(event string) {
590591
r.IncCacheEvents(event, obj.Name, obj.Namespace)
591592
}))
@@ -1038,7 +1039,7 @@ func (r *HelmChartReconciler) namespacedChartRepositoryCallback(ctx context.Cont
10381039

10391040
chartRepo = ociChartRepo
10401041
} else {
1041-
httpChartRepo, err := repository.NewChartRepository(normalizedURL, "", r.Getters, tlsConfig, clientOpts)
1042+
httpChartRepo, err := repository.NewChartRepository(normalizedURL, "", r.Getters, tlsConfig, clientOpts, namespace, r.RepoRecorder)
10421043
if err != nil {
10431044
return nil, err
10441045
}

controllers/helmrepository_controller.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ type HelmRepositoryReconciler struct {
109109
Cache *cache.Cache
110110
TTL time.Duration
111111
*cache.CacheRecorder
112+
RepoRecorder *repository.Recorder
112113
}
113114

114115
type HelmRepositoryReconcilerOptions struct {
@@ -398,7 +399,7 @@ func (r *HelmRepositoryReconciler) reconcileSource(ctx context.Context, obj *sou
398399
}
399400

400401
// Construct Helm chart repository with options and download index
401-
newChartRepo, err := repository.NewChartRepository(obj.Spec.URL, "", r.Getters, tlsConfig, clientOpts)
402+
newChartRepo, err := repository.NewChartRepository(obj.Spec.URL, "", r.Getters, tlsConfig, clientOpts, obj.Namespace, r.RepoRecorder)
402403
if err != nil {
403404
switch err.(type) {
404405
case *url.Error:

controllers/helmrepository_controller_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,9 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
600600
if serr != nil {
601601
validSecret = false
602602
}
603-
newChartRepo, err = repository.NewChartRepository(obj.Spec.URL, "", testGetters, tOpts, clientOpts)
603+
newChartRepo, err = repository.NewChartRepository(obj.Spec.URL, "", testGetters, tOpts, clientOpts, obj.Namespace, testRepoRecorder)
604604
} else {
605-
newChartRepo, err = repository.NewChartRepository(obj.Spec.URL, "", testGetters, nil, nil)
605+
newChartRepo, err = repository.NewChartRepository(obj.Spec.URL, "", testGetters, nil, nil, obj.Namespace, testRepoRecorder)
606606
}
607607
g.Expect(err).ToNot(HaveOccurred())
608608

@@ -736,7 +736,7 @@ func TestHelmRepositoryReconciler_reconcileArtifact(t *testing.T) {
736736
g.Expect(err).ToNot(HaveOccurred())
737737
g.Expect(cacheFile.Close()).ToNot(HaveOccurred())
738738

739-
chartRepo, err := repository.NewChartRepository(obj.Spec.URL, "", testGetters, nil, nil)
739+
chartRepo, err := repository.NewChartRepository(obj.Spec.URL, "", testGetters, nil, nil, obj.Namespace, testRepoRecorder)
740740
g.Expect(err).ToNot(HaveOccurred())
741741
chartRepo.CachePath = cachePath
742742

0 commit comments

Comments
 (0)