fix empty homepage name, incorrect image parsing, refactor

This commit is contained in:
yusing
2025-02-24 08:42:10 +08:00
parent bda547198e
commit 1d16d514c7
5 changed files with 27 additions and 37 deletions

View File

@@ -7,17 +7,9 @@ import (
"github.com/yusing/go-proxy/internal/utils/strutils"
)
type (
containerHelper struct {
*container.Summary
image *ContainerImage
}
ContainerImage struct {
Author string
Name string
Tag string
}
)
type containerHelper struct {
*container.Summary
}
// getDeleteLabel gets the value of a label and then deletes it from the container.
// If the label does not exist, an empty string is returned.
@@ -45,11 +37,10 @@ func (c containerHelper) parseImage() *ContainerImage {
slashSep := strutils.SplitRune(colonSep[0], '/')
im := new(ContainerImage)
if len(slashSep) > 1 {
im.Author = slashSep[len(slashSep)-1]
im.Name = strings.Join(slashSep[:len(slashSep)-1], "/")
im.Author = strings.Join(slashSep[:len(slashSep)-1], "/")
im.Name = slashSep[len(slashSep)-1]
} else {
im.Author = "library"
im.Name = colonSep[0]
im.Name = slashSep[0]
}
if len(colonSep) > 1 {
im.Tag = colonSep[1]
@@ -75,10 +66,3 @@ func (c containerHelper) getPrivatePortMapping() PortMapping {
}
return res
}
func (c containerHelper) IsBlacklisted() bool {
if c.image == nil {
c.image = c.parseImage()
}
return c.image.IsBlacklisted()
}