refactor: put StripTagMeta into formatter package
Avoid circular import.
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
||||
"github.com/docker/go-units"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/schollz/progressbar/v3"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func ShortenID(str string) string {
|
||||
@ -49,3 +50,22 @@ func CreateProgressbar(length int, title string) *progressbar.ProgressBar {
|
||||
progressbar.OptionSetDescription(title),
|
||||
)
|
||||
}
|
||||
|
||||
// StripTagMeta strips front-matter image tag data that we don't need for parsing.
|
||||
func StripTagMeta(image string) string {
|
||||
originalImage := image
|
||||
|
||||
if strings.Contains(image, "docker.io") {
|
||||
image = strings.Split(image, "/")[1]
|
||||
}
|
||||
|
||||
if strings.Contains(image, "library") {
|
||||
image = strings.Split(image, "/")[1]
|
||||
}
|
||||
|
||||
if originalImage != image {
|
||||
logrus.Debugf("stripped %s to %s for parsing", originalImage, image)
|
||||
}
|
||||
|
||||
return image
|
||||
}
|
||||
|
Reference in New Issue
Block a user