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
624324b3
Commit
624324b3
authored
Feb 26, 2019
by
Ivan Etchart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for Content Registry API
parent
68c08691
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
223 additions
and
0 deletions
+223
-0
README.md
README.md
+1
-0
gitlab.go
gitlab.go
+2
-0
registry.go
registry.go
+220
-0
No files found.
README.md
View file @
624324b3
...
@@ -30,6 +30,7 @@ to add new and/or missing endpoints. Currently the following services are suppor
...
@@ -30,6 +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
]
Deploy Keys
-
[
x
]
Deploy Keys
-
[
x
]
Deployments
-
[
x
]
Deployments
-
[
x
]
Environments
-
[
x
]
Environments
...
...
gitlab.go
View file @
624324b3
...
@@ -332,6 +332,7 @@ type Client struct {
...
@@ -332,6 +332,7 @@ type Client struct {
Projects
*
ProjectsService
Projects
*
ProjectsService
ProtectedBranches
*
ProtectedBranchesService
ProtectedBranches
*
ProtectedBranchesService
ProtectedTags
*
ProtectedTagsService
ProtectedTags
*
ProtectedTagsService
Registry
*
RegistryService
Repositories
*
RepositoriesService
Repositories
*
RepositoriesService
RepositoryFiles
*
RepositoryFilesService
RepositoryFiles
*
RepositoryFilesService
Runners
*
RunnersService
Runners
*
RunnersService
...
@@ -474,6 +475,7 @@ func newClient(httpClient *http.Client) *Client {
...
@@ -474,6 +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
.
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
}
...
...
registry.go
0 → 100644
View file @
624324b3
package
gitlab
import
(
"fmt"
"net/url"
"time"
)
// RegistryService 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
{
client
*
Client
}
// RegistryRepository represents a GitLab content registry repository.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/container_registry.html
type
RegistryRepository
struct
{
ID
int
`json:"id"`
Name
string
`json:"name"`
Path
string
`json:"path"`
Location
string
`json:"location"`
CreatedAt
*
time
.
Time
`json:"created_at,omitempty"`
}
func
(
s
RegistryRepository
)
String
()
string
{
return
Stringify
(
s
)
}
// RegistryRepositoryTag represents a GitLab registry image tag.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/container_registry.html
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"`
CreatedAt
*
time
.
Time
`json:"created_at,omitempty"`
TotalSize
int
`json:"total_size"`
}
func
(
s
RegistryRepositoryTagDetail
)
String
()
string
{
return
Stringify
(
s
)
}
// ListRegistryRepositoriesOptions represents the available ListRegistryRepositories() options.
//
// GitLab API docs:
// 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
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/registry/repositories"
,
url
.
QueryEscape
(
project
))
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
var
repos
[]
*
RegistryRepository
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
repos
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
repos
,
resp
,
err
}
// DeleteRegistryRepository deletes a repository in a registry.
//
// 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
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/registry/repositories/%d"
,
url
.
QueryEscape
(
project
),
repositoryID
)
req
,
err
:=
s
.
client
.
NewRequest
(
"DELETE"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
err
}
return
s
.
client
.
Do
(
req
,
nil
)
}
// 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
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/registry/repositories/%d/tags"
,
url
.
QueryEscape
(
project
),
repositoryID
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
var
repos
[]
*
RegistryRepositoryTag
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
repos
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
repos
,
resp
,
err
}
// GetRegistryRepositoryTagDetail get details of a registry repository tag
//
// 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
)
{
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
)
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
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
tagDetail
,
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
)
{
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
)
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.
//
// 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
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/registry/repositories/%d/tags"
,
url
.
QueryEscape
(
project
),
repositoryID
)
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