refactor: migrate JSON function to new package

We now use it to help read remote docker registries also.
This commit is contained in:
2021-08-09 16:16:33 +02:00
parent 260edad142
commit 7ad812ad98
3 changed files with 17 additions and 7 deletions

View File

@ -1,7 +1,9 @@
package client
import (
"github.com/docker/distribution/reference"
"fmt"
"coopcloud.tech/abra/web"
)
type Tag struct {
@ -13,7 +15,13 @@ type Tags []Tag
var registryURL = "https://registry.hub.docker.com/v1/repositories/%s/tags"
func ReadRegistryTags(image reference.Named, target interface{}) ([]string, error) {
// tagsUrl := fmt.Sprintf(registryURL, image.Name())
return nil, nil
func GetRegistryTags(image string) (Tags, error) {
var tags Tags
tagsUrl := fmt.Sprintf(registryURL, image)
if err := web.ReadJSON(tagsUrl, &tags); err != nil {
return tags, err
}
return tags, nil
}