diff --git a/docs/providers/docker.md b/docs/providers/docker.md index 8457831e..66d0a584 100644 --- a/docs/providers/docker.md +++ b/docs/providers/docker.md @@ -182,4 +182,5 @@ You can configure more finely the way to analyze the image of your container thr | `diun.max_tags` | `0` | Maximum number of tags to watch if `diun.watch_repo` enabled. `0` means all of them | | `diun.include_tags` | | Semicolon separated list of regular expressions to include tags. Can be useful if you enable `diun.watch_repo` | | `diun.exclude_tags` | | Semicolon separated list of regular expressions to exclude tags. Can be useful if you enable `diun.watch_repo` | +| `diun.hub_link` | _automatic_ | Set registry hub link for this image | | `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) | diff --git a/docs/providers/dockerfile.md b/docs/providers/dockerfile.md index 7b52b5ad..dd1fe65b 100644 --- a/docs/providers/dockerfile.md +++ b/docs/providers/dockerfile.md @@ -115,4 +115,5 @@ The following annotations can be added as comments before the target instruction | `diun.max_tags` | `0` | Maximum number of tags to watch if `watch_repo` enabled. `0` means all of them | | `diun.include_tags` | | Semicolon separated list of regular expressions to include tags. Can be useful if you enable `diun.watch_repo` | | `diun.exclude_tags` | | Semicolon separated list of regular expressions to exclude tags. Can be useful if you enable `diun.watch_repo` | +| `diun.hub_link` | _automatic_ | Set registry hub link for this image | | `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) | diff --git a/docs/providers/file.md b/docs/providers/file.md index d3dc7d25..6ec858fd 100644 --- a/docs/providers/file.md +++ b/docs/providers/file.md @@ -182,6 +182,7 @@ The configuration file(s) defines a slice of images to analyze with the followin | `max_tags` | `0` | Maximum number of tags to watch if `watch_repo` enabled. `0` means all of them | | `include_tags` | | List of regular expressions to include tags. Can be useful if you enable `watch_repo` | | `exclude_tags` | | List of regular expressions to exclude tags. Can be useful if you enable `watch_repo` | +| `hub_link` | _automatic_ | Set registry hub link for this image | | `platform.os` | _automatic_ | Operating system to use as custom platform | | `platform.arch` | _automatic_ | CPU architecture to use as custom platform | | `platform.variant` | _automatic_ | Variant of the CPU to use as custom platform | diff --git a/docs/providers/kubernetes.md b/docs/providers/kubernetes.md index 929c0454..70b451df 100644 --- a/docs/providers/kubernetes.md +++ b/docs/providers/kubernetes.md @@ -290,4 +290,5 @@ You can configure more finely the way to analyze the image of your pods through | `diun.max_tags` | `0` | Maximum number of tags to watch if `diun.watch_repo` enabled. `0` means all of them | | `diun.include_tags` | | Semicolon separated list of regular expressions to include tags. Can be useful if you enable `diun.watch_repo` | | `diun.exclude_tags` | | Semicolon separated list of regular expressions to exclude tags. Can be useful if you enable `diun.watch_repo` | +| `diun.hub_link` | _automatic_ | Set registry hub link for this image | | `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) | diff --git a/docs/providers/swarm.md b/docs/providers/swarm.md index 760433a4..724ba307 100644 --- a/docs/providers/swarm.md +++ b/docs/providers/swarm.md @@ -184,4 +184,5 @@ You can configure more finely the way to analyze the image of your service throu | `diun.max_tags` | `0` | Maximum number of tags to watch if `diun.watch_repo` enabled. `0` means all of them | | `diun.include_tags` | | Semicolon separated list of regular expressions to include tags. Can be useful if you enable `diun.watch_repo` | | `diun.exclude_tags` | | Semicolon separated list of regular expressions to exclude tags. Can be useful if you enable `diun.watch_repo` | +| `diun.hub_link` | _automatic_ | Set registry hub link for this image | | `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) | diff --git a/internal/app/job.go b/internal/app/job.go index 3d6d9584..54bb84ff 100644 --- a/internal/app/job.go +++ b/internal/app/job.go @@ -32,6 +32,7 @@ func (di *Diun) createJob(job model.Job) { return } job.RegImage = prvImage + job.HubLinkOverride = job.Image.HubLink // First check? job.FirstCheck, err = di.db.First(job.RegImage) @@ -201,6 +202,9 @@ func (di *Diun) runJob(job model.Job) (entry model.NotifEntry) { if v, ok := entry.Manifest.Labels["org.opencontainers.image.url"]; ok { entry.Image.HubLink = v } + if job.HubLinkOverride != "" { + entry.Image.HubLink = job.HubLinkOverride + } if len(dbManifest.Name) == 0 { entry.Status = model.ImageStatusNew diff --git a/internal/model/image.go b/internal/model/image.go index 1baec90f..7863a2d3 100644 --- a/internal/model/image.go +++ b/internal/model/image.go @@ -14,6 +14,7 @@ type Image struct { IncludeTags []string `yaml:"include_tags,omitempty" json:",omitempty"` ExcludeTags []string `yaml:"exclude_tags,omitempty" json:",omitempty"` HubTpl string `yaml:"hub_tpl,omitempty" json:",omitempty"` + HubLink string `yaml:"hub_link,omitempty" json:",omitempty"` } // ImagePlatform holds image platform configuration diff --git a/internal/model/job.go b/internal/model/job.go index 32610d66..dfdfbdb3 100644 --- a/internal/model/job.go +++ b/internal/model/job.go @@ -6,9 +6,10 @@ import ( // Job holds job configuration type Job struct { - Provider string - Image Image - RegImage registry.Image - Registry *registry.Client - FirstCheck bool + Provider string + Image Image + RegImage registry.Image + Registry *registry.Client + FirstCheck bool + HubLinkOverride string } diff --git a/internal/provider/common.go b/internal/provider/common.go index dbd33b14..fdfeab3c 100644 --- a/internal/provider/common.go +++ b/internal/provider/common.go @@ -72,6 +72,8 @@ func ValidateImage(image string, labels map[string]string, watchByDef bool) (img img.ExcludeTags = strings.Split(value, ";") case "diun.hub_tpl": img.HubTpl = value + case "diun.hub_link": + img.HubLink = value case "diun.platform": platform, err := platforms.Parse(value) if err != nil { diff --git a/internal/provider/file/file_test.go b/internal/provider/file/file_test.go index 5e31ef43..f2eddc05 100644 --- a/internal/provider/file/file_test.go +++ b/internal/provider/file/file_test.go @@ -137,6 +137,17 @@ var ( }, }, } + lscrFile = []model.Job{ + { + Provider: "file", + Image: model.Image{ + Name: "lscr.io/linuxserver/heimdall", + NotifyOn: model.NotifyOnDefaults, + SortTags: registry.SortTagReverse, + HubLink: "https://fleet.linuxserver.io/image?name=linuxserver/heimdall", + }, + }, + } ) func TestListJobFilename(t *testing.T) { @@ -150,5 +161,5 @@ func TestListJobDirectory(t *testing.T) { fc := file.New(&model.PrdFile{ Directory: "./fixtures", }) - assert.Equal(t, append(append(bintrayFile, dockerhubFile...), quayFile...), fc.ListJob()) + assert.Equal(t, append(append(bintrayFile, dockerhubFile...), append(lscrFile, quayFile...)...), fc.ListJob()) } diff --git a/internal/provider/file/fixtures/lscr.yml b/internal/provider/file/fixtures/lscr.yml new file mode 100644 index 00000000..b65d174d --- /dev/null +++ b/internal/provider/file/fixtures/lscr.yml @@ -0,0 +1,2 @@ +- name: lscr.io/linuxserver/heimdall + hub_link: https://fleet.linuxserver.io/image?name=linuxserver/heimdall