Commit 6cb213a6 authored by Petar Prokic's avatar Petar Prokic

Update group cluster API

- Expose fields managed and enabled where missing
- Update tests to use the new fields
- Update handbook to mention the fields
parent c4914b37
This diff is collapsed.
...@@ -75,10 +75,12 @@ module API ...@@ -75,10 +75,12 @@ module API
params do params do
requires :cluster_id, type: Integer, desc: 'The cluster ID' requires :cluster_id, type: Integer, desc: 'The cluster ID'
optional :name, type: String, desc: 'Cluster name' optional :name, type: String, desc: 'Cluster name'
optional :enabled, type: Boolean, default: true, desc: 'Determines if cluster is active or not, defaults to true'
optional :domain, type: String, desc: 'Cluster base domain' optional :domain, type: String, desc: 'Cluster base domain'
optional :environment_scope, type: String, desc: 'The associated environment to the cluster' optional :environment_scope, type: String, desc: 'The associated environment to the cluster'
optional :namespace_per_environment, default: true, type: Boolean, desc: 'Deploy each environment to a separate Kubernetes namespace' optional :namespace_per_environment, default: true, type: Boolean, desc: 'Deploy each environment to a separate Kubernetes namespace'
optional :management_project_id, type: Integer, desc: 'The ID of the management project' optional :management_project_id, type: Integer, desc: 'The ID of the management project'
optional :managed, type: Boolean, default: true, desc: 'Determines if GitLab will manage namespaces and service accounts for this cluster, defaults to true'
optional :platform_kubernetes_attributes, type: Hash, desc: %q(Platform Kubernetes data) do 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 :api_url, type: String, desc: 'URL to access the Kubernetes API'
optional :token, type: String, desc: 'Token to authenticate against Kubernetes' optional :token, type: String, desc: 'Token to authenticate against Kubernetes'
......
...@@ -89,6 +89,8 @@ RSpec.describe API::GroupClusters do ...@@ -89,6 +89,8 @@ RSpec.describe API::GroupClusters do
expect(json_response['environment_scope']).to eq('*') expect(json_response['environment_scope']).to eq('*')
expect(json_response['cluster_type']).to eq('group_type') expect(json_response['cluster_type']).to eq('group_type')
expect(json_response['domain']).to eq('example.com') expect(json_response['domain']).to eq('example.com')
expect(json_response['enabled']).to be_truthy
expect(json_response['managed']).to be_truthy
end end
it 'returns group information' do it 'returns group information' do
...@@ -172,6 +174,7 @@ RSpec.describe API::GroupClusters do ...@@ -172,6 +174,7 @@ RSpec.describe API::GroupClusters do
name: 'test-cluster', name: 'test-cluster',
domain: 'domain.example.com', domain: 'domain.example.com',
managed: false, managed: false,
enabled: false,
namespace_per_environment: false, namespace_per_environment: false,
platform_kubernetes_attributes: platform_kubernetes_attributes, platform_kubernetes_attributes: platform_kubernetes_attributes,
management_project_id: management_project_id management_project_id: management_project_id
...@@ -206,6 +209,7 @@ RSpec.describe API::GroupClusters do ...@@ -206,6 +209,7 @@ RSpec.describe API::GroupClusters do
expect(cluster_result.name).to eq('test-cluster') expect(cluster_result.name).to eq('test-cluster')
expect(cluster_result.domain).to eq('domain.example.com') expect(cluster_result.domain).to eq('domain.example.com')
expect(cluster_result.managed).to be_falsy expect(cluster_result.managed).to be_falsy
expect(cluster_result.enabled).to be_falsy
expect(cluster_result.management_project_id).to eq management_project_id expect(cluster_result.management_project_id).to eq management_project_id
expect(cluster_result.namespace_per_environment).to eq(false) expect(cluster_result.namespace_per_environment).to eq(false)
expect(platform_kubernetes.rbac?).to be_truthy expect(platform_kubernetes.rbac?).to be_truthy
...@@ -342,7 +346,9 @@ RSpec.describe API::GroupClusters do ...@@ -342,7 +346,9 @@ RSpec.describe API::GroupClusters do
{ {
domain: domain, domain: domain,
platform_kubernetes_attributes: platform_kubernetes_attributes, platform_kubernetes_attributes: platform_kubernetes_attributes,
management_project_id: management_project_id management_project_id: management_project_id,
managed: false,
enabled: false
} }
end end
...@@ -381,6 +387,8 @@ RSpec.describe API::GroupClusters do ...@@ -381,6 +387,8 @@ RSpec.describe API::GroupClusters do
it 'updates cluster attributes' do it 'updates cluster attributes' do
expect(cluster.domain).to eq('new-domain.com') expect(cluster.domain).to eq('new-domain.com')
expect(cluster.management_project).to eq(management_project) expect(cluster.management_project).to eq(management_project)
expect(cluster.managed).to be_falsy
expect(cluster.enabled).to be_falsy
end end
end end
...@@ -394,6 +402,8 @@ RSpec.describe API::GroupClusters do ...@@ -394,6 +402,8 @@ RSpec.describe API::GroupClusters do
it 'does not update cluster attributes' do it 'does not update cluster attributes' do
expect(cluster.domain).to eq('old-domain.com') expect(cluster.domain).to eq('old-domain.com')
expect(cluster.management_project).to be_nil expect(cluster.management_project).to be_nil
expect(cluster.managed).to be_truthy
expect(cluster.enabled).to be_truthy
end end
it 'returns validation errors' do it 'returns validation errors' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment