@@ -277,18 +277,7 @@ func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationStat
277277 continue
278278 }
279279
280- // If the user has specified digest as update strategy, but the running
281- // image is configured to use a tag and no digest, we need to set an
282- // initial dummy digest, so that tag.Equals() will return false.
283- // TODO: Fix this. This is just a workaround.
284- if vc .Strategy == image .StrategyDigest {
285- if ! updateableImage .ImageTag .IsDigest () {
286- log .Tracef ("Setting dummy digest for image %s" , updateableImage .GetFullNameWithTag ())
287- updateableImage .ImageTag .TagDigest = "dummy"
288- }
289- }
290-
291- if needsUpdate (updateableImage , applicationImage , latest ) {
280+ if needsUpdate (updateableImage , applicationImage , latest , vc .Strategy ) {
292281 appImageWithTag := applicationImage .WithTag (latest )
293282 appImageFullNameWithTag := appImageWithTag .GetFullNameWithTag ()
294283
@@ -392,7 +381,17 @@ func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationStat
392381 return result
393382}
394383
395- func needsUpdate (updateableImage * image.ContainerImage , applicationImage * image.ContainerImage , latest * tag.ImageTag ) bool {
384+ func needsUpdate (updateableImage * image.ContainerImage , applicationImage * image.ContainerImage , latest * tag.ImageTag , strategy image.UpdateStrategy ) bool {
385+ if strategy == image .StrategyDigest {
386+ if updateableImage .ImageTag == nil {
387+ return true
388+ }
389+ // When using digest strategy, consider the digest even if the current image
390+ // was referenced by tag. If either digest is missing or differs, we want an update.
391+ if ! updateableImage .ImageTag .IsDigest () || updateableImage .ImageTag .TagDigest != latest .TagDigest {
392+ return true
393+ }
394+ }
396395 // If the latest tag does not match image's current tag or the kustomize image is different, it means we have an update candidate.
397396 return ! updateableImage .ImageTag .Equals (latest ) || applicationImage .KustomizeImage != nil && applicationImage .DiffersFrom (updateableImage , false )
398397}
0 commit comments