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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
d857ec57
Commit
d857ec57
authored
Oct 11, 2019
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API to update management_project_id
For project and group cluster
parent
94c58f73
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
2 deletions
+49
-2
changelogs/unreleased/cluster_management_projects_updating.yml
...elogs/unreleased/cluster_management_projects_updating.yml
+5
-0
doc/api/group_clusters.md
doc/api/group_clusters.md
+1
-0
doc/api/project_clusters.md
doc/api/project_clusters.md
+1
-0
lib/api/group_clusters.rb
lib/api/group_clusters.rb
+1
-0
lib/api/project_clusters.rb
lib/api/project_clusters.rb
+1
-0
spec/requests/api/group_clusters_spec.rb
spec/requests/api/group_clusters_spec.rb
+20
-1
spec/requests/api/project_clusters_spec.rb
spec/requests/api/project_clusters_spec.rb
+20
-1
No files found.
changelogs/unreleased/cluster_management_projects_updating.yml
0 → 100644
View file @
d857ec57
---
title
:
Adds ability to set management project for cluster via API
merge_request
:
18429
author
:
type
:
added
doc/api/group_clusters.md
View file @
d857ec57
...
...
@@ -135,6 +135,7 @@ Parameters:
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the group
](
README.md#namespaced-path-encoding
)
|
|
`name`
| String | yes | The name of the cluster |
|
`domain`
| String | no | The
[
base domain
](
../user/group/clusters/index.md#base-domain
)
of the cluster |
|
`management_project_id`
| integer | no | The ID of the
[
management project
](
../user/clusters/management_project.md
)
for the cluster |
|
`enabled`
| Boolean | no | Determines if cluster is active or not, defaults to true |
|
`managed`
| Boolean | no | Determines if GitLab will manage namespaces and service accounts for this cluster, defaults to true |
|
`platform_kubernetes_attributes[api_url]`
| String | yes | The URL to access the Kubernetes API |
...
...
doc/api/project_clusters.md
View file @
d857ec57
...
...
@@ -253,6 +253,7 @@ Parameters:
|
`cluster_id`
| integer | yes | The ID of the cluster |
|
`name`
| String | no | The name of the cluster |
|
`domain`
| String | no | The
[
base domain
](
../user/project/clusters/index.md#base-domain
)
of the cluster |
|
`management_project_id`
| integer | no | The ID of the
[
management project
](
../user/clusters/management_project.md
)
for the cluster |
|
`platform_kubernetes_attributes[api_url]`
| String | no | The URL to access the Kubernetes API |
|
`platform_kubernetes_attributes[token]`
| String | no | The token to authenticate against Kubernetes |
|
`platform_kubernetes_attributes[ca_cert]`
| String | no | TLS certificate (needed if API is using a self-signed TLS certificate |
...
...
lib/api/group_clusters.rb
View file @
d857ec57
...
...
@@ -84,6 +84,7 @@ module API
requires
:cluster_id
,
type:
Integer
,
desc:
'The cluster ID'
optional
:name
,
type:
String
,
desc:
'Cluster name'
optional
:domain
,
type:
String
,
desc:
'Cluster base domain'
optional
:management_project_id
,
type:
Integer
,
desc:
'The ID of the management project'
optional
:platform_kubernetes_attributes
,
type:
Hash
,
desc:
%q(Platform Kubernetes data)
do
optional
:api_url
,
type:
String
,
desc:
'URL to access the Kubernetes API'
optional
:token
,
type:
String
,
desc:
'Token to authenticate against Kubernetes'
...
...
lib/api/project_clusters.rb
View file @
d857ec57
...
...
@@ -88,6 +88,7 @@ module API
requires
:cluster_id
,
type:
Integer
,
desc:
'The cluster ID'
optional
:name
,
type:
String
,
desc:
'Cluster name'
optional
:domain
,
type:
String
,
desc:
'Cluster base domain'
optional
:management_project_id
,
type:
Integer
,
desc:
'The ID of the management project'
optional
:platform_kubernetes_attributes
,
type:
Hash
,
desc:
%q(Platform Kubernetes data)
do
optional
:api_url
,
type:
String
,
desc:
'URL to access the Kubernetes API'
optional
:token
,
type:
String
,
desc:
'Token to authenticate against Kubernetes'
...
...
spec/requests/api/group_clusters_spec.rb
View file @
d857ec57
...
...
@@ -286,12 +286,15 @@ describe API::GroupClusters do
let
(
:update_params
)
do
{
domain:
domain
,
platform_kubernetes_attributes:
platform_kubernetes_attributes
platform_kubernetes_attributes:
platform_kubernetes_attributes
,
management_project_id:
management_project_id
}
end
let
(
:domain
)
{
'new-domain.com'
}
let
(
:platform_kubernetes_attributes
)
{
{}
}
let
(
:management_project
)
{
create
(
:project
)
}
let
(
:management_project_id
)
{
management_project
.
id
}
let
(
:cluster
)
do
create
(
:cluster
,
:group
,
:provided_by_gcp
,
...
...
@@ -308,6 +311,8 @@ describe API::GroupClusters do
context
'authorized user'
do
before
do
management_project
.
add_maintainer
(
current_user
)
put
api
(
"/groups/
#{
group
.
id
}
/clusters/
#{
cluster
.
id
}
"
,
current_user
),
params:
update_params
cluster
.
reload
...
...
@@ -320,6 +325,7 @@ describe API::GroupClusters do
it
'updates cluster attributes'
do
expect
(
cluster
.
domain
).
to
eq
(
'new-domain.com'
)
expect
(
cluster
.
management_project
).
to
eq
(
management_project
)
end
end
...
...
@@ -332,6 +338,7 @@ describe API::GroupClusters do
it
'does not update cluster attributes'
do
expect
(
cluster
.
domain
).
to
eq
(
'old-domain.com'
)
expect
(
cluster
.
management_project
).
to
be_nil
end
it
'returns validation errors'
do
...
...
@@ -339,6 +346,18 @@ describe API::GroupClusters do
end
end
context
'current user does not have access to management_project_id'
do
let
(
:management_project_id
)
{
create
(
:project
).
id
}
it
'responds with 400'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
it
'returns validation errors'
do
expect
(
json_response
[
'message'
][
'management_project_id'
].
first
).
to
match
(
'don\'t have permission'
)
end
end
context
'with a GCP cluster'
do
context
'when user tries to change GCP specific fields'
do
let
(
:platform_kubernetes_attributes
)
do
...
...
spec/requests/api/project_clusters_spec.rb
View file @
d857ec57
...
...
@@ -281,11 +281,14 @@ describe API::ProjectClusters do
let
(
:api_url
)
{
'https://kubernetes.example.com'
}
let
(
:namespace
)
{
'new-namespace'
}
let
(
:platform_kubernetes_attributes
)
{
{
namespace:
namespace
}
}
let
(
:management_project
)
{
create
(
:project
)
}
let
(
:management_project_id
)
{
management_project
.
id
}
let
(
:update_params
)
do
{
domain:
'new-domain.com'
,
platform_kubernetes_attributes:
platform_kubernetes_attributes
platform_kubernetes_attributes:
platform_kubernetes_attributes
,
management_project_id:
management_project_id
}
end
...
...
@@ -310,6 +313,8 @@ describe API::ProjectClusters do
context
'authorized user'
do
before
do
management_project
.
add_maintainer
(
current_user
)
put
api
(
"/projects/
#{
project
.
id
}
/clusters/
#{
cluster
.
id
}
"
,
current_user
),
params:
update_params
cluster
.
reload
...
...
@@ -323,6 +328,7 @@ describe API::ProjectClusters do
it
'updates cluster attributes'
do
expect
(
cluster
.
domain
).
to
eq
(
'new-domain.com'
)
expect
(
cluster
.
platform_kubernetes
.
namespace
).
to
eq
(
'new-namespace'
)
expect
(
cluster
.
management_project
).
to
eq
(
management_project
)
end
end
...
...
@@ -336,6 +342,7 @@ describe API::ProjectClusters do
it
'does not update cluster attributes'
do
expect
(
cluster
.
domain
).
not_to
eq
(
'new_domain.com'
)
expect
(
cluster
.
platform_kubernetes
.
namespace
).
not_to
eq
(
'invalid_namespace'
)
expect
(
cluster
.
management_project
).
not_to
eq
(
management_project
)
end
it
'returns validation errors'
do
...
...
@@ -343,6 +350,18 @@ describe API::ProjectClusters do
end
end
context
'current user does not have access to management_project_id'
do
let
(
:management_project_id
)
{
create
(
:project
).
id
}
it
'responds with 400'
do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
it
'returns validation errors'
do
expect
(
json_response
[
'message'
][
'management_project_id'
].
first
).
to
match
(
'don\'t have permission'
)
end
end
context
'with a GCP cluster'
do
context
'when user tries to change GCP specific fields'
do
let
(
:platform_kubernetes_attributes
)
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