@@ -1623,8 +1623,11 @@ user_data_collector_config: {}
16231623
16241624 cr .Spec .OLSConfig .ProxyConfig = & olsv1alpha1.ProxyConfig {
16251625 ProxyURL : "https://proxy.example.com:8080" ,
1626- ProxyCACertificateRef : & corev1.LocalObjectReference {
1627- Name : caConfigMapName ,
1626+ ProxyCACertificateRef : & corev1.ConfigMapKeySelector {
1627+ LocalObjectReference : corev1.LocalObjectReference {
1628+ Name : caConfigMapName ,
1629+ },
1630+ // No Key specified - tests backward compatibility
16281631 },
16291632 }
16301633
@@ -1643,6 +1646,12 @@ user_data_collector_config: {}
16431646 Name : caConfigMapName ,
16441647 },
16451648 DefaultMode : & defaultVolumeMode ,
1649+ Items : []corev1.KeyToPath {
1650+ {
1651+ Key : utils .ProxyCACertFileName ,
1652+ Path : utils .ProxyCACertFileName ,
1653+ },
1654+ },
16461655 },
16471656 },
16481657 }))
@@ -1662,14 +1671,58 @@ user_data_collector_config: {}
16621671
16631672 cr .Spec .OLSConfig .ProxyConfig = & olsv1alpha1.ProxyConfig {
16641673 ProxyURL : "https://proxy.example.com:8080" ,
1665- ProxyCACertificateRef : & corev1.LocalObjectReference {
1666- Name : caConfigMapName ,
1674+ ProxyCACertificateRef : & corev1.ConfigMapKeySelector {
1675+ LocalObjectReference : corev1.LocalObjectReference {
1676+ Name : caConfigMapName ,
1677+ },
1678+ // No Key specified - tests backward compatibility
16671679 },
16681680 }
16691681 _ , err = GenerateOLSConfigMap (testReconcilerInstance , ctx , cr )
16701682 Expect (err ).To (HaveOccurred ())
16711683 Expect (err .Error ()).To (ContainSubstring ("failed to validate proxy CA certificate" ))
16721684 })
1685+
1686+ It ("should support custom ConfigMap key for proxy CA certificate" , func () {
1687+ customKey := "service-ca.crt"
1688+ proxyCACm .Data = map [string ]string {
1689+ customKey : utils .TestCACert ,
1690+ }
1691+ err := testReconcilerInstance .Update (ctx , proxyCACm )
1692+ Expect (err ).NotTo (HaveOccurred ())
1693+
1694+ cr .Spec .OLSConfig .ProxyConfig = & olsv1alpha1.ProxyConfig {
1695+ ProxyURL : "https://proxy.example.com:8080" ,
1696+ ProxyCACertificateRef : & corev1.ConfigMapKeySelector {
1697+ LocalObjectReference : corev1.LocalObjectReference {
1698+ Name : caConfigMapName ,
1699+ },
1700+ Key : customKey ,
1701+ },
1702+ }
1703+
1704+ // Test OLS ConfigMap has correct path with custom key
1705+ olsCm , err := GenerateOLSConfigMap (testReconcilerInstance , ctx , cr )
1706+ Expect (err ).NotTo (HaveOccurred ())
1707+ Expect (olsCm .Data [utils .OLSConfigFilename ]).To (ContainSubstring (
1708+ fmt .Sprintf ("proxy_ca_cert_path: /etc/certs/proxy-ca/%s" , customKey )))
1709+
1710+ // Test deployment has Items projection with custom key
1711+ dep , err := GenerateOLSDeployment (testReconcilerInstance , cr )
1712+ Expect (err ).NotTo (HaveOccurred ())
1713+
1714+ var proxyCAVolume * corev1.Volume
1715+ for i := range dep .Spec .Template .Spec .Volumes {
1716+ if dep .Spec .Template .Spec .Volumes [i ].Name == utils .ProxyCACertVolumeName {
1717+ proxyCAVolume = & dep .Spec .Template .Spec .Volumes [i ]
1718+ break
1719+ }
1720+ }
1721+ Expect (proxyCAVolume ).NotTo (BeNil ())
1722+ Expect (proxyCAVolume .ConfigMap .Items ).To (HaveLen (1 ))
1723+ Expect (proxyCAVolume .ConfigMap .Items [0 ].Key ).To (Equal (customKey ))
1724+ Expect (proxyCAVolume .ConfigMap .Items [0 ].Path ).To (Equal (customKey ))
1725+ })
16731726 })
16741727})
16751728
0 commit comments