mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-24 06:28:13 +01:00
Allow customizing the hub link (#648)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -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.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.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.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`) |
|
| `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) |
|
||||||
|
|||||||
@@ -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.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.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.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`) |
|
| `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) |
|
||||||
|
|||||||
@@ -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 |
|
| `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` |
|
| `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` |
|
| `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.os` | _automatic_ | Operating system to use as custom platform |
|
||||||
| `platform.arch` | _automatic_ | CPU architecture 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 |
|
| `platform.variant` | _automatic_ | Variant of the CPU to use as custom platform |
|
||||||
|
|||||||
@@ -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.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.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.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`) |
|
| `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) |
|
||||||
|
|||||||
@@ -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.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.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.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`) |
|
| `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) |
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ func (di *Diun) createJob(job model.Job) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
job.RegImage = prvImage
|
job.RegImage = prvImage
|
||||||
|
job.HubLinkOverride = job.Image.HubLink
|
||||||
|
|
||||||
// First check?
|
// First check?
|
||||||
job.FirstCheck, err = di.db.First(job.RegImage)
|
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 {
|
if v, ok := entry.Manifest.Labels["org.opencontainers.image.url"]; ok {
|
||||||
entry.Image.HubLink = v
|
entry.Image.HubLink = v
|
||||||
}
|
}
|
||||||
|
if job.HubLinkOverride != "" {
|
||||||
|
entry.Image.HubLink = job.HubLinkOverride
|
||||||
|
}
|
||||||
|
|
||||||
if len(dbManifest.Name) == 0 {
|
if len(dbManifest.Name) == 0 {
|
||||||
entry.Status = model.ImageStatusNew
|
entry.Status = model.ImageStatusNew
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type Image struct {
|
|||||||
IncludeTags []string `yaml:"include_tags,omitempty" json:",omitempty"`
|
IncludeTags []string `yaml:"include_tags,omitempty" json:",omitempty"`
|
||||||
ExcludeTags []string `yaml:"exclude_tags,omitempty" json:",omitempty"`
|
ExcludeTags []string `yaml:"exclude_tags,omitempty" json:",omitempty"`
|
||||||
HubTpl string `yaml:"hub_tpl,omitempty" json:",omitempty"`
|
HubTpl string `yaml:"hub_tpl,omitempty" json:",omitempty"`
|
||||||
|
HubLink string `yaml:"hub_link,omitempty" json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImagePlatform holds image platform configuration
|
// ImagePlatform holds image platform configuration
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import (
|
|||||||
|
|
||||||
// Job holds job configuration
|
// Job holds job configuration
|
||||||
type Job struct {
|
type Job struct {
|
||||||
Provider string
|
Provider string
|
||||||
Image Image
|
Image Image
|
||||||
RegImage registry.Image
|
RegImage registry.Image
|
||||||
Registry *registry.Client
|
Registry *registry.Client
|
||||||
FirstCheck bool
|
FirstCheck bool
|
||||||
|
HubLinkOverride string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ func ValidateImage(image string, labels map[string]string, watchByDef bool) (img
|
|||||||
img.ExcludeTags = strings.Split(value, ";")
|
img.ExcludeTags = strings.Split(value, ";")
|
||||||
case "diun.hub_tpl":
|
case "diun.hub_tpl":
|
||||||
img.HubTpl = value
|
img.HubTpl = value
|
||||||
|
case "diun.hub_link":
|
||||||
|
img.HubLink = value
|
||||||
case "diun.platform":
|
case "diun.platform":
|
||||||
platform, err := platforms.Parse(value)
|
platform, err := platforms.Parse(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -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) {
|
func TestListJobFilename(t *testing.T) {
|
||||||
@@ -150,5 +161,5 @@ func TestListJobDirectory(t *testing.T) {
|
|||||||
fc := file.New(&model.PrdFile{
|
fc := file.New(&model.PrdFile{
|
||||||
Directory: "./fixtures",
|
Directory: "./fixtures",
|
||||||
})
|
})
|
||||||
assert.Equal(t, append(append(bintrayFile, dockerhubFile...), quayFile...), fc.ListJob())
|
assert.Equal(t, append(append(bintrayFile, dockerhubFile...), append(lscrFile, quayFile...)...), fc.ListJob())
|
||||||
}
|
}
|
||||||
|
|||||||
2
internal/provider/file/fixtures/lscr.yml
Normal file
2
internal/provider/file/fixtures/lscr.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- name: lscr.io/linuxserver/heimdall
|
||||||
|
hub_link: https://fleet.linuxserver.io/image?name=linuxserver/heimdall
|
||||||
Reference in New Issue
Block a user