Skip to content
This repository was archived by the owner on Feb 24, 2024. It is now read-only.

Commit 1352845

Browse files
authored
Merge pull request #19 from kohbis/v1-api-deprecated
Docker API V1 is deprecated, use V2
2 parents 687185c + aa4e910 commit 1352845

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cmd/root.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ import (
1919
)
2020

2121
// Tags represents response of the API that gets Docker tags
22-
type Tags []struct {
23-
// Layer string `json:"layer"`
24-
Name string `json:"name"`
22+
type Tags struct {
23+
Results []struct {
24+
Name string `json:"name"`
25+
}
2526
}
2627

2728
// Status represents status in pulling image
@@ -162,7 +163,7 @@ func imagePrompt() (string, error) {
162163
}
163164

164165
func getTags(imageName string) ([]string, error) {
165-
url := fmt.Sprintf("https://registry.hub.docker.com/v1/repositories/%s/tags", imageName)
166+
url := fmt.Sprintf("https://registry.hub.docker.com/v2/repositories/%s/tags", imageName)
166167

167168
resp, err := http.Get(url)
168169
if err != nil {
@@ -179,8 +180,8 @@ func getTags(imageName string) ([]string, error) {
179180
}
180181

181182
var tagNames []string
182-
for _, tag := range *tags {
183-
tagNames = append(tagNames, tag.Name)
183+
for _, res := range tags.Results {
184+
tagNames = append(tagNames, res.Name)
184185
}
185186

186187
return tagNames, nil

0 commit comments

Comments
 (0)