Skip to content

Commit e0bd19c

Browse files
committed
fixup! fixup! fixup! Migrate OCIRepository controller to runtime/secrets
Signed-off-by: cappyzawa <[email protected]>
1 parent 06b3d72 commit e0bd19c

File tree

4 files changed

+7
-18
lines changed

4 files changed

+7
-18
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ require (
3838
github.com/fluxcd/pkg/lockedfile v0.6.0
3939
github.com/fluxcd/pkg/masktoken v0.7.0
4040
github.com/fluxcd/pkg/oci v0.51.0
41-
github.com/fluxcd/pkg/runtime v0.73.0
41+
github.com/fluxcd/pkg/runtime v0.75.0
4242
github.com/fluxcd/pkg/sourceignore v0.13.0
4343
github.com/fluxcd/pkg/ssh v0.20.0
4444
github.com/fluxcd/pkg/tar v0.13.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ github.com/fluxcd/pkg/masktoken v0.7.0 h1:pitmyOg2pUVdW+nn2Lk/xqm2TaA08uxvOC0ns3
398398
github.com/fluxcd/pkg/masktoken v0.7.0/go.mod h1:Lc1uoDjO1GY6+YdkK+ZqqBIBWquyV58nlSJ5S1N1IYU=
399399
github.com/fluxcd/pkg/oci v0.51.0 h1:9oYnm+T4SCVSBif9gn80ALJkMGSERabVMDJiaMIdr7Y=
400400
github.com/fluxcd/pkg/oci v0.51.0/go.mod h1:5J6IhHoDVYCVeBEC+4E3nPeKh7d0kjJ8IEL6NVCiTx4=
401-
github.com/fluxcd/pkg/runtime v0.73.0 h1:BV3qEwMT3lfHA2lterT3Es62z6EkJr2ST/jkyBmmskQ=
402-
github.com/fluxcd/pkg/runtime v0.73.0/go.mod h1:iGhdaEq+lMJQTJNAFEPOU4gUJ7kt3yeDcJPZy7O9IUw=
401+
github.com/fluxcd/pkg/runtime v0.75.0 h1:wIaODmU5D54nyrehTqA9oQDFoi6BbBj/24adLStXc0I=
402+
github.com/fluxcd/pkg/runtime v0.75.0/go.mod h1:iGhdaEq+lMJQTJNAFEPOU4gUJ7kt3yeDcJPZy7O9IUw=
403403
github.com/fluxcd/pkg/sourceignore v0.13.0 h1:ZvkzX2WsmyZK9cjlqOFFW1onHVzhPZIqDbCh96rPqbU=
404404
github.com/fluxcd/pkg/sourceignore v0.13.0/go.mod h1:Z9H1GoBx0ljOhptnzoV0PL6Nd/UzwKcSphP27lqb4xI=
405405
github.com/fluxcd/pkg/ssh v0.20.0 h1:Ak0laIYIc/L8lEfqls/LDWRW8wYPESGaravQsCRGLb8=

internal/controller/helmrepository_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
482482
repoURL, err := repository.NormalizeURL(serverURL)
483483
t.Expect(err).ToNot(HaveOccurred())
484484

485-
tlsConfig, err := secrets.TLSConfigFromSecret(context.TODO(), secret)
485+
tlsConfig, err := secrets.TLSConfigFromSecret(context.TODO(), secret, serverURL, false)
486486
t.Expect(err).ToNot(HaveOccurred())
487487

488488
getterOpts := []helmgetter.Option{
@@ -534,7 +534,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
534534
repoURL, err := repository.NormalizeURL(serverURL)
535535
t.Expect(err).ToNot(HaveOccurred())
536536

537-
tlsConfig, err := secrets.TLSConfigFromSecret(context.TODO(), secret)
537+
tlsConfig, err := secrets.TLSConfigFromSecret(context.TODO(), secret, serverURL, false)
538538
t.Expect(err).ToNot(HaveOccurred())
539539

540540
getterOpts := []helmgetter.Option{
@@ -588,7 +588,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
588588
repoURL, err := repository.NormalizeURL(serverURL)
589589
t.Expect(err).ToNot(HaveOccurred())
590590

591-
tlsConfig, err := secrets.TLSConfigFromSecret(context.TODO(), secret)
591+
tlsConfig, err := secrets.TLSConfigFromSecret(context.TODO(), secret, serverURL, false)
592592
t.Expect(err).ToNot(HaveOccurred())
593593

594594
getterOpts := []helmgetter.Option{

internal/controller/ocirepository_controller.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -971,17 +971,6 @@ func (r *OCIRepositoryReconciler) transport(ctx context.Context, obj *sourcev1.O
971971
return nil, err
972972
}
973973
if tlsConfig != nil {
974-
// Set ServerName for proper virtual hosting support.
975-
// This is crucial for OCI registries that use virtual hosting where multiple
976-
// registries are hosted on the same IP address. Without ServerName, the TLS
977-
// handshake would fail with a certificate mismatch error.
978-
// Note: runtime/secrets does not set ServerName, so this must be done at the
979-
// controller level to ensure proper TLS SNI (Server Name Indication) support.
980-
u, err := url.Parse(obj.Spec.URL)
981-
if err != nil {
982-
return nil, fmt.Errorf("cannot parse repository URL: %w", err)
983-
}
984-
tlsConfig.ServerName = u.Hostname()
985974
transport.TLSClientConfig = tlsConfig
986975
}
987976

@@ -1008,7 +997,7 @@ func (r *OCIRepositoryReconciler) getTLSConfig(ctx context.Context, obj *sourcev
1008997
Namespace: obj.Namespace,
1009998
Name: obj.Spec.CertSecretRef.Name,
1010999
}
1011-
return secrets.TLSConfigFromSecretRef(ctx, r.Client, secretName)
1000+
return secrets.TLSConfigFromSecretRef(ctx, r.Client, secretName, obj.Spec.URL, obj.Spec.Insecure)
10121001
}
10131002

10141003
// reconcileStorage ensures the current state of the storage matches the

0 commit comments

Comments
 (0)