-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepository.go
39 lines (33 loc) · 976 Bytes
/
repository.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
package harbor
import (
"encoding/json"
"fmt"
"github.com/dukhyungkim/harbor-client/model"
)
func (c *Client) ListRepositories(projectName string, params *model.ListRepositoriesParams) ([]*model.Repository, error) {
if params == nil {
params = model.NewListRepositoriesParams()
}
url := fmt.Sprintf(urlListRepositories, projectName) + params.ToParamString()
data, err := c.getJSON(url, true)
if err != nil {
return nil, err
}
var repositories []*model.Repository
if err := json.Unmarshal(data, &repositories); err != nil {
return nil, err
}
return repositories, nil
}
func (c *Client) GetRepository(projectName string, repositoryName string) (*model.Repository, error) {
url := fmt.Sprintf(urlGetRepository, projectName, repositoryName)
data, err := c.getJSON(url, true)
if err != nil {
return nil, err
}
var repository model.Repository
if err := json.Unmarshal(data, &repository); err != nil {
return nil, err
}
return &repository, nil
}