Allow customizing the hub link (#648)

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2022-07-17 15:56:06 +02:00
committed by GitHub
parent 190578f612
commit c89e54888e
11 changed files with 32 additions and 6 deletions

View File

@@ -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`) |

View File

@@ -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`) |

View File

@@ -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 |

View File

@@ -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`) |

View File

@@ -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`) |

View File

@@ -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

View File

@@ -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

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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())
}

View File

@@ -0,0 +1,2 @@
- name: lscr.io/linuxserver/heimdall
hub_link: https://fleet.linuxserver.io/image?name=linuxserver/heimdall