diff --git a/internal/app/job.go b/internal/app/job.go index 447df8a39..126b82913 100644 --- a/internal/app/job.go +++ b/internal/app/job.go @@ -194,10 +194,20 @@ func (di *Diun) runJob(job model.Job) (entry model.NotifEntry) { } var updated bool - entry.Manifest, updated, err = job.Registry.Manifest(job.RegImage, dbManifest) - if err != nil { - sublog.Warn().Err(err).Msg("Cannot get remote manifest") - return + + // If we care about updated models, go check for an update + if model.NotifyOnUpdate.OneOf(job.Image.NotifyOn) { + entry.Manifest, updated, err = job.Registry.Manifest(job.RegImage, dbManifest) + if err != nil { + sublog.Warn().Err(err).Msg("Cannot get remote manifest") + return + } + } else { + // Otherwise use a stub + entry.Manifest = registry.Manifest{ + Name: job.RegImage.Name(), + Tag: job.RegImage.Tag, + } } if v, ok := entry.Manifest.Labels["org.opencontainers.image.url"]; ok { diff --git a/internal/model/image.go b/internal/model/image.go index fe712df57..1046e79b9 100644 --- a/internal/model/image.go +++ b/internal/model/image.go @@ -1,6 +1,8 @@ package model import ( + "slices" + "github.com/crazy-max/diun/v4/pkg/registry" ) @@ -60,11 +62,6 @@ func (ns *NotifyOn) Valid() bool { } // OneOf checks if notify status is one of the values in the list -func (ns *NotifyOn) OneOf(nsl []NotifyOn) bool { - for _, n := range nsl { - if n == *ns { - return true - } - } - return false +func (ns NotifyOn) OneOf(nsl []NotifyOn) bool { + return slices.Contains(nsl, ns) }