mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-24 06:28:13 +01:00
Add Hublink for GitHub Container Registry (#211)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -119,6 +119,10 @@ func (i Image) hubLink() (string, error) {
|
|||||||
return fmt.Sprintf("https://github.com/%s/packages", filepath.ToSlash(filepath.Dir(i.Path))), nil
|
return fmt.Sprintf("https://github.com/%s/packages", filepath.ToSlash(filepath.Dir(i.Path))), nil
|
||||||
case "gcr.io":
|
case "gcr.io":
|
||||||
return fmt.Sprintf("https://%s/%s", i.Domain, i.Path), nil
|
return fmt.Sprintf("https://%s/%s", i.Domain, i.Path), nil
|
||||||
|
case "ghcr.io":
|
||||||
|
ref := strings.Split(i.Path, "/")
|
||||||
|
ghUser, ghPackage := ref[0], ref[1]
|
||||||
|
return fmt.Sprintf("https://github.com/users/%s/packages/container/package/%s", ghUser, ghPackage), nil
|
||||||
case "quay.io":
|
case "quay.io":
|
||||||
return fmt.Sprintf("https://quay.io/repository/%s", i.Path), nil
|
return fmt.Sprintf("https://quay.io/repository/%s", i.Path), nil
|
||||||
case "registry.access.redhat.com":
|
case "registry.access.redhat.com":
|
||||||
|
|||||||
@@ -101,6 +101,28 @@ func TestParseImage(t *testing.T) {
|
|||||||
Tag: "latest",
|
Tag: "latest",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "ghcr ddns-route53",
|
||||||
|
parseOpts: registry.ParseImageOptions{
|
||||||
|
Name: "ghcr.io/crazy-max/ddns-route53",
|
||||||
|
},
|
||||||
|
expected: registry.Image{
|
||||||
|
Domain: "ghcr.io",
|
||||||
|
Path: "crazy-max/ddns-route53",
|
||||||
|
Tag: "latest",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "ghcr radarr",
|
||||||
|
parseOpts: registry.ParseImageOptions{
|
||||||
|
Name: "ghcr.io/linuxserver/radarr",
|
||||||
|
},
|
||||||
|
expected: registry.Image{
|
||||||
|
Domain: "ghcr.io",
|
||||||
|
Path: "linuxserver/radarr",
|
||||||
|
Tag: "latest",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range testCases {
|
for _, tt := range testCases {
|
||||||
@@ -185,6 +207,20 @@ func TestHubLink(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: "https://quay.io/repository/coreos/hyperkube",
|
expected: "https://quay.io/repository/coreos/hyperkube",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "ghcr ddns-route53",
|
||||||
|
parseOpts: registry.ParseImageOptions{
|
||||||
|
Name: "ghcr.io/crazy-max/ddns-route53",
|
||||||
|
},
|
||||||
|
expected: "https://github.com/users/crazy-max/packages/container/package/ddns-route53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "ghcr radarr",
|
||||||
|
parseOpts: registry.ParseImageOptions{
|
||||||
|
Name: "ghcr.io/linuxserver/radarr",
|
||||||
|
},
|
||||||
|
expected: "https://github.com/users/linuxserver/packages/container/package/radarr",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: "redhat etcd",
|
desc: "redhat etcd",
|
||||||
parseOpts: registry.ParseImageOptions{
|
parseOpts: registry.ParseImageOptions{
|
||||||
|
|||||||
Reference in New Issue
Block a user