@@ -48,73 +48,76 @@ local CiliumBGPNodeConfigOverride(name) =
4848 };
4949
5050local validate_auth_secret(name, config) =
51- local data = std.get(config, 'data' , {});
52- local sdata = std.get(config, 'stringData' , {});
53- assert
54- std.objectHas (data, 'password' ) || std.objectHas (sdata, 'password' )
55- : "Cilium BGP auth secret `%s` doesn't have key `password`" % name;
56- config {
57- metadata+: {
58- namespace: params.cilium_helm_values.bgpControlPlane.secretsNamespace.name,
59- },
60- };
51+ if config != null then
52+ local data = std.get(config, 'data' , {});
53+ local sdata = std.get(config, 'stringData' , {});
54+ assert
55+ std.objectHas (data, 'password' ) || std.objectHas (sdata, 'password' )
56+ : "Cilium BGP auth secret `%s` doesn't have key `password`" % name;
57+ config {
58+ metadata+: {
59+ namespace: params.cilium_helm_values.bgpControlPlane.secretsNamespace.name,
60+ },
61+ };
6162
6263local authsecrets = com.generateResources(
6364 std.mapWithKey (validate_auth_secret, params.bgp.auth_secrets),
6465 kube.Secret
6566);
6667
6768local render_peer_config(name, config) =
68- local auth_secret_names = [ o.metadata.name for o in authsecrets ];
69- local validate_peer_config(pconfig) =
70- local secretname = std.get(pconfig.spec, 'authSecretRef' );
71- assert
72- secretname == null || std.member(auth_secret_names, secretname)
73- : "CiliumBGPPeerConfig `%s` references auth secret `%s` which doesn't exist"
74- % [ name, secretname ];
75- pconfig;
76- validate_peer_config({
77- metadata+: std.get(config, 'metadata' , {}),
78- spec: {
79- families: std.objectValues(std.get(config, 'families' , {})),
80- } + com.makeMergeable(std.get(config, 'spec' , {})),
81- });
69+ if config != null then
70+ local auth_secret_names = [ o.metadata.name for o in authsecrets ];
71+ local validate_peer_config(pconfig) =
72+ local secretname = std.get(pconfig.spec, 'authSecretRef' );
73+ assert
74+ secretname == null || std.member(auth_secret_names, secretname)
75+ : "CiliumBGPPeerConfig `%s` references auth secret `%s` which doesn't exist"
76+ % [ name, secretname ];
77+ pconfig;
78+ validate_peer_config({
79+ metadata+: std.get(config, 'metadata' , {}),
80+ spec: {
81+ families: std.objectValues(std.get(config, 'families' , {})),
82+ } + com.makeMergeable(std.get(config, 'spec' , {})),
83+ });
8284
8385local bgppeerconfigs = com.generateResources(
8486 std.mapWithKey (render_peer_config, params.bgp.peer_configs),
8587 CiliumBGPPeerConfig
8688);
8789
8890local render_cluster_config(name, config) =
89- local peerConfigNames = [ o.metadata.name for o in bgppeerconfigs ];
90- local validate_peer_config(iname, pconfig) =
91- local pcfgname = std.get(pconfig, 'peerConfigRef' , { name: '' }).name;
92- assert
93- std.member(peerConfigNames, pcfgname)
94- : 'Peer `%s` in BGP instance `%s` in CiliumBGPClusterConfig `%s` ' %
95- [ pconfig.name, iname, name ]
96- + "references CiliumBGPPeerConfig `%s` which doesn't exist" %
97- [ pcfgname ];
98- pconfig;
99- local render_instance(name, iconfig) =
100- local cfg = iconfig {
101- name: name,
102- peers: [
103- validate_peer_config(name, iconfig.peers[pname] { name: pname })
104- for pname in std.objectFields (iconfig.peers)
105- ],
91+ if config != null then
92+ local peerConfigNames = [ o.metadata.name for o in bgppeerconfigs ];
93+ local validate_peer_config(iname, pconfig) =
94+ local pcfgname = std.get(pconfig, 'peerConfigRef' , { name: '' }).name;
95+ assert
96+ std.member(peerConfigNames, pcfgname)
97+ : 'Peer `%s` in BGP instance `%s` in CiliumBGPClusterConfig `%s` ' %
98+ [ pconfig.name, iname, name ]
99+ + "references CiliumBGPPeerConfig `%s` which doesn't exist" %
100+ [ pcfgname ];
101+ pconfig;
102+ local render_instance(name, iconfig) =
103+ local cfg = iconfig {
104+ name: name,
105+ peers: [
106+ validate_peer_config(name, iconfig.peers[pname] { name: pname })
107+ for pname in std.objectFields (iconfig.peers)
108+ ],
109+ };
110+ cfg;
111+ {
112+ metadata+: std.get(config, 'metadata' , {}),
113+ spec: {
114+ nodeSelector: std.get(config, 'nodeSelector' , {}),
115+ bgpInstances: std.objectValues(std.mapWithKey (
116+ render_instance,
117+ config.bgpInstances
118+ )),
119+ } + com.makeMergeable(std.get(config, 'spec' , {})),
106120 };
107- cfg;
108- {
109- metadata+: std.get(config, 'metadata' , {}),
110- spec: {
111- nodeSelector: std.get(config, 'nodeSelector' , {}),
112- bgpInstances: std.objectValues(std.mapWithKey (
113- render_instance,
114- config.bgpInstances
115- )),
116- } + com.makeMergeable(std.get(config, 'spec' , {})),
117- };
118121
119122local bgpclusterconfigs = com.generateResources(
120123 std.mapWithKey (render_cluster_config, params.bgp.cluster_configs),
@@ -123,12 +126,13 @@ local bgpclusterconfigs = com.generateResources(
123126
124127
125128local render_advertisement(name, config) =
126- {
127- metadata+: std.get(config, 'metadata' , {}),
128- spec: {
129- advertisements: std.objectValues(std.get(config, 'advertisements' , {})),
130- },
131- };
129+ if config != null then
130+ {
131+ metadata+: std.get(config, 'metadata' , {}),
132+ spec: {
133+ advertisements: std.objectValues(std.get(config, 'advertisements' , {})),
134+ },
135+ };
132136
133137local bgpadvertisements = com.generateResources(
134138 std.mapWithKey (render_advertisement, params.bgp.advertisements),
0 commit comments