Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
55d15f96
Commit
55d15f96
authored
Mar 05, 2019
by
Ivan Etchart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply comments
parent
624324b3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
58 deletions
+55
-58
README.md
README.md
+1
-1
gitlab.go
gitlab.go
+2
-2
registry.go
registry.go
+52
-55
No files found.
README.md
View file @
55d15f96
...
...
@@ -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
]
Cont
ent
Registry
-
[
x
]
Cont
ainer
Registry
-
[
x
]
Deploy Keys
-
[
x
]
Deployments
-
[
x
]
Environments
...
...
gitlab.go
View file @
55d15f96
...
...
@@ -332,7 +332,7 @@ type Client struct {
Projects
*
ProjectsService
ProtectedBranches
*
ProtectedBranchesService
ProtectedTags
*
ProtectedTagsService
Registry
*
RegistryService
ContainerRegistry
*
Container
RegistryService
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
=
&
Container
RegistryService
{
client
:
c
}
c
.
Repositories
=
&
RepositoriesService
{
client
:
c
}
c
.
RepositoryFiles
=
&
RepositoryFilesService
{
client
:
c
}
c
.
Runners
=
&
RunnersService
{
client
:
c
}
...
...
registry.go
View file @
55d15f96
...
...
@@ -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
Container
RegistryService
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
RegistryRepositoryTag
Detail
)
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
*
Container
RegistryService
)
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
),
repository
ID
)
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
,
&
t
agDetail
)
td
:=
new
(
RegistryRepositoryTag
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
t
d
)
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
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment