Commit 55d15f96 authored by Ivan Etchart's avatar Ivan Etchart

Apply comments

parent 624324b3
...@@ -30,7 +30,7 @@ to add new and/or missing endpoints. Currently the following services are suppor ...@@ -30,7 +30,7 @@ to add new and/or missing endpoints. Currently the following services are suppor
- [x] Broadcast Messages - [x] Broadcast Messages
- [x] Commits - [x] Commits
- [x] Custom Attributes - [x] Custom Attributes
- [x] Content Registry - [x] Container Registry
- [x] Deploy Keys - [x] Deploy Keys
- [x] Deployments - [x] Deployments
- [x] Environments - [x] Environments
......
...@@ -332,7 +332,7 @@ type Client struct { ...@@ -332,7 +332,7 @@ type Client struct {
Projects *ProjectsService Projects *ProjectsService
ProtectedBranches *ProtectedBranchesService ProtectedBranches *ProtectedBranchesService
ProtectedTags *ProtectedTagsService ProtectedTags *ProtectedTagsService
Registry *RegistryService ContainerRegistry *ContainerRegistryService
Repositories *RepositoriesService Repositories *RepositoriesService
RepositoryFiles *RepositoryFilesService RepositoryFiles *RepositoryFilesService
Runners *RunnersService Runners *RunnersService
...@@ -475,7 +475,7 @@ func newClient(httpClient *http.Client) *Client { ...@@ -475,7 +475,7 @@ func newClient(httpClient *http.Client) *Client {
c.Projects = &ProjectsService{client: c} c.Projects = &ProjectsService{client: c}
c.ProtectedBranches = &ProtectedBranchesService{client: c} c.ProtectedBranches = &ProtectedBranchesService{client: c}
c.ProtectedTags = &ProtectedTagsService{client: c} c.ProtectedTags = &ProtectedTagsService{client: c}
c.Registry = &RegistryService{client: c} c.ContainerRegistry = &ContainerRegistryService{client: c}
c.Repositories = &RepositoriesService{client: c} c.Repositories = &RepositoriesService{client: c}
c.RepositoryFiles = &RepositoryFilesService{client: c} c.RepositoryFiles = &RepositoryFilesService{client: c}
c.Runners = &RunnersService{client: c} c.Runners = &RunnersService{client: c}
......
...@@ -6,11 +6,11 @@ import ( ...@@ -6,11 +6,11 @@ import (
"time" "time"
) )
// RegistryService handles communication with the container registry related methods // ContainerRegistryService handles communication with the container registry
// of the GitLab API. // related methods of the GitLab API.
// //
// GitLab API docs: https://docs.gitlab.com/ee/api/container_registry.html // GitLab API docs: https://docs.gitlab.com/ee/api/container_registry.html
type RegistryService struct { type ContainerRegistryService struct {
client *Client client *Client
} }
...@@ -22,7 +22,7 @@ type RegistryRepository struct { ...@@ -22,7 +22,7 @@ type RegistryRepository struct {
Name string `json:"name"` Name string `json:"name"`
Path string `json:"path"` Path string `json:"path"`
Location string `json:"location"` Location string `json:"location"`
CreatedAt *time.Time `json:"created_at,omitempty"` CreatedAt *time.Time `json:"created_at"`
} }
func (s RegistryRepository) String() string { func (s RegistryRepository) String() string {
...@@ -33,19 +33,6 @@ func (s RegistryRepository) String() string { ...@@ -33,19 +33,6 @@ func (s RegistryRepository) String() string {
// //
// GitLab API docs: https://docs.gitlab.com/ee/api/container_registry.html // GitLab API docs: https://docs.gitlab.com/ee/api/container_registry.html
type RegistryRepositoryTag struct { type RegistryRepositoryTag struct {
Name string `json:"name"`
Path string `json:"path"`
Location string `json:"location"`
}
func (s RegistryRepositoryTag) String() string {
return Stringify(s)
}
// RegistryRepositoryTagDetail represents a GitLab registry tag detail.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/container_registry.html
type RegistryRepositoryTagDetail struct {
Name string `json:"name"` Name string `json:"name"`
Path string `json:"path"` Path string `json:"path"`
Location string `json:"location"` Location string `json:"location"`
...@@ -56,7 +43,7 @@ type RegistryRepositoryTagDetail struct { ...@@ -56,7 +43,7 @@ type RegistryRepositoryTagDetail struct {
TotalSize int `json:"total_size"` TotalSize int `json:"total_size"`
} }
func (s RegistryRepositoryTagDetail) String() string { func (s RegistryRepositoryTag) String() string {
return Stringify(s) return Stringify(s)
} }
...@@ -66,27 +53,11 @@ func (s RegistryRepositoryTagDetail) String() string { ...@@ -66,27 +53,11 @@ func (s RegistryRepositoryTagDetail) String() string {
// https://docs.gitlab.com/ee/api/container_registry.html#list-registry-repositories // https://docs.gitlab.com/ee/api/container_registry.html#list-registry-repositories
type ListRegistryRepositoriesOptions ListOptions type ListRegistryRepositoriesOptions ListOptions
// ListRegistryRepositoryTagsOptions represents the available ListRegistryRepositoryTags() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#list-repository-tags
type ListRegistryRepositoryTagsOptions ListOptions
// BulkDeleteRegistryRepositoryTagsOptions represents the available BulkDeleteRegistryRepositoryTags() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#delete-repository-tags-in-bulk
type BulkDeleteRegistryRepositoryTagsOptions struct {
NameRegexp *string `url:"name_regex,omitempty" json:"name_regex,omitempty"`
KeepN *int `url:"keep_n,omitempty" json:"keep_n,omitempty"`
OlderThan *string `url:"older_than,omitempty" json:"older_than,omitempty"`
}
// ListRegistryRepositories gets a list of registry repositories in a projecty // ListRegistryRepositories gets a list of registry repositories in a projecty
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#list-registry-repositories // https://docs.gitlab.com/ee/api/container_registry.html#list-registry-repositories
func (s *RegistryService) ListRegistryRepositories(pid interface{}, opt *ListRegistryRepositoriesOptions, options ...OptionFunc) ([]*RegistryRepository, *Response, error) { func (s *ContainerRegistryService) ListRegistryRepositories(pid interface{}, opt *ListRegistryRepositoriesOptions, options ...OptionFunc) ([]*RegistryRepository, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
...@@ -103,7 +74,6 @@ func (s *RegistryService) ListRegistryRepositories(pid interface{}, opt *ListReg ...@@ -103,7 +74,6 @@ func (s *RegistryService) ListRegistryRepositories(pid interface{}, opt *ListReg
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
return repos, resp, err return repos, resp, err
} }
...@@ -111,33 +81,42 @@ func (s *RegistryService) ListRegistryRepositories(pid interface{}, opt *ListReg ...@@ -111,33 +81,42 @@ func (s *RegistryService) ListRegistryRepositories(pid interface{}, opt *ListReg
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#delete-registry-repository // https://docs.gitlab.com/ee/api/container_registry.html#delete-registry-repository
func (s *RegistryService) DeleteRegistryRepository(pid interface{}, repositoryID int, options ...OptionFunc) (*Response, error) { func (s *ContainerRegistryService) DeleteRegistryRepository(pid interface{}, repository int, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, err return nil, err
} }
u := fmt.Sprintf("projects/%s/registry/repositories/%d", url.QueryEscape(project), repositoryID) u := fmt.Sprintf("projects/%s/registry/repositories/%d", url.QueryEscape(project), repository)
req, err := s.client.NewRequest("DELETE", u, nil, options) req, err := s.client.NewRequest("DELETE", u, nil, options)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return s.client.Do(req, nil) return s.client.Do(req, nil)
} }
// ListRegistryRepositoryTagsOptions represents the available
// ListRegistryRepositoryTags() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#list-repository-tags
type ListRegistryRepositoryTagsOptions ListOptions
// ListRegistryRepositoryTags gets a list of tags for given registry repository. // ListRegistryRepositoryTags gets a list of tags for given registry repository.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#list-repository-tags // https://docs.gitlab.com/ee/api/container_registry.html#list-repository-tags
func (s *RegistryService) ListRegistryRepositoryTags(pid interface{}, repositoryID int, opt *ListRegistryRepositoryTagsOptions, options ...OptionFunc) ([]*RegistryRepositoryTag, *Response, error) { func (s *ContainerRegistryService) ListRegistryRepositoryTags(pid interface{}, repository int, opt *ListRegistryRepositoryTagsOptions, options ...OptionFunc) ([]*RegistryRepositoryTag, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
u := fmt.Sprintf("projects/%s/registry/repositories/%d/tags", url.QueryEscape(project), repositoryID) u := fmt.Sprintf("projects/%s/registry/repositories/%d/tags",
url.QueryEscape(project),
repository,
)
req, err := s.client.NewRequest("GET", u, opt, options) req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil { if err != nil {
...@@ -149,7 +128,6 @@ func (s *RegistryService) ListRegistryRepositoryTags(pid interface{}, repository ...@@ -149,7 +128,6 @@ func (s *RegistryService) ListRegistryRepositoryTags(pid interface{}, repository
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
return repos, resp, err return repos, resp, err
} }
...@@ -157,64 +135,83 @@ func (s *RegistryService) ListRegistryRepositoryTags(pid interface{}, repository ...@@ -157,64 +135,83 @@ func (s *RegistryService) ListRegistryRepositoryTags(pid interface{}, repository
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#get-details-of-a-repository-tag // https://docs.gitlab.com/ee/api/container_registry.html#get-details-of-a-repository-tag
func (s *RegistryService) GetRegistryRepositoryTagDetail(pid interface{}, repositoryID int, tagName string, options ...OptionFunc) (*RegistryRepositoryTagDetail, *Response, error) { func (s *ContainerRegistryService) GetRegistryRepositoryTagDetail(pid interface{}, repository int, tagName string, options ...OptionFunc) (*RegistryRepositoryTag, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
u := fmt.Sprintf("projects/%s/registry/repositories/%d/tags/%s", url.QueryEscape(project), repositoryID, tagName) u := fmt.Sprintf("projects/%s/registry/repositories/%d/tags/%s",
url.QueryEscape(project),
repository,
tagName,
)
req, err := s.client.NewRequest("GET", u, nil, options) req, err := s.client.NewRequest("GET", u, nil, options)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
var tagDetail *RegistryRepositoryTagDetail td := new(RegistryRepositoryTag)
resp, err := s.client.Do(req, &tagDetail) resp, err := s.client.Do(req, &td)
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
return td, resp, err
return tagDetail, resp, err
} }
// DeleteRegistryRepositoryTag deletes a registry repository tag. // DeleteRegistryRepositoryTag deletes a registry repository tag.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#delete-a-repository-tag // https://docs.gitlab.com/ee/api/container_registry.html#delete-a-repository-tag
func (s *RegistryService) DeleteRegistryRepositoryTag(pid interface{}, repositoryID int, tagName string, options ...OptionFunc) (*Response, error) { func (s *ContainerRegistryService) DeleteRegistryRepositoryTag(pid interface{}, repository int, tagName string, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, err return nil, err
} }
u := fmt.Sprintf("projects/%s/registry/repositories/%d/tags/%s", url.QueryEscape(project), repositoryID, tagName) u := fmt.Sprintf("projects/%s/registry/repositories/%d/tags/%s",
url.QueryEscape(project),
repository,
tagName,
)
req, err := s.client.NewRequest("DELETE", u, nil, options) req, err := s.client.NewRequest("DELETE", u, nil, options)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return s.client.Do(req, nil) return s.client.Do(req, nil)
} }
// BulkDeleteRegistryRepositoryTags deletes repository tags in bulk based on given criteria. // DeleteRegistryRepositoryTagsOptions represents the available
// DeleteRegistryRepositoryTags() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#delete-repository-tags-in-bulk
type DeleteRegistryRepositoryTagsOptions struct {
NameRegexp *string `url:"name_regex,omitempty" json:"name_regex,omitempty"`
KeepN *int `url:"keep_n,omitempty" json:"keep_n,omitempty"`
OlderThan *string `url:"older_than,omitempty" json:"older_than,omitempty"`
}
// DeleteRegistryRepositoryTags deletes repository tags in bulk based on given criteria.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ee/api/container_registry.html#delete-repository-tags-in-bulk // https://docs.gitlab.com/ee/api/container_registry.html#delete-repository-tags-in-bulk
func (s *RegistryService) BulkDeleteRegistryRepositoryTags(pid interface{}, repositoryID int, opt *BulkDeleteRegistryRepositoryTagsOptions, options ...OptionFunc) (*Response, error) { func (s *ContainerRegistryService) DeleteRegistryRepositoryTags(pid interface{}, repository int, opt *DeleteRegistryRepositoryTagsOptions, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, err return nil, err
} }
u := fmt.Sprintf("projects/%s/registry/repositories/%d/tags", url.QueryEscape(project), repositoryID) u := fmt.Sprintf("projects/%s/registry/repositories/%d/tags",
url.QueryEscape(project),
repository,
)
req, err := s.client.NewRequest("DELETE", u, opt, options) req, err := s.client.NewRequest("DELETE", u, opt, options)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return s.client.Do(req, nil) return s.client.Do(req, nil)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment