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
- [x] Broadcast Messages
- [x] Commits
- [x] Custom Attributes
- [x] Content Registry
- [x] Container Registry
- [x] Deploy Keys
- [x] Deployments
- [x] Environments
......
......@@ -332,7 +332,7 @@ type Client struct {
Projects *ProjectsService
ProtectedBranches *ProtectedBranchesService
ProtectedTags *ProtectedTagsService
Registry *RegistryService
ContainerRegistry *ContainerRegistryService
Repositories *RepositoriesService
RepositoryFiles *RepositoryFilesService
Runners *RunnersService
......@@ -475,7 +475,7 @@ func newClient(httpClient *http.Client) *Client {
c.Projects = &ProjectsService{client: c}
c.ProtectedBranches = &ProtectedBranchesService{client: c}
c.ProtectedTags = &ProtectedTagsService{client: c}
c.Registry = &RegistryService{client: c}
c.ContainerRegistry = &ContainerRegistryService{client: c}
c.Repositories = &RepositoriesService{client: c}
c.RepositoryFiles = &RepositoryFilesService{client: c}
c.Runners = &RunnersService{client: c}
......
......@@ -6,11 +6,11 @@ import (
"time"
)
// RegistryService handles communication with the container registry related methods
// of the GitLab API.
// ContainerRegistryService handles communication with the container registry
// related methods of the GitLab API.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/container_registry.html
type RegistryService struct {
type ContainerRegistryService struct {
client *Client
}
......@@ -22,7 +22,7 @@ type RegistryRepository struct {
Name string `json:"name"`
Path string `json:"path"`
Location string `json:"location"`
CreatedAt *time.Time `json:"created_at,omitempty"`
CreatedAt *time.Time `json:"created_at"`
}
func (s RegistryRepository) String() string {
......@@ -36,19 +36,6 @@ 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"`
Path string `json:"path"`
Location string `json:"location"`
Revision string `json:"revision"`
ShortRevision string `json:"short_revision"`
Digest string `json:"digest"`
......@@ -56,7 +43,7 @@ type RegistryRepositoryTagDetail struct {
TotalSize int `json:"total_size"`
}
func (s RegistryRepositoryTagDetail) String() string {
func (s RegistryRepositoryTag) String() string {
return Stringify(s)
}
......@@ -66,27 +53,11 @@ func (s RegistryRepositoryTagDetail) String() string {
// https://docs.gitlab.com/ee/api/container_registry.html#list-registry-repositories
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
//
// GitLab API docs:
// 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)
if err != nil {
return nil, nil, err
......@@ -103,7 +74,6 @@ func (s *RegistryService) ListRegistryRepositories(pid interface{}, opt *ListReg
if err != nil {
return nil, resp, err
}
return repos, resp, err
}
......@@ -111,33 +81,42 @@ func (s *RegistryService) ListRegistryRepositories(pid interface{}, opt *ListReg
//
// GitLab API docs:
// 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)
if err != nil {
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)
if err != nil {
return nil, err
}
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.
//
// GitLab API docs:
// 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)
if err != nil {
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)
if err != nil {
......@@ -149,7 +128,6 @@ func (s *RegistryService) ListRegistryRepositoryTags(pid interface{}, repository
if err != nil {
return nil, resp, err
}
return repos, resp, err
}
......@@ -157,64 +135,83 @@ func (s *RegistryService) ListRegistryRepositoryTags(pid interface{}, repository
//
// GitLab API docs:
// 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)
if err != nil {
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)
if err != nil {
return nil, nil, err
}
var tagDetail *RegistryRepositoryTagDetail
resp, err := s.client.Do(req, &tagDetail)
td := new(RegistryRepositoryTag)
resp, err := s.client.Do(req, &td)
if err != nil {
return nil, resp, err
}
return tagDetail, resp, err
return td, resp, err
}
// DeleteRegistryRepositoryTag deletes a registry repository tag.
//
// GitLab API docs:
// 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)
if err != nil {
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)
if err != nil {
return nil, err
}
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
func (s *RegistryService) BulkDeleteRegistryRepositoryTags(pid interface{}, repositoryID int, opt *BulkDeleteRegistryRepositoryTagsOptions, options ...OptionFunc) (*Response, error) {
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:
// https://docs.gitlab.com/ee/api/container_registry.html#delete-repository-tags-in-bulk
func (s *ContainerRegistryService) DeleteRegistryRepositoryTags(pid interface{}, repository int, opt *DeleteRegistryRepositoryTagsOptions, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
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)
if err != nil {
return nil, err
}
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