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
77d5de5b
Commit
77d5de5b
authored
Jul 03, 2019
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE: Add API for CRUD group clusters
This is basically a copy of the API for project clusters.
parent
78cf7132
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
136 additions
and
0 deletions
+136
-0
ee/lib/ee/api/group_clusters.rb
ee/lib/ee/api/group_clusters.rb
+21
-0
ee/spec/requests/api/group_clusters_spec.rb
ee/spec/requests/api/group_clusters_spec.rb
+113
-0
lib/api/group_clusters.rb
lib/api/group_clusters.rb
+2
-0
No files found.
ee/lib/ee/api/group_clusters.rb
0 → 100644
View file @
77d5de5b
# frozen_string_literal: true
module
EE
module
API
module
GroupClusters
extend
ActiveSupport
::
Concern
prepended
do
helpers
do
params
:create_params_ee
do
optional
:environment_scope
,
default:
'*'
,
type:
String
,
desc:
'The associated environment to the cluster'
end
params
:update_params_ee
do
optional
:environment_scope
,
type:
String
,
desc:
'The associated environment to the cluster'
end
end
end
end
end
end
ee/spec/requests/api/group_clusters_spec.rb
0 → 100644
View file @
77d5de5b
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
GroupClusters
do
include
KubernetesHelpers
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
before
do
group
.
add_maintainer
(
current_user
)
end
describe
'POST /groups/:id/clusters/user'
do
let
(
:api_url
)
{
'https://kubernetes.example.com'
}
let
(
:platform_kubernetes_attributes
)
do
{
api_url:
api_url
,
token:
'sample-token'
}
end
let
(
:cluster_params
)
do
{
name:
'test-cluster'
,
environment_scope:
'production/*'
,
platform_kubernetes_attributes:
platform_kubernetes_attributes
}
end
context
'when user sets specific environment scope'
do
it
'creates a cluster with that specific environment'
do
post
api
(
"/groups/
#{
group
.
id
}
/clusters/user"
,
current_user
),
params:
cluster_params
expect
(
json_response
[
'environment_scope'
]).
to
eq
(
'production/*'
)
end
end
context
'when does not set an specific environment scope'
do
let
(
:cluster_params
)
do
{
name:
'test-cluster'
,
platform_kubernetes_attributes:
platform_kubernetes_attributes
}
end
it
'sets default environment'
do
post
api
(
"/groups/
#{
group
.
id
}
/clusters/user"
,
current_user
),
params:
cluster_params
expect
(
json_response
[
'environment_scope'
]).
to
eq
(
'*'
)
end
end
context
'when license has multiple clusters feature'
do
before
do
stub_licensed_features
(
multiple_clusters:
true
)
create
(
:cluster
,
:provided_by_gcp
,
:group
,
groups:
[
group
])
post
api
(
"/groups/
#{
group
.
id
}
/clusters/user"
,
current_user
),
params:
cluster_params
end
it
'responds with 201'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
end
it
'allows multiple clusters to be associated to group'
do
expect
(
group
.
reload
.
clusters
.
count
).
to
eq
(
2
)
end
end
end
describe
'PUT /groups/:id/clusters/:cluster_id'
do
let
(
:api_url
)
{
'https://kubernetes.example.com'
}
let
(
:update_params
)
do
{
environment_scope:
'test/*'
}
end
before
do
put
api
(
"/groups/
#{
group
.
id
}
/clusters/
#{
cluster
.
id
}
"
,
current_user
),
params:
update_params
cluster
.
reload
end
context
'With a GCP cluster'
do
let
(
:cluster
)
do
create
(
:cluster
,
:group
,
:provided_by_gcp
,
groups:
[
group
])
end
it
'updates the environment scope'
do
expect
(
cluster
.
environment_scope
).
to
eq
(
'test/*'
)
end
end
context
'With an user cluster'
do
let
(
:cluster
)
do
create
(
:cluster
,
:group
,
:provided_by_user
,
groups:
[
group
])
end
it
'updates the environment scope'
do
expect
(
cluster
.
environment_scope
).
to
eq
(
'test/*'
)
end
end
end
end
lib/api/group_clusters.rb
View file @
77d5de5b
...
@@ -16,6 +16,8 @@ module API
...
@@ -16,6 +16,8 @@ module API
end
end
end
end
prepend
EE
::
API
::
GroupClusters
# rubocop: disable Cop/InjectEnterpriseEditionModule
params
do
params
do
requires
:id
,
type:
String
,
desc:
'The ID of the group'
requires
:id
,
type:
String
,
desc:
'The ID of the group'
end
end
...
...
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