Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
362f2226
Commit
362f2226
authored
Aug 24, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve by zj nice catches
parent
fb8f32a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
47 deletions
+39
-47
doc/api/pipeline_schedules.md
doc/api/pipeline_schedules.md
+21
-18
lib/api/entities.rb
lib/api/entities.rb
+1
-1
lib/api/pipeline_schedules.rb
lib/api/pipeline_schedules.rb
+13
-24
spec/requests/api/pipeline_schedules_spec.rb
spec/requests/api/pipeline_schedules_spec.rb
+4
-4
No files found.
doc/api/pipeline_schedules.md
View file @
362f2226
...
@@ -290,12 +290,12 @@ Create a new variable of a pipeline schedule.
...
@@ -290,12 +290,12 @@ Create a new variable of a pipeline schedule.
POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables
POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables
```
```
| Attribute
| Type
| required | Description |
| Attribute
| Type
| required | Description |
|---------------
|
---------|----------|--------------------------|
|---------------
---------|-------
---------|----------|--------------------------|
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`pipeline_schedule_id`
| integer
| yes | The pipeline schedule id |
|
`pipeline_schedule_id`
| integer
| yes | The pipeline schedule id |
|
`key`
| string
| yes | The
`key`
of a variable; must have no more than 255 characters; only
`A-Z`
,
`a-z`
,
`0-9`
, and
`_`
are allowed |
|
`key`
| string
| yes | The
`key`
of a variable; must have no more than 255 characters; only
`A-Z`
,
`a-z`
,
`0-9`
, and
`_`
are allowed |
|
`value`
| string
| yes | The
`value`
of a variable |
|
`value`
| string
| yes | The
`value`
of a variable |
```
sh
```
sh
curl
--request
POST
--header
"PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ"
--form
"key=NEW_VARIABLE"
--form
"value=new value"
"https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables"
curl
--request
POST
--header
"PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ"
--form
"key=NEW_VARIABLE"
--form
"value=new value"
"https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables"
...
@@ -316,12 +316,12 @@ Updates the variable of a pipeline schedule.
...
@@ -316,12 +316,12 @@ Updates the variable of a pipeline schedule.
PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
```
```
| Attribute
| Type
| required | Description |
| Attribute
| Type
| required | Description |
|---------------
|
---------|----------|--------------------------|
|---------------
---------|-------
---------|----------|--------------------------|
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`pipeline_schedule_id`
| integer
| yes | The pipeline schedule id |
|
`pipeline_schedule_id`
| integer
| yes | The pipeline schedule id |
|
`key`
| string
| yes | The
`key`
of a variable |
|
`key`
| string
| yes | The
`key`
of a variable |
|
`value`
| string
| yes | The
`value`
of a variable |
|
`value`
| string
| yes | The
`value`
of a variable |
```
sh
```
sh
curl
--request
PUT
--header
"PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ"
--form
"value=updated value"
"https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/NEW_VARIABLE"
curl
--request
PUT
--header
"PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ"
--form
"value=updated value"
"https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/NEW_VARIABLE"
...
@@ -342,18 +342,21 @@ Delete the variable of a pipeline schedule.
...
@@ -342,18 +342,21 @@ Delete the variable of a pipeline schedule.
DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
```
```
| Attribute
| Type
| required | Description |
| Attribute
| Type
| required | Description |
|----------------
|
---------|----------|--------------------------|
|----------------
--------|-------
---------|----------|--------------------------|
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`pipeline_schedule_id`
| integer
| yes | The pipeline schedule id |
|
`pipeline_schedule_id`
| integer
| yes | The pipeline schedule id |
|
`key`
| string
| yes | The
`key`
of a variable |
|
`key`
| string
| yes | The
`key`
of a variable |
```
sh
```
sh
curl
--request
DELETE
--header
"PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ"
"https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/NEW_VARIABLE"
curl
--request
DELETE
--header
"PRIVATE-TOKEN: k5ESFgWY2Qf5xEvDcFxZ"
"https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/NEW_VARIABLE"
```
```
```
json
```
json
//
Empty
{
"key"
:
"NEW_VARIABLE"
,
"value"
:
"updated value"
}
```
```
[
ce-34518
]:
https://gitlab.com/gitlab-org/gitlab-ce/issues/34518
[
ce-34518
]:
https://gitlab.com/gitlab-org/gitlab-ce/issues/34518
\ No newline at end of file
lib/api/entities.rb
View file @
362f2226
...
@@ -819,7 +819,7 @@ module API
...
@@ -819,7 +819,7 @@ module API
class
Variable
<
Grape
::
Entity
class
Variable
<
Grape
::
Entity
expose
:key
,
:value
expose
:key
,
:value
expose
:protected?
,
as: :protected
,
if:
->
(
entity
,
options
)
{
entity
.
respond_to?
(
:protected?
)
}
expose
:protected?
,
as: :protected
,
if:
->
(
entity
,
_
)
{
entity
.
respond_to?
(
:protected?
)
}
end
end
class
Pipeline
<
PipelineBasic
class
Pipeline
<
PipelineBasic
...
...
lib/api/pipeline_schedules.rb
View file @
362f2226
...
@@ -33,8 +33,6 @@ module API
...
@@ -33,8 +33,6 @@ module API
get
':id/pipeline_schedules/:pipeline_schedule_id'
do
get
':id/pipeline_schedules/:pipeline_schedule_id'
do
authorize!
:read_pipeline_schedule
,
user_project
authorize!
:read_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
present
pipeline_schedule
,
with:
Entities
::
PipelineScheduleDetails
present
pipeline_schedule
,
with:
Entities
::
PipelineScheduleDetails
end
end
...
@@ -75,8 +73,6 @@ module API
...
@@ -75,8 +73,6 @@ module API
end
end
put
':id/pipeline_schedules/:pipeline_schedule_id'
do
put
':id/pipeline_schedules/:pipeline_schedule_id'
do
authorize!
:read_pipeline_schedule
,
user_project
authorize!
:read_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
if
pipeline_schedule
.
update
(
declared_params
(
include_missing:
false
))
if
pipeline_schedule
.
update
(
declared_params
(
include_missing:
false
))
...
@@ -94,8 +90,6 @@ module API
...
@@ -94,8 +90,6 @@ module API
end
end
post
':id/pipeline_schedules/:pipeline_schedule_id/take_ownership'
do
post
':id/pipeline_schedules/:pipeline_schedule_id/take_ownership'
do
authorize!
:read_pipeline_schedule
,
user_project
authorize!
:read_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
if
pipeline_schedule
.
own!
(
current_user
)
if
pipeline_schedule
.
own!
(
current_user
)
...
@@ -113,8 +107,6 @@ module API
...
@@ -113,8 +107,6 @@ module API
end
end
delete
':id/pipeline_schedules/:pipeline_schedule_id'
do
delete
':id/pipeline_schedules/:pipeline_schedule_id'
do
authorize!
:read_pipeline_schedule
,
user_project
authorize!
:read_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:admin_pipeline_schedule
,
pipeline_schedule
authorize!
:admin_pipeline_schedule
,
pipeline_schedule
destroy_conditionally!
(
pipeline_schedule
)
destroy_conditionally!
(
pipeline_schedule
)
...
@@ -130,8 +122,6 @@ module API
...
@@ -130,8 +122,6 @@ module API
end
end
post
':id/pipeline_schedules/:pipeline_schedule_id/variables'
do
post
':id/pipeline_schedules/:pipeline_schedule_id/variables'
do
authorize!
:read_pipeline_schedule
,
user_project
authorize!
:read_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
variable_params
=
declared_params
(
include_missing:
false
)
variable_params
=
declared_params
(
include_missing:
false
)
...
@@ -153,17 +143,12 @@ module API
...
@@ -153,17 +143,12 @@ module API
end
end
put
':id/pipeline_schedules/:pipeline_schedule_id/variables/:key'
do
put
':id/pipeline_schedules/:pipeline_schedule_id/variables/:key'
do
authorize!
:read_pipeline_schedule
,
user_project
authorize!
:read_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
variable
=
pipeline_schedule
.
variables
.
find_by
(
key:
params
[
:key
])
if
pipeline_schedule_variable
.
update
(
declared_params
(
include_missing:
false
))
not_found!
(
'Variable'
)
unless
variable
present
pipeline_schedule_variable
,
with:
Entities
::
Variable
if
variable
.
update
(
declared_params
(
include_missing:
false
))
present
variable
,
with:
Entities
::
Variable
else
else
render_validation_error!
(
variable
)
render_validation_error!
(
pipeline_schedule_
variable
)
end
end
end
end
...
@@ -176,15 +161,10 @@ module API
...
@@ -176,15 +161,10 @@ module API
end
end
delete
':id/pipeline_schedules/:pipeline_schedule_id/variables/:key'
do
delete
':id/pipeline_schedules/:pipeline_schedule_id/variables/:key'
do
authorize!
:read_pipeline_schedule
,
user_project
authorize!
:read_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:admin_pipeline_schedule
,
pipeline_schedule
authorize!
:admin_pipeline_schedule
,
pipeline_schedule
variable
=
pipeline_schedule
.
variables
.
find_by
(
key:
params
[
:key
])
not_found!
(
'Variable'
)
unless
variable
status
:accepted
status
:accepted
present
variable
.
destroy
,
with:
Entities
::
Variable
present
pipeline_schedule_
variable
.
destroy
,
with:
Entities
::
Variable
end
end
end
end
...
@@ -194,6 +174,15 @@ module API
...
@@ -194,6 +174,15 @@ module API
user_project
.
pipeline_schedules
user_project
.
pipeline_schedules
.
preload
(
:owner
,
:last_pipeline
)
.
preload
(
:owner
,
:last_pipeline
)
.
find_by
(
id:
params
.
delete
(
:pipeline_schedule_id
))
.
find_by
(
id:
params
.
delete
(
:pipeline_schedule_id
))
@pipeline_schedule
||
not_found!
(
'Pipeline Schedule'
)
end
def
pipeline_schedule_variable
@pipeline_schedule_variable
||=
pipeline_schedule
.
variables
.
find_by
(
key:
params
[
:key
])
@pipeline_schedule_variable
||
not_found!
(
'Pipeline Schedule Variable'
)
end
end
end
end
end
end
...
...
spec/requests/api/pipeline_schedules_spec.rb
View file @
362f2226
...
@@ -303,7 +303,7 @@ describe API::PipelineSchedules do
...
@@ -303,7 +303,7 @@ describe API::PipelineSchedules do
describe
'POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables'
do
describe
'POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables'
do
let
(
:params
)
{
attributes_for
(
:ci_pipeline_schedule_variable
)
}
let
(
:params
)
{
attributes_for
(
:ci_pipeline_schedule_variable
)
}
l
et
(
:pipeline_schedule
)
do
s
et
(
:pipeline_schedule
)
do
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
developer
)
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
developer
)
end
end
...
@@ -359,7 +359,7 @@ describe API::PipelineSchedules do
...
@@ -359,7 +359,7 @@ describe API::PipelineSchedules do
end
end
describe
'PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key'
do
describe
'PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key'
do
l
et
(
:pipeline_schedule
)
do
s
et
(
:pipeline_schedule
)
do
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
developer
)
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
developer
)
end
end
...
@@ -398,7 +398,7 @@ describe API::PipelineSchedules do
...
@@ -398,7 +398,7 @@ describe API::PipelineSchedules do
describe
'DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key'
do
describe
'DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key'
do
let
(
:master
)
{
create
(
:user
)
}
let
(
:master
)
{
create
(
:user
)
}
let!
(
:pipeline_schedule
)
do
set
(
:pipeline_schedule
)
do
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
developer
)
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
developer
)
end
end
...
@@ -427,7 +427,7 @@ describe API::PipelineSchedules do
...
@@ -427,7 +427,7 @@ describe API::PipelineSchedules do
end
end
end
end
context
'authenticated user with invalid permissions'
do
# TODO:
context
'authenticated user with invalid permissions'
do
let!
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
master
)
}
let!
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
project:
project
,
owner:
master
)
}
it
'does not delete pipeline_schedule_variable'
do
it
'does not delete pipeline_schedule_variable'
do
...
...
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