Skip to content

Commit 76c78b8

Browse files
authored
Merge pull request #1289 from fluxcd/generic-secret
helmrepo: only configure tls login option when required
2 parents 9ae35e9 + dfcede0 commit 76c78b8

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

internal/controller/helmchart_controller_test.go

+26-13
Original file line numberDiff line numberDiff line change
@@ -2376,22 +2376,31 @@ func TestHelmChartReconciler_reconcileSourceFromOCI_authStrategy(t *testing.T) {
23762376
},
23772377
},
23782378
{
2379-
name: "HTTPS With CA cert",
2379+
name: "HTTPS With CA cert only",
23802380
want: sreconcile.ResultSuccess,
23812381
registryOpts: registryOptions{
2382-
withTLS: true,
2383-
withClientCertAuth: true,
2384-
},
2385-
secretOpts: secretOptions{
2386-
username: testRegistryUsername,
2387-
password: testRegistryPassword,
2382+
withTLS: true,
23882383
},
2389-
secret: &corev1.Secret{
2384+
certSecret: &corev1.Secret{
23902385
ObjectMeta: metav1.ObjectMeta{
2391-
Name: "auth-secretref",
2386+
Name: "certs-secretref",
23922387
},
2393-
Type: corev1.SecretTypeDockerConfigJson,
2394-
Data: map[string][]byte{},
2388+
Type: corev1.SecretTypeOpaque,
2389+
Data: map[string][]byte{
2390+
"ca.crt": tlsCA,
2391+
},
2392+
},
2393+
assertConditions: []metav1.Condition{
2394+
*conditions.TrueCondition(meta.ReconcilingCondition, meta.ProgressingReason, "building artifact: pulled 'helmchart' chart with version '0.1.0'"),
2395+
*conditions.UnknownCondition(meta.ReadyCondition, meta.ProgressingReason, "building artifact: pulled 'helmchart' chart with version '0.1.0'"),
2396+
},
2397+
},
2398+
{
2399+
name: "HTTPS With CA cert and client cert auth",
2400+
want: sreconcile.ResultSuccess,
2401+
registryOpts: registryOptions{
2402+
withTLS: true,
2403+
withClientCertAuth: true,
23952404
},
23962405
certSecret: &corev1.Secret{
23972406
ObjectMeta: metav1.ObjectMeta{
@@ -2526,8 +2535,12 @@ func TestHelmChartReconciler_reconcileSourceFromOCI_authStrategy(t *testing.T) {
25262535
sp := patch.NewSerialPatcher(obj, r.Client)
25272536

25282537
got, err := r.reconcileSource(ctx, sp, obj, &b)
2529-
g.Expect(err != nil).To(Equal(tt.wantErr))
2530-
g.Expect(got).To(Equal(tt.want))
2538+
if tt.wantErr {
2539+
g.Expect(err).To(HaveOccurred())
2540+
} else {
2541+
g.Expect(err).ToNot(HaveOccurred())
2542+
g.Expect(got).To(Equal(tt.want))
2543+
}
25312544
g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(tt.assertConditions))
25322545
})
25332546
}

internal/helm/getter/client_opts.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ func GetClientOpts(ctx context.Context, c client.Client, obj *helmv1.HelmReposit
162162
}
163163
if loginOpt != nil {
164164
hrOpts.RegLoginOpts = []helmreg.LoginOption{loginOpt}
165-
}
166-
tlsLoginOpt := registry.TLSLoginOption(certFile, keyFile, caFile)
167-
if tlsLoginOpt != nil {
168-
hrOpts.RegLoginOpts = append(hrOpts.RegLoginOpts, tlsLoginOpt)
165+
tlsLoginOpt := registry.TLSLoginOption(certFile, keyFile, caFile)
166+
if tlsLoginOpt != nil {
167+
hrOpts.RegLoginOpts = append(hrOpts.RegLoginOpts, tlsLoginOpt)
168+
}
169169
}
170170
}
171171
if deprecatedTLSConfig {

0 commit comments

Comments
 (0)