@@ -1648,8 +1648,9 @@ user_data_collector_config: {}
16481648
16491649 cr .Spec .OLSConfig .ProxyConfig = & olsv1alpha1.ProxyConfig {
16501650 ProxyURL : "https://proxy.example.com:8080" ,
1651- ProxyCACertificateRef : & corev1. LocalObjectReference {
1651+ ProxyCACertificateRef : & olsv1alpha1. ProxyCACertConfigMapRef {
16521652 Name : caConfigMapName ,
1653+ // No Key specified - tests backward compatibility
16531654 },
16541655 }
16551656
@@ -1668,6 +1669,12 @@ user_data_collector_config: {}
16681669 Name : caConfigMapName ,
16691670 },
16701671 DefaultMode : & defaultVolumeMode ,
1672+ Items : []corev1.KeyToPath {
1673+ {
1674+ Key : utils .ProxyCACertFileName ,
1675+ Path : utils .ProxyCACertFileName ,
1676+ },
1677+ },
16711678 },
16721679 },
16731680 }))
@@ -1687,14 +1694,54 @@ user_data_collector_config: {}
16871694
16881695 cr .Spec .OLSConfig .ProxyConfig = & olsv1alpha1.ProxyConfig {
16891696 ProxyURL : "https://proxy.example.com:8080" ,
1690- ProxyCACertificateRef : & corev1. LocalObjectReference {
1697+ ProxyCACertificateRef : & olsv1alpha1. ProxyCACertConfigMapRef {
16911698 Name : caConfigMapName ,
1699+ // No Key specified - tests backward compatibility
16921700 },
16931701 }
16941702 _ , err = GenerateOLSConfigMap (testReconcilerInstance , ctx , cr )
16951703 Expect (err ).To (HaveOccurred ())
16961704 Expect (err .Error ()).To (ContainSubstring ("failed to validate proxy CA certificate" ))
16971705 })
1706+
1707+ It ("should support custom ConfigMap key for proxy CA certificate" , func () {
1708+ customKey := "service-ca.crt"
1709+ proxyCACm .Data = map [string ]string {
1710+ customKey : utils .TestCACert ,
1711+ }
1712+ err := testReconcilerInstance .Update (ctx , proxyCACm )
1713+ Expect (err ).NotTo (HaveOccurred ())
1714+
1715+ cr .Spec .OLSConfig .ProxyConfig = & olsv1alpha1.ProxyConfig {
1716+ ProxyURL : "https://proxy.example.com:8080" ,
1717+ ProxyCACertificateRef : & olsv1alpha1.ProxyCACertConfigMapRef {
1718+ Name : caConfigMapName ,
1719+ Key : customKey ,
1720+ },
1721+ }
1722+
1723+ // Test OLS ConfigMap has correct path with custom key
1724+ olsCm , err := GenerateOLSConfigMap (testReconcilerInstance , ctx , cr )
1725+ Expect (err ).NotTo (HaveOccurred ())
1726+ Expect (olsCm .Data [utils .OLSConfigFilename ]).To (ContainSubstring (
1727+ fmt .Sprintf ("proxy_ca_cert_path: /etc/certs/proxy-ca/%s" , customKey )))
1728+
1729+ // Test deployment has Items projection with custom key
1730+ dep , err := GenerateOLSDeployment (testReconcilerInstance , cr )
1731+ Expect (err ).NotTo (HaveOccurred ())
1732+
1733+ var proxyCAVolume * corev1.Volume
1734+ for i := range dep .Spec .Template .Spec .Volumes {
1735+ if dep .Spec .Template .Spec .Volumes [i ].Name == utils .ProxyCACertVolumeName {
1736+ proxyCAVolume = & dep .Spec .Template .Spec .Volumes [i ]
1737+ break
1738+ }
1739+ }
1740+ Expect (proxyCAVolume ).NotTo (BeNil ())
1741+ Expect (proxyCAVolume .ConfigMap .Items ).To (HaveLen (1 ))
1742+ Expect (proxyCAVolume .ConfigMap .Items [0 ].Key ).To (Equal (customKey ))
1743+ Expect (proxyCAVolume .ConfigMap .Items [0 ].Path ).To (Equal (customKey ))
1744+ })
16981745 })
16991746})
17001747
0 commit comments