forked from 0xch4z/dockerhub-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tag.go
62 lines (56 loc) · 1.89 KB
/
tag.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package dockerhub
import (
"context"
"fmt"
"net/http"
"time"
)
// TagService Type
type TagService service
// Tags response
type Tags struct {
Count int `json:"count"`
Next interface{} `json:"next"`
Previous interface{} `json:"previous"`
Results []struct {
Creator int `json:"creator"`
ID int `json:"id"`
ImageID interface{} `json:"image_id"`
Images []struct {
Architecture string `json:"architecture"`
Features string `json:"features"`
Variant interface{} `json:"variant"`
Digest string `json:"digest"`
Os string `json:"os"`
OsFeatures string `json:"os_features"`
OsVersion interface{} `json:"os_version"`
Size int `json:"size"`
Status string `json:"status"`
LastPulled time.Time `json:"last_pulled"`
LastPushed time.Time `json:"last_pushed"`
} `json:"images"`
LastUpdated time.Time `json:"last_updated"`
LastUpdater int `json:"last_updater"`
LastUpdaterUsername string `json:"last_updater_username"`
Name string `json:"name"`
Repository int `json:"repository"`
FullSize int `json:"full_size"`
V2 bool `json:"v2"`
TagStatus string `json:"tag_status"`
TagLastPulled time.Time `json:"tag_last_pulled"`
TagLastPushed time.Time `json:"tag_last_pushed"`
} `json:"results"`
}
// GetTags of the repo
func (s *TagService) GetTags(ctx context.Context, namespace, repo string, page int) (*Tags, error) {
slug := fmt.Sprintf("/repositories/%v/%v/tags/?page_size=%d&ordering=last_updated", namespace, repo, page)
req, err := s.client.NewRequest(http.MethodGet, slug, nil)
if err != nil {
return nil, err
}
res := &Tags{}
if _, err := s.client.Do(ctx, req, res); err != nil {
return nil, err
}
return res, nil
}