@@ -277,18 +277,7 @@ func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationStat
277
277
continue
278
278
}
279
279
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 ) {
292
281
appImageWithTag := applicationImage .WithTag (latest )
293
282
appImageFullNameWithTag := appImageWithTag .GetFullNameWithTag ()
294
283
@@ -392,7 +381,17 @@ func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationStat
392
381
return result
393
382
}
394
383
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
+ }
396
395
// If the latest tag does not match image's current tag or the kustomize image is different, it means we have an update candidate.
397
396
return ! updateableImage .ImageTag .Equals (latest ) || applicationImage .KustomizeImage != nil && applicationImage .DiffersFrom (updateableImage , false )
398
397
}
0 commit comments