@@ -55,7 +55,26 @@ func (r *Resources) ensureGatewayConfig(ctx context.Context, cachedStatus inspec
5555 return errors .WithStack (errors .Wrapf (err , "Failed to generate gateway config" ))
5656 }
5757
58- gatewayCfgYaml , gatewayCfgChecksum , _ , err := cfg .RenderYAML ()
58+ gatewayCfgYaml , _ , _ , err := cfg .RenderYAML ()
59+ if err != nil {
60+ return errors .WithStack (errors .Wrapf (err , "Failed to render gateway config" ))
61+ }
62+
63+ gatewayCfgCDSYaml , _ , _ , err := cfg .RenderCDSYAML ()
64+ if err != nil {
65+ return errors .WithStack (errors .Wrapf (err , "Failed to render gateway cds config" ))
66+ }
67+
68+ gatewayCfgLDSYaml , _ , _ , err := cfg .RenderLDSYAML ()
69+ if err != nil {
70+ return errors .WithStack (errors .Wrapf (err , "Failed to render gateway lds config" ))
71+ }
72+
73+ elements , err := r .renderConfigMap (map [string ]string {
74+ GatewayConfigFileName : string (gatewayCfgYaml ),
75+ GatewayCDSConfigFileName : string (gatewayCfgCDSYaml ),
76+ GatewayLDSConfigFileName : string (gatewayCfgLDSYaml ),
77+ })
5978 if err != nil {
6079 return errors .WithStack (errors .Wrapf (err , "Failed to render gateway config" ))
6180 }
@@ -66,10 +85,7 @@ func (r *Resources) ensureGatewayConfig(ctx context.Context, cachedStatus inspec
6685 ObjectMeta : meta.ObjectMeta {
6786 Name : configMapName ,
6887 },
69- Data : map [string ]string {
70- GatewayConfigFileName : string (gatewayCfgYaml ),
71- GatewayConfigChecksumFileName : gatewayCfgChecksum ,
72- },
88+ Data : elements ,
7389 }
7490
7591 owner := r .context .GetAPIObject ().AsOwner ()
@@ -88,17 +104,14 @@ func (r *Resources) ensureGatewayConfig(ctx context.Context, cachedStatus inspec
88104 return errors .Reconcile ()
89105 } else {
90106 // CM Exists, checks checksum - if key is not in the map we return empty string
91- if existingSha , existingChecksumSha := util .SHA256FromString (cm .Data [ GatewayConfigFileName ] ), cm . Data [ GatewayConfigChecksumFileName ]; existingSha != gatewayCfgChecksum || existingChecksumSha != gatewayCfgChecksum {
107+ if currentSha , expectedSha := util .Optional (cm .Data , ConfigMapChecksumKey , "" ), util . Optional ( elements , ConfigMapChecksumKey , "" ); currentSha != expectedSha || currentSha == "" {
92108 // We need to do the update
93109 if _ , changed , err := patcher .Patcher [* core.ConfigMap ](ctx , cachedStatus .ConfigMapsModInterface ().V1 (), cm , meta.PatchOptions {},
94- patcher .PatchConfigMapData (map [string ]string {
95- GatewayConfigFileName : string (gatewayCfgYaml ),
96- GatewayConfigChecksumFileName : gatewayCfgChecksum ,
97- })); err != nil {
110+ patcher .PatchConfigMapData (elements )); err != nil {
98111 log .Err (err ).Debug ("Failed to patch GatewayConfig ConfigMap" )
99112 return errors .WithStack (err )
100113 } else if changed {
101- log .Str ("service " , cm .GetName ()).Str ("before" , existingSha ).Str ("after" , gatewayCfgChecksum ).Info ("Updated GatewayConfig" )
114+ log .Str ("configmap " , cm .GetName ()).Str ("before" , currentSha ).Str ("after" , expectedSha ).Info ("Updated GatewayConfig" )
102115 }
103116 }
104117 }
0 commit comments