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
fd955263
Commit
fd955263
authored
Jan 08, 2019
by
achiu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shorten comments, update variable names, update ProtectRepositoryTagsOptions.Name to a pointer
parent
483af39f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
18 deletions
+19
-18
protected_tags.go
protected_tags.go
+17
-16
protected_tags_test.go
protected_tags_test.go
+2
-2
No files found.
protected_tags.go
View file @
fd955263
...
@@ -5,7 +5,7 @@ import (
...
@@ -5,7 +5,7 @@ import (
"net/url"
"net/url"
)
)
// ProtectedTagsService handles
communication with
the protected tag methods of the GitLab API.
// ProtectedTagsService handles the protected tag methods of the GitLab API.
//
//
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_tags.html
// https://docs.gitlab.com/ee/api/protected_tags.html
...
@@ -16,7 +16,7 @@ type ProtectedTagsService struct {
...
@@ -16,7 +16,7 @@ type ProtectedTagsService struct {
// TagAccessDescription reperesents the access decription for a protected tag.
// TagAccessDescription reperesents the access decription for a protected tag.
//
//
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_tags.html
#list-protected-tags
// https://docs.gitlab.com/ee/api/protected_tags.html
type
TagAccessDescription
struct
{
type
TagAccessDescription
struct
{
AccessLevel
AccessLevelValue
`json:"access_level"`
AccessLevel
AccessLevelValue
`json:"access_level"`
AccessLevelDescription
string
`json:"access_level_description"`
AccessLevelDescription
string
`json:"access_level_description"`
...
@@ -25,7 +25,7 @@ type TagAccessDescription struct {
...
@@ -25,7 +25,7 @@ type TagAccessDescription struct {
// ProtectedTag represents a protected tag.
// ProtectedTag represents a protected tag.
//
//
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_tags.html
#list-protected-tags
// https://docs.gitlab.com/ee/api/protected_tags.html
type
ProtectedTag
struct
{
type
ProtectedTag
struct
{
Name
string
`json:"name"`
Name
string
`json:"name"`
CreateAccessLevels
[]
*
TagAccessDescription
`json:"create_access_levels"`
CreateAccessLevels
[]
*
TagAccessDescription
`json:"create_access_levels"`
...
@@ -53,13 +53,13 @@ func (s *ProtectedTagsService) ListProtectedTags(pid interface{}, opt *ListProte
...
@@ -53,13 +53,13 @@ func (s *ProtectedTagsService) ListProtectedTags(pid interface{}, opt *ListProte
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
var
p
[]
*
ProtectedTag
var
p
ts
[]
*
ProtectedTag
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
p
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
p
ts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
resp
,
err
return
nil
,
resp
,
err
}
}
return
p
,
resp
,
err
return
p
ts
,
resp
,
err
}
}
// GetProtectedTag returns a single protected tag or wildcard protected tag.
// GetProtectedTag returns a single protected tag or wildcard protected tag.
...
@@ -78,25 +78,26 @@ func (s *ProtectedTagsService) GetProtectedTag(pid interface{}, tag string, opti
...
@@ -78,25 +78,26 @@ func (s *ProtectedTagsService) GetProtectedTag(pid interface{}, tag string, opti
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
p
:=
new
(
ProtectedTag
)
p
t
:=
new
(
ProtectedTag
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
p
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
p
t
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
resp
,
err
return
nil
,
resp
,
err
}
}
return
p
,
resp
,
err
return
p
t
,
resp
,
err
}
}
// ProtectRepositoryTagsOptions represents available ProtectRepositoryTags() options.
// ProtectRepositoryTagsOptions represents available ProtectRepositoryTags()
// options.
//
//
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_tags.html#protect-repository-tags
// https://docs.gitlab.com/ee/api/protected_tags.html#protect-repository-tags
type
ProtectRepositoryTagsOptions
struct
{
type
ProtectRepositoryTagsOptions
struct
{
Name
string
`url:"name,omitempty" json:"name,omitempty
"`
Name
*
string
`url:"name" json:"name
"`
CreateAccessLevel
*
AccessLevelValue
`url:"create_access_level,omitempty" json:"create_access_level,omitempty"`
CreateAccessLevel
*
AccessLevelValue
`url:"create_access_level,omitempty" json:"create_access_level,omitempty"`
}
}
// ProtectRepositoryTags protects a single
repository tag or several project repository tags using a wildcard protecte
d tag.
// ProtectRepositoryTags protects a single
tag or a wildcar
d tag.
//
//
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_tags.html#protect-repository-tags
// https://docs.gitlab.com/ee/api/protected_tags.html#protect-repository-tags
...
@@ -112,16 +113,16 @@ func (s *ProtectedTagsService) ProtectRepositoryTags(pid interface{}, opt *Prote
...
@@ -112,16 +113,16 @@ func (s *ProtectedTagsService) ProtectRepositoryTags(pid interface{}, opt *Prote
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
p
:=
new
(
ProtectedTag
)
p
t
:=
new
(
ProtectedTag
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
p
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
p
t
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
resp
,
err
return
nil
,
resp
,
err
}
}
return
p
,
resp
,
err
return
p
t
,
resp
,
err
}
}
// UnprotectRepositoryTags unprotects the given
protected tag or wildcard protecte
d tag.
// UnprotectRepositoryTags unprotects the given
tag or wildcar
d tag.
//
//
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_tags.html#unprotect-repository-tags
// https://docs.gitlab.com/ee/api/protected_tags.html#unprotect-repository-tags
...
...
protected_tags_test.go
View file @
fd955263
...
@@ -125,7 +125,7 @@ func TestProtectRepositoryTags(t *testing.T) {
...
@@ -125,7 +125,7 @@ func TestProtectRepositoryTags(t *testing.T) {
},
},
}
}
opt
:=
&
ProtectRepositoryTagsOptions
{
Name
:
"my-awesome-tag"
,
CreateAccessLevel
:
AccessLevel
(
30
)}
opt
:=
&
ProtectRepositoryTagsOptions
{
Name
:
String
(
"my-awesome-tag"
)
,
CreateAccessLevel
:
AccessLevel
(
30
)}
tag
,
_
,
err
:=
client
.
ProtectedTags
.
ProtectRepositoryTags
(
1
,
opt
)
tag
,
_
,
err
:=
client
.
ProtectedTags
.
ProtectRepositoryTags
(
1
,
opt
)
assert
.
NoError
(
t
,
err
,
"failed to get response"
)
assert
.
NoError
(
t
,
err
,
"failed to get response"
)
...
@@ -142,7 +142,7 @@ func TestProtectRepositoryTags_WithServerError(t *testing.T) {
...
@@ -142,7 +142,7 @@ func TestProtectRepositoryTags_WithServerError(t *testing.T) {
fmt
.
Fprint
(
w
,
`{"message":"some error"}`
)
fmt
.
Fprint
(
w
,
`{"message":"some error"}`
)
})
})
opt
:=
&
ProtectRepositoryTagsOptions
{
Name
:
"my-awesome-tag"
,
CreateAccessLevel
:
AccessLevel
(
30
)}
opt
:=
&
ProtectRepositoryTagsOptions
{
Name
:
String
(
"my-awesome-tag"
)
,
CreateAccessLevel
:
AccessLevel
(
30
)}
tag
,
resp
,
err
:=
client
.
ProtectedTags
.
ProtectRepositoryTags
(
1
,
opt
)
tag
,
resp
,
err
:=
client
.
ProtectedTags
.
ProtectRepositoryTags
(
1
,
opt
)
assert
.
Nil
(
t
,
tag
)
assert
.
Nil
(
t
,
tag
)
...
...
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