Add Hublink for GitHub Container Registry (#211)

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2020-11-07 20:27:38 +01:00
committed by GitHub
parent a216d5308f
commit a186194793
2 changed files with 40 additions and 0 deletions

View File

@@ -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
case "gcr.io":
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":
return fmt.Sprintf("https://quay.io/repository/%s", i.Path), nil
case "registry.access.redhat.com":

View File

@@ -101,6 +101,28 @@ func TestParseImage(t *testing.T) {
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 {
@@ -185,6 +207,20 @@ func TestHubLink(t *testing.T) {
},
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",
parseOpts: registry.ParseImageOptions{