Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions internal/app/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 4 additions & 7 deletions internal/model/image.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package model

import (
"slices"

"github.com/crazy-max/diun/v4/pkg/registry"
)

Expand Down Expand Up @@ -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)
}
Loading