Skip to content

Commit 64fada5

Browse files
committed
🌱 Use upstream cluster RESTConfig utility
This commit simplifies the codebase by removing custom kubeconfig code and instead using the existing fucntionality from cluster-api project.
1 parent 1c38403 commit 64fada5

File tree

10 files changed

+103
-329
lines changed

10 files changed

+103
-329
lines changed

controllers/controllers_test.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ import (
2828
addonsv1alpha1 "sigs.k8s.io/cluster-api-addon-provider-helm/api/v1alpha1"
2929
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3030
"sigs.k8s.io/cluster-api/util/conditions"
31+
"sigs.k8s.io/cluster-api/util/secret"
3132
"sigs.k8s.io/controller-runtime/pkg/client"
3233
)
3334

3435
var (
3536
testNamespace = "test-namespace"
36-
kubeconfig = "test-kubeconfig"
3737
newVersion = "new-version"
3838

3939
defaultProxy = &addonsv1alpha1.HelmChartProxy{
@@ -88,6 +88,29 @@ var (
8888
}
8989
)
9090

91+
func newKubeconfigSecretForCluster(cluster *clusterv1.Cluster) *corev1.Secret {
92+
return &corev1.Secret{
93+
ObjectMeta: metav1.ObjectMeta{
94+
Name: cluster.Name + "-kubeconfig",
95+
Namespace: cluster.Namespace,
96+
},
97+
Data: map[string][]byte{
98+
secret.KubeconfigDataName: []byte(`apiVersion: v1
99+
kind: Config
100+
clusters:
101+
- cluster:
102+
server: http://127.0.0.1:8080
103+
name: ` + cluster.Name + `
104+
contexts:
105+
- context:
106+
cluster: ` + cluster.Name + `
107+
name: ` + cluster.Name + `
108+
current-context: ` + cluster.Name + `
109+
`),
110+
},
111+
}
112+
}
113+
91114
var _ = Describe("Testing HelmChartProxy and HelmReleaseProxy reconcile", func() {
92115
var (
93116
waitForHelmChartProxyCondition = func(objectKey client.ObjectKey, condition func(helmChartProxy *addonsv1alpha1.HelmChartProxy) bool) {
@@ -117,6 +140,8 @@ var _ = Describe("Testing HelmChartProxy and HelmReleaseProxy reconcile", func()
117140
cluster := cluster1.DeepCopy()
118141
err := k8sClient.Create(ctx, cluster)
119142
Expect(err).ToNot(HaveOccurred())
143+
err = k8sClient.Create(ctx, newKubeconfigSecretForCluster(cluster))
144+
Expect(err).ToNot(HaveOccurred())
120145

121146
patch := client.MergeFrom(cluster.DeepCopy())
122147
cluster.Status.Conditions = clusterv1.Conditions{

controllers/helmreleaseproxy/helmreleaseproxy_controller.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ import (
2828
apierrors "k8s.io/apimachinery/pkg/api/errors"
2929
"k8s.io/apimachinery/pkg/runtime"
3030
"k8s.io/apimachinery/pkg/types"
31+
"k8s.io/client-go/rest"
3132
addonsv1alpha1 "sigs.k8s.io/cluster-api-addon-provider-helm/api/v1alpha1"
3233
"sigs.k8s.io/cluster-api-addon-provider-helm/internal"
3334
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
35+
"sigs.k8s.io/cluster-api/controllers/remote"
3436
"sigs.k8s.io/cluster-api/util"
3537
"sigs.k8s.io/cluster-api/util/conditions"
3638
"sigs.k8s.io/cluster-api/util/patch"
@@ -46,9 +48,8 @@ import (
4648
// HelmReleaseProxyReconciler reconciles a HelmReleaseProxy object.
4749
type HelmReleaseProxyReconciler struct {
4850
client.Client
49-
Scheme *runtime.Scheme
50-
KubeconfigGetter internal.Getter
51-
HelmClient internal.Client
51+
Scheme *runtime.Scheme
52+
HelmClient internal.Client
5253

5354
// WatchFilterValue is the label value used to filter events prior to reconciliation.
5455
WatchFilterValue string
@@ -152,7 +153,7 @@ func (r *HelmReleaseProxyReconciler) Reconcile(ctx context.Context, req ctrl.Req
152153
// our finalizer is present, so lets handle any external dependency
153154
if err := r.Client.Get(ctx, clusterKey, cluster); err == nil {
154155
log.V(2).Info("Getting kubeconfig for cluster", "cluster", cluster.Name)
155-
kubeconfig, err := r.KubeconfigGetter.GetClusterKubeconfig(ctx, clusterKey)
156+
restConfig, err := remote.RESTConfig(ctx, "caaph", r.Client, clusterKey)
156157
if err != nil {
157158
wrappedErr := errors.Wrapf(err, "failed to get kubeconfig for cluster")
158159
conditions.MarkFalse(helmReleaseProxy, addonsv1alpha1.ClusterAvailableCondition, addonsv1alpha1.GetKubeconfigFailedReason, clusterv1.ConditionSeverityError, wrappedErr.Error())
@@ -161,7 +162,7 @@ func (r *HelmReleaseProxyReconciler) Reconcile(ctx context.Context, req ctrl.Req
161162
}
162163
conditions.MarkTrue(helmReleaseProxy, addonsv1alpha1.ClusterAvailableCondition)
163164

164-
if err := r.reconcileDelete(ctx, helmReleaseProxy, r.HelmClient, kubeconfig); err != nil {
165+
if err := r.reconcileDelete(ctx, helmReleaseProxy, r.HelmClient, restConfig); err != nil {
165166
// if fail to delete the external dependency here, return with error
166167
// so that it can be retried
167168
return ctrl.Result{}, err
@@ -206,8 +207,8 @@ func (r *HelmReleaseProxyReconciler) Reconcile(ctx context.Context, req ctrl.Req
206207
return ctrl.Result{}, nil
207208
}
208209

209-
log.V(2).Info("Getting kubeconfig for cluster", "cluster", cluster.Name)
210-
kubeconfig, err := r.KubeconfigGetter.GetClusterKubeconfig(ctx, clusterKey)
210+
log.V(2).Info("Getting REST config for cluster", "cluster", cluster.Name)
211+
restConfig, err := remote.RESTConfig(ctx, "caaph", r.Client, clusterKey)
211212
if err != nil {
212213
wrappedErr := errors.Wrapf(err, "failed to get kubeconfig for cluster")
213214
conditions.MarkFalse(helmReleaseProxy, addonsv1alpha1.ClusterAvailableCondition, addonsv1alpha1.GetKubeconfigFailedReason, clusterv1.ConditionSeverityError, wrappedErr.Error())
@@ -249,14 +250,14 @@ func (r *HelmReleaseProxyReconciler) Reconcile(ctx context.Context, req ctrl.Req
249250
}
250251

251252
log.V(2).Info("Reconciling HelmReleaseProxy", "releaseProxyName", helmReleaseProxy.Name)
252-
err = r.reconcileNormal(ctx, helmReleaseProxy, r.HelmClient, credentialsPath, caFilePath, kubeconfig)
253+
err = r.reconcileNormal(ctx, helmReleaseProxy, r.HelmClient, credentialsPath, caFilePath, restConfig)
253254

254255
return ctrl.Result{}, err
255256
}
256257

257258
// reconcileNormal handles HelmReleaseProxy reconciliation when it is not being deleted. This will install or upgrade the HelmReleaseProxy on the Cluster.
258259
// It will set the ReleaseName on the HelmReleaseProxy if the name is generated and also set the release status and release revision.
259-
func (r *HelmReleaseProxyReconciler) reconcileNormal(ctx context.Context, helmReleaseProxy *addonsv1alpha1.HelmReleaseProxy, client internal.Client, credentialsPath, caFilePath string, kubeconfig string) error {
260+
func (r *HelmReleaseProxyReconciler) reconcileNormal(ctx context.Context, helmReleaseProxy *addonsv1alpha1.HelmReleaseProxy, client internal.Client, credentialsPath, caFilePath string, restConfig *rest.Config) error {
260261
log := ctrl.LoggerFrom(ctx)
261262

262263
log.V(2).Info("Reconciling HelmReleaseProxy on cluster", "HelmReleaseProxy", helmReleaseProxy.Name, "cluster", helmReleaseProxy.Spec.ClusterRef.Name)
@@ -268,7 +269,7 @@ func (r *HelmReleaseProxyReconciler) reconcileNormal(ctx context.Context, helmRe
268269
})
269270
}
270271

271-
release, err := client.InstallOrUpgradeHelmRelease(ctx, kubeconfig, credentialsPath, caFilePath, helmReleaseProxy.Spec)
272+
release, err := client.InstallOrUpgradeHelmRelease(ctx, restConfig, credentialsPath, caFilePath, helmReleaseProxy.Spec)
272273
if err != nil {
273274
log.Error(err, fmt.Sprintf("Failed to install or upgrade release '%s' on cluster %s", helmReleaseProxy.Spec.ReleaseName, helmReleaseProxy.Spec.ClusterRef.Name))
274275
conditions.MarkFalse(helmReleaseProxy, addonsv1alpha1.HelmReleaseReadyCondition, addonsv1alpha1.HelmInstallOrUpgradeFailedReason, clusterv1.ConditionSeverityError, err.Error())
@@ -297,12 +298,12 @@ func (r *HelmReleaseProxyReconciler) reconcileNormal(ctx context.Context, helmRe
297298
}
298299

299300
// reconcileDelete handles HelmReleaseProxy deletion. This will uninstall the HelmReleaseProxy on the Cluster or return nil if the HelmReleaseProxy is not found.
300-
func (r *HelmReleaseProxyReconciler) reconcileDelete(ctx context.Context, helmReleaseProxy *addonsv1alpha1.HelmReleaseProxy, client internal.Client, kubeconfig string) error {
301+
func (r *HelmReleaseProxyReconciler) reconcileDelete(ctx context.Context, helmReleaseProxy *addonsv1alpha1.HelmReleaseProxy, client internal.Client, restConfig *rest.Config) error {
301302
log := ctrl.LoggerFrom(ctx)
302303

303304
log.V(2).Info("Deleting HelmReleaseProxy on cluster", "HelmReleaseProxy", helmReleaseProxy.Name, "cluster", helmReleaseProxy.Spec.ClusterRef.Name)
304305

305-
_, err := client.GetHelmRelease(ctx, kubeconfig, helmReleaseProxy.Spec)
306+
_, err := client.GetHelmRelease(ctx, restConfig, helmReleaseProxy.Spec)
306307
if err != nil {
307308
log.V(2).Error(err, "error getting release from cluster", "cluster", helmReleaseProxy.Spec.ClusterRef.Name)
308309

@@ -320,7 +321,7 @@ func (r *HelmReleaseProxyReconciler) reconcileDelete(ctx context.Context, helmRe
320321

321322
log.V(2).Info("Preparing to uninstall release on cluster", "releaseName", helmReleaseProxy.Spec.ReleaseName, "clusterName", helmReleaseProxy.Spec.ClusterRef.Name)
322323

323-
response, err := client.UninstallHelmRelease(ctx, kubeconfig, helmReleaseProxy.Spec)
324+
response, err := client.UninstallHelmRelease(ctx, restConfig, helmReleaseProxy.Spec)
324325
if err != nil {
325326
log.V(2).Info("Error uninstalling chart with Helm:", err)
326327
conditions.MarkFalse(helmReleaseProxy, addonsv1alpha1.HelmReleaseReadyCondition, addonsv1alpha1.HelmReleaseDeletionFailedReason, clusterv1.ConditionSeverityError, err.Error())

controllers/helmreleaseproxy/helmreleaseproxy_controller_test.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2929
"k8s.io/apimachinery/pkg/runtime"
3030
"k8s.io/client-go/kubernetes/scheme"
31+
"k8s.io/client-go/rest"
3132
addonsv1alpha1 "sigs.k8s.io/cluster-api-addon-provider-helm/api/v1alpha1"
3233
"sigs.k8s.io/cluster-api-addon-provider-helm/internal/mocks"
3334
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
@@ -40,7 +41,7 @@ var (
4041
ctx = ctrl.SetupSignalHandler()
4142
fakeScheme = runtime.NewScheme()
4243

43-
kubeconfig = "test-kubeconfig"
44+
restConfig = &rest.Config{}
4445

4546
defaultProxy = &addonsv1alpha1.HelmReleaseProxy{
4647
TypeMeta: metav1.TypeMeta{
@@ -171,7 +172,7 @@ func TestReconcileNormal(t *testing.T) {
171172
name: "successfully install a Helm release",
172173
helmReleaseProxy: defaultProxy.DeepCopy(),
173174
clientExpect: func(g *WithT, c *mocks.MockClientMockRecorder) {
174-
c.InstallOrUpgradeHelmRelease(ctx, kubeconfig, "", "", defaultProxy.DeepCopy().Spec).Return(&helmRelease.Release{
175+
c.InstallOrUpgradeHelmRelease(ctx, restConfig, "", "", defaultProxy.DeepCopy().Spec).Return(&helmRelease.Release{
175176
Name: "test-release",
176177
Version: 1,
177178
Info: &helmRelease.Info{
@@ -195,7 +196,7 @@ func TestReconcileNormal(t *testing.T) {
195196
name: "successfully install a Helm release with a generated name",
196197
helmReleaseProxy: generateNameProxy,
197198
clientExpect: func(g *WithT, c *mocks.MockClientMockRecorder) {
198-
c.InstallOrUpgradeHelmRelease(ctx, kubeconfig, "", "", generateNameProxy.Spec).Return(&helmRelease.Release{
199+
c.InstallOrUpgradeHelmRelease(ctx, restConfig, "", "", generateNameProxy.Spec).Return(&helmRelease.Release{
199200
Name: "test-release",
200201
Version: 1,
201202
Info: &helmRelease.Info{
@@ -219,7 +220,7 @@ func TestReconcileNormal(t *testing.T) {
219220
name: "Helm release pending",
220221
helmReleaseProxy: defaultProxy.DeepCopy(),
221222
clientExpect: func(g *WithT, c *mocks.MockClientMockRecorder) {
222-
c.InstallOrUpgradeHelmRelease(ctx, kubeconfig, "", "", defaultProxy.Spec).Return(&helmRelease.Release{
223+
c.InstallOrUpgradeHelmRelease(ctx, restConfig, "", "", defaultProxy.Spec).Return(&helmRelease.Release{
223224
Name: "test-release",
224225
Version: 1,
225226
Info: &helmRelease.Info{
@@ -246,7 +247,7 @@ func TestReconcileNormal(t *testing.T) {
246247
name: "Helm client returns error",
247248
helmReleaseProxy: defaultProxy.DeepCopy(),
248249
clientExpect: func(g *WithT, c *mocks.MockClientMockRecorder) {
249-
c.InstallOrUpgradeHelmRelease(ctx, kubeconfig, "", "", defaultProxy.Spec).Return(nil, errInternal).Times(1)
250+
c.InstallOrUpgradeHelmRelease(ctx, restConfig, "", "", defaultProxy.Spec).Return(nil, errInternal).Times(1)
250251
},
251252
expect: func(g *WithT, hrp *addonsv1alpha1.HelmReleaseProxy) {
252253
_, ok := hrp.Annotations[addonsv1alpha1.IsReleaseNameGeneratedAnnotation]
@@ -264,7 +265,7 @@ func TestReconcileNormal(t *testing.T) {
264265
name: "Helm release in a failed state, no client error",
265266
helmReleaseProxy: defaultProxy.DeepCopy(),
266267
clientExpect: func(g *WithT, c *mocks.MockClientMockRecorder) {
267-
c.InstallOrUpgradeHelmRelease(ctx, kubeconfig, "", "", defaultProxy.Spec).Return(&helmRelease.Release{
268+
c.InstallOrUpgradeHelmRelease(ctx, restConfig, "", "", defaultProxy.Spec).Return(&helmRelease.Release{
268269
Name: "test-release",
269270
Version: 1,
270271
Info: &helmRelease.Info{
@@ -304,7 +305,7 @@ func TestReconcileNormal(t *testing.T) {
304305
Build(),
305306
}
306307

307-
err := r.reconcileNormal(ctx, tc.helmReleaseProxy, clientMock, "", "", kubeconfig)
308+
err := r.reconcileNormal(ctx, tc.helmReleaseProxy, clientMock, "", "", restConfig)
308309
if tc.expectedError != "" {
309310
g.Expect(err).To(HaveOccurred())
310311
g.Expect(err).To(MatchError(tc.expectedError), err.Error())
@@ -330,7 +331,7 @@ func TestReconcileNormalWithCredentialRef(t *testing.T) {
330331
name: "successfully install a Helm release",
331332
helmReleaseProxy: defaultProxyWithCredentialRef.DeepCopy(),
332333
clientExpect: func(g *WithT, c *mocks.MockClientMockRecorder) {
333-
c.InstallOrUpgradeHelmRelease(ctx, kubeconfig, "/tmp/oci-credentials-xyz.json", "", defaultProxyWithCredentialRef.Spec).Return(&helmRelease.Release{
334+
c.InstallOrUpgradeHelmRelease(ctx, restConfig, "/tmp/oci-credentials-xyz.json", "", defaultProxyWithCredentialRef.Spec).Return(&helmRelease.Release{
334335
Name: "test-release",
335336
Version: 1,
336337
Info: &helmRelease.Info{
@@ -370,7 +371,7 @@ func TestReconcileNormalWithCredentialRef(t *testing.T) {
370371
Build(),
371372
}
372373

373-
err := r.reconcileNormal(ctx, tc.helmReleaseProxy, clientMock, "/tmp/oci-credentials-xyz.json", "", kubeconfig)
374+
err := r.reconcileNormal(ctx, tc.helmReleaseProxy, clientMock, "/tmp/oci-credentials-xyz.json", "", restConfig)
374375
if tc.expectedError != "" {
375376
g.Expect(err).To(HaveOccurred())
376377
g.Expect(err).To(MatchError(tc.expectedError), err.Error())
@@ -396,7 +397,7 @@ func TestReconcileNormalWithACertificateRef(t *testing.T) {
396397
name: "successfully install a Helm release",
397398
helmReleaseProxy: defaultProxyWithCACertRef.DeepCopy(),
398399
clientExpect: func(g *WithT, c *mocks.MockClientMockRecorder) {
399-
c.InstallOrUpgradeHelmRelease(ctx, kubeconfig, "", "/tmp/ca-xyz.crt", defaultProxyWithCACertRef.Spec).Return(&helmRelease.Release{
400+
c.InstallOrUpgradeHelmRelease(ctx, restConfig, "", "/tmp/ca-xyz.crt", defaultProxyWithCACertRef.Spec).Return(&helmRelease.Release{
400401
Name: "test-release",
401402
Version: 1,
402403
Info: &helmRelease.Info{
@@ -436,7 +437,7 @@ func TestReconcileNormalWithACertificateRef(t *testing.T) {
436437
Build(),
437438
}
438439

439-
err := r.reconcileNormal(ctx, tc.helmReleaseProxy, clientMock, "", "/tmp/ca-xyz.crt", kubeconfig)
440+
err := r.reconcileNormal(ctx, tc.helmReleaseProxy, clientMock, "", "/tmp/ca-xyz.crt", restConfig)
440441
if tc.expectedError != "" {
441442
g.Expect(err).To(HaveOccurred())
442443
g.Expect(err).To(MatchError(tc.expectedError), err.Error())
@@ -462,14 +463,14 @@ func TestReconcileDelete(t *testing.T) {
462463
name: "successfully uninstall a Helm release",
463464
helmReleaseProxy: defaultProxy.DeepCopy(),
464465
clientExpect: func(g *WithT, c *mocks.MockClientMockRecorder) {
465-
c.GetHelmRelease(ctx, kubeconfig, defaultProxy.DeepCopy().Spec).Return(&helmRelease.Release{
466+
c.GetHelmRelease(ctx, restConfig, defaultProxy.DeepCopy().Spec).Return(&helmRelease.Release{
466467
Name: "test-release",
467468
Version: 1,
468469
Info: &helmRelease.Info{
469470
Status: helmRelease.StatusDeployed,
470471
},
471472
}, nil).Times(1)
472-
c.UninstallHelmRelease(ctx, kubeconfig, defaultProxy.DeepCopy().Spec).Return(&helmRelease.UninstallReleaseResponse{}, nil).Times(1)
473+
c.UninstallHelmRelease(ctx, restConfig, defaultProxy.DeepCopy().Spec).Return(&helmRelease.UninstallReleaseResponse{}, nil).Times(1)
473474
},
474475
expect: func(g *WithT, hrp *addonsv1alpha1.HelmReleaseProxy) {
475476
g.Expect(conditions.Has(hrp, addonsv1alpha1.HelmReleaseReadyCondition)).To(BeTrue())
@@ -484,7 +485,7 @@ func TestReconcileDelete(t *testing.T) {
484485
name: "Helm release already uninstalled",
485486
helmReleaseProxy: defaultProxy.DeepCopy(),
486487
clientExpect: func(g *WithT, c *mocks.MockClientMockRecorder) {
487-
c.GetHelmRelease(ctx, kubeconfig, defaultProxy.DeepCopy().Spec).Return(nil, helmDriver.ErrReleaseNotFound).Times(1)
488+
c.GetHelmRelease(ctx, restConfig, defaultProxy.DeepCopy().Spec).Return(nil, helmDriver.ErrReleaseNotFound).Times(1)
488489
},
489490
expect: func(g *WithT, hrp *addonsv1alpha1.HelmReleaseProxy) {
490491
g.Expect(conditions.Has(hrp, addonsv1alpha1.HelmReleaseReadyCondition)).To(BeTrue())
@@ -499,7 +500,7 @@ func TestReconcileDelete(t *testing.T) {
499500
name: "error attempting to get Helm release",
500501
helmReleaseProxy: defaultProxy.DeepCopy(),
501502
clientExpect: func(g *WithT, c *mocks.MockClientMockRecorder) {
502-
c.GetHelmRelease(ctx, kubeconfig, defaultProxy.DeepCopy().Spec).Return(nil, errInternal).Times(1)
503+
c.GetHelmRelease(ctx, restConfig, defaultProxy.DeepCopy().Spec).Return(nil, errInternal).Times(1)
503504
},
504505
expect: func(g *WithT, hrp *addonsv1alpha1.HelmReleaseProxy) {
505506
g.Expect(conditions.Has(hrp, addonsv1alpha1.HelmReleaseReadyCondition)).To(BeTrue())
@@ -530,7 +531,7 @@ func TestReconcileDelete(t *testing.T) {
530531
Build(),
531532
}
532533

533-
err := r.reconcileDelete(ctx, tc.helmReleaseProxy, clientMock, kubeconfig)
534+
err := r.reconcileDelete(ctx, tc.helmReleaseProxy, clientMock, restConfig)
534535
if tc.expectedError != "" {
535536
g.Expect(err).To(HaveOccurred())
536537
g.Expect(err).To(MatchError(tc.expectedError), err.Error())

controllers/suite_test.go

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,20 @@ import (
5050
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
5151

5252
var (
53-
k8sClient client.Client
54-
testEnv *envtest.Environment
55-
k8sManager manager.Manager
56-
ctx context.Context
57-
cancel context.CancelFunc
58-
helmClient *mocks.MockClient
59-
kubeconfigGetter *mocks.MockGetter
53+
k8sClient client.Client
54+
testEnv *envtest.Environment
55+
k8sManager manager.Manager
56+
ctx context.Context
57+
cancel context.CancelFunc
58+
helmClient *mocks.MockClient
6059
)
6160

6261
const (
6362
timeout = time.Second * 10
6463
interval = time.Millisecond * 250
6564
)
6665

67-
func TestAPIs(t *testing.T) {
66+
func TestControllers(t *testing.T) {
6867
RegisterFailHandler(Fail)
6968

7069
RunSpecs(t, "Controller Suite")
@@ -128,12 +127,10 @@ var _ = BeforeSuite(func() {
128127
Expect(k8sClient).NotTo(BeNil())
129128

130129
helmClient = mocks.NewMockClient(gomock.NewController(&TestReporter{}))
131-
kubeconfigGetter = mocks.NewMockGetter(gomock.NewController(&TestReporter{}))
132130

133-
kubeconfigGetter.EXPECT().GetClusterKubeconfig(gomock.Any(), client.ObjectKeyFromObject(cluster1)).Return(kubeconfig, nil).AnyTimes()
134-
helmClient.EXPECT().InstallOrUpgradeHelmRelease(gomock.Any(), kubeconfig, gomock.Any(), gomock.Any(), gomock.Any()).Return(helmReleaseDeployed, nil).AnyTimes()
135-
helmClient.EXPECT().UninstallHelmRelease(gomock.Any(), kubeconfig, gomock.Any()).Return(&helmRelease.UninstallReleaseResponse{}, nil).AnyTimes()
136-
helmClient.EXPECT().GetHelmRelease(gomock.Any(), kubeconfig, gomock.Any()).Return(&helmRelease.Release{}, nil).AnyTimes()
131+
helmClient.EXPECT().InstallOrUpgradeHelmRelease(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(helmReleaseDeployed, nil).AnyTimes()
132+
helmClient.EXPECT().UninstallHelmRelease(gomock.Any(), gomock.Any(), gomock.Any()).Return(&helmRelease.UninstallReleaseResponse{}, nil).AnyTimes()
133+
helmClient.EXPECT().GetHelmRelease(gomock.Any(), gomock.Any(), gomock.Any()).Return(&helmRelease.Release{}, nil).AnyTimes()
137134

138135
err = (&helmchartproxy.HelmChartProxyReconciler{
139136
Client: k8sManager.GetClient(),
@@ -142,10 +139,9 @@ var _ = BeforeSuite(func() {
142139
Expect(err).ToNot(HaveOccurred())
143140

144141
err = (&helmreleaseproxy.HelmReleaseProxyReconciler{
145-
Client: k8sManager.GetClient(),
146-
Scheme: k8sManager.GetScheme(),
147-
KubeconfigGetter: kubeconfigGetter,
148-
HelmClient: helmClient,
142+
Client: k8sManager.GetClient(),
143+
Scheme: k8sManager.GetScheme(),
144+
HelmClient: helmClient,
149145
}).SetupWithManager(ctx, k8sManager, controller.Options{})
150146
Expect(err).ToNot(HaveOccurred())
151147

0 commit comments

Comments
 (0)