Skip to content

Commit

Permalink
Update latest value of OpenShiftRolloutPlugin in ConfigMap
Browse files Browse the repository at this point in the history
Signed-off-by: Rizwana777 <[email protected]>
  • Loading branch information
Rizwana777 committed Mar 18, 2024
1 parent 0100dce commit 63b9e20
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions controllers/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,25 @@ func (r *RolloutManagerReconciler) reconcileConfigMap(ctx context.Context, cr *r
return fmt.Errorf("failed to unmarshal traffic router plugins from ConfigMap: %s", err)
}

for _, plugin := range actualTrafficRouterPlugins {
// Check if the plugin already exists and if the URL is different, update the ConfigMap
for i, plugin := range actualTrafficRouterPlugins {
if plugin.Name == OpenShiftRolloutPluginName {
// Openshift Route Plugin already present, nothing to do
return nil
if plugin.Location != r.OpenShiftRoutePluginLocation {
actualTrafficRouterPlugins[i].Location = r.OpenShiftRoutePluginLocation
pluginString, err := yaml.Marshal(actualTrafficRouterPlugins)
if err != nil {
return fmt.Errorf("error marshalling trafficRouterPlugin to string %s", err)
}

actualConfigMap.Data = map[string]string{
TrafficRouterPluginConfigMapKey: string(pluginString),
}

return r.Client.Update(ctx, actualConfigMap)
} else {
// Plugin URL is the same, nothing to do
return nil
}
}
}

Expand Down

0 comments on commit 63b9e20

Please sign in to comment.