Skip to content

Instantly share code, notes, and snippets.

@selcukusta
Created November 28, 2019 11:46
Show Gist options
  • Save selcukusta/f69e67c42444b87d81c83ec01a00bff2 to your computer and use it in GitHub Desktop.
Save selcukusta/f69e67c42444b87d81c83ec01a00bff2 to your computer and use it in GitHub Desktop.
currentConfigMap := &corev1.ConfigMap{}
newConfigMap := r.createConfigMap(instance, map[string]string{instance.Spec.Config.ConfigMapKey: instance.Spec.Config.ConfigMapValue})
err = r.client.Get(context.TODO(), types.NamespacedName{Name: instance.Spec.Config.ConfigMapName, Namespace: request.Namespace}, currentConfigMap)
if err == nil {
if !reflect.DeepEqual(currentConfigMap.Data, newConfigMap.Data) {
reqLogger.Info(fmt.Sprintf("ConfigMap will be changed: %v", instance.Spec.Config.ConfigMapName))
if r.client.Update(context.TODO(), newConfigMap) != nil {
return reconcile.Result{}, err
}
for _, deployment := range instance.Spec.LinkedDeployments {
reqLogger.Info(fmt.Sprintf("Deployment will be restarted: %v", deployment))
if r.restartDeployment(deployment, request.Namespace) != nil {
return reconcile.Result{}, err
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment