@@ -472,12 +472,20 @@ func (r *ConnectorReconciler) reconcileDeployment(ctx context.Context, cr *v1alp
472472
473473 // Determine if Deployment needs updates by comparing specs
474474 needsUpdate := false
475- if ! reflect .DeepEqual (deploy .Spec .Template .Spec .Containers [0 ].Env , found .Spec .Template .Spec .Containers [0 ].Env ) {
475+ desiredContainer := deploy .Spec .Template .Spec .Containers [0 ]
476+ currentContainer := found .Spec .Template .Spec .Containers [0 ]
477+
478+ if desiredContainer .Image != currentContainer .Image {
479+ needsUpdate = true
480+ logger .Info ("Container image needs update" , "current" , currentContainer .Image , "desired" , desiredContainer .Image )
481+ }
482+
483+ if ! reflect .DeepEqual (desiredContainer .Env , currentContainer .Env ) {
476484 needsUpdate = true
477485 logger .Info ("Environment variables need update" )
478486 }
479487
480- if ! reflect .DeepEqual (deploy . Spec . Template . Spec . Containers [ 0 ]. Resources , found . Spec . Template . Spec . Containers [ 0 ] .Resources ) {
488+ if ! reflect .DeepEqual (desiredContainer . Resources , currentContainer .Resources ) {
481489 needsUpdate = true
482490 logger .Info ("Resources need update" )
483491 }
@@ -487,8 +495,10 @@ func (r *ConnectorReconciler) reconcileDeployment(ctx context.Context, cr *v1alp
487495 logger .Info ("Updating Deployment" , "Name" , found .Name )
488496 // Create a copy to update
489497 updatedDeploy := found .DeepCopy ()
490- updatedDeploy .Spec .Template .Spec .Containers [0 ].Env = deploy .Spec .Template .Spec .Containers [0 ].Env
491- updatedDeploy .Spec .Template .Spec .Containers [0 ].Resources = deploy .Spec .Template .Spec .Containers [0 ].Resources
498+ updatedContainer := & updatedDeploy .Spec .Template .Spec .Containers [0 ]
499+ updatedContainer .Image = desiredContainer .Image
500+ updatedContainer .Env = desiredContainer .Env
501+ updatedContainer .Resources = desiredContainer .Resources
492502
493503 if err = r .Update (ctx , updatedDeploy ); err != nil {
494504 // If conflict occurred, log but don't return error
0 commit comments