@@ -1626,8 +1626,9 @@ user_data_collector_config: {}
16261626
16271627 cr .Spec .OLSConfig .ProxyConfig = & olsv1alpha1.ProxyConfig {
16281628 ProxyURL : "https://proxy.example.com:8080" ,
1629- ProxyCACertificateRef : & corev1. LocalObjectReference {
1629+ ProxyCACertificateRef : & olsv1alpha1. ProxyCACertConfigMapRef {
16301630 Name : caConfigMapName ,
1631+ // No Key specified - tests backward compatibility
16311632 },
16321633 }
16331634
@@ -1646,6 +1647,12 @@ user_data_collector_config: {}
16461647 Name : caConfigMapName ,
16471648 },
16481649 DefaultMode : & defaultVolumeMode ,
1650+ Items : []corev1.KeyToPath {
1651+ {
1652+ Key : utils .ProxyCACertFileName ,
1653+ Path : utils .ProxyCACertFileName ,
1654+ },
1655+ },
16491656 },
16501657 },
16511658 }))
@@ -1665,14 +1672,54 @@ user_data_collector_config: {}
16651672
16661673 cr .Spec .OLSConfig .ProxyConfig = & olsv1alpha1.ProxyConfig {
16671674 ProxyURL : "https://proxy.example.com:8080" ,
1668- ProxyCACertificateRef : & corev1. LocalObjectReference {
1675+ ProxyCACertificateRef : & olsv1alpha1. ProxyCACertConfigMapRef {
16691676 Name : caConfigMapName ,
1677+ // No Key specified - tests backward compatibility
16701678 },
16711679 }
16721680 _ , err = GenerateOLSConfigMap (testReconcilerInstance , ctx , cr )
16731681 Expect (err ).To (HaveOccurred ())
16741682 Expect (err .Error ()).To (ContainSubstring ("failed to validate proxy CA certificate" ))
16751683 })
1684+
1685+ It ("should support custom ConfigMap key for proxy CA certificate" , func () {
1686+ customKey := "service-ca.crt"
1687+ proxyCACm .Data = map [string ]string {
1688+ customKey : utils .TestCACert ,
1689+ }
1690+ err := testReconcilerInstance .Update (ctx , proxyCACm )
1691+ Expect (err ).NotTo (HaveOccurred ())
1692+
1693+ cr .Spec .OLSConfig .ProxyConfig = & olsv1alpha1.ProxyConfig {
1694+ ProxyURL : "https://proxy.example.com:8080" ,
1695+ ProxyCACertificateRef : & olsv1alpha1.ProxyCACertConfigMapRef {
1696+ Name : caConfigMapName ,
1697+ Key : customKey ,
1698+ },
1699+ }
1700+
1701+ // Test OLS ConfigMap has correct path with custom key
1702+ olsCm , err := GenerateOLSConfigMap (testReconcilerInstance , ctx , cr )
1703+ Expect (err ).NotTo (HaveOccurred ())
1704+ Expect (olsCm .Data [utils .OLSConfigFilename ]).To (ContainSubstring (
1705+ fmt .Sprintf ("proxy_ca_cert_path: /etc/certs/proxy-ca/%s" , customKey )))
1706+
1707+ // Test deployment has Items projection with custom key
1708+ dep , err := GenerateOLSDeployment (testReconcilerInstance , cr )
1709+ Expect (err ).NotTo (HaveOccurred ())
1710+
1711+ var proxyCAVolume * corev1.Volume
1712+ for i := range dep .Spec .Template .Spec .Volumes {
1713+ if dep .Spec .Template .Spec .Volumes [i ].Name == utils .ProxyCACertVolumeName {
1714+ proxyCAVolume = & dep .Spec .Template .Spec .Volumes [i ]
1715+ break
1716+ }
1717+ }
1718+ Expect (proxyCAVolume ).NotTo (BeNil ())
1719+ Expect (proxyCAVolume .ConfigMap .Items ).To (HaveLen (1 ))
1720+ Expect (proxyCAVolume .ConfigMap .Items [0 ].Key ).To (Equal (customKey ))
1721+ Expect (proxyCAVolume .ConfigMap .Items [0 ].Path ).To (Equal (customKey ))
1722+ })
16761723 })
16771724})
16781725
0 commit comments