Commit 2f4643f6 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'move-cluster-management-project-out-of-alpha' into 'master'

Move cluster management projects out of alpha [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!62255
parents 8221fc2e d4189c08
...@@ -4,9 +4,8 @@ module Clusters ...@@ -4,9 +4,8 @@ module Clusters
class ClustersHierarchy class ClustersHierarchy
DEPTH_COLUMN = :depth DEPTH_COLUMN = :depth
def initialize(clusterable, include_management_project: true) def initialize(clusterable)
@clusterable = clusterable @clusterable = clusterable
@include_management_project = include_management_project
end end
# Returns clusters in order from deepest to highest group # Returns clusters in order from deepest to highest group
...@@ -25,7 +24,7 @@ module Clusters ...@@ -25,7 +24,7 @@ module Clusters
private private
attr_reader :clusterable, :include_management_project attr_reader :clusterable
def recursive_cte def recursive_cte
cte = Gitlab::SQL::RecursiveCTE.new(:clusters_cte) cte = Gitlab::SQL::RecursiveCTE.new(:clusters_cte)
...@@ -39,7 +38,7 @@ module Clusters ...@@ -39,7 +38,7 @@ module Clusters
raise ArgumentError, "unknown type for #{clusterable}" raise ArgumentError, "unknown type for #{clusterable}"
end end
if clusterable.is_a?(::Project) && include_management_project if clusterable.is_a?(::Project)
cte << same_namespace_management_clusters_query cte << same_namespace_management_clusters_query
end end
...@@ -71,7 +70,7 @@ module Clusters ...@@ -71,7 +70,7 @@ module Clusters
# Only applicable if the clusterable is a project (most especially when # Only applicable if the clusterable is a project (most especially when
# requesting project.deployment_platform). # requesting project.deployment_platform).
def depth_order_clause def depth_order_clause
return { DEPTH_COLUMN => :asc } unless clusterable.is_a?(::Project) && include_management_project return { DEPTH_COLUMN => :asc } unless clusterable.is_a?(::Project)
order = <<~SQL order = <<~SQL
(CASE clusters.management_project_id (CASE clusters.management_project_id
......
...@@ -10,10 +10,6 @@ module DeploymentPlatform ...@@ -10,10 +10,6 @@ module DeploymentPlatform
private private
def cluster_management_project_enabled?
Feature.enabled?(:cluster_management_project, self, default_enabled: true)
end
def find_deployment_platform(environment) def find_deployment_platform(environment)
find_platform_kubernetes_with_cte(environment) || find_platform_kubernetes_with_cte(environment) ||
find_instance_cluster_platform_kubernetes(environment: environment) find_instance_cluster_platform_kubernetes(environment: environment)
...@@ -21,13 +17,13 @@ module DeploymentPlatform ...@@ -21,13 +17,13 @@ module DeploymentPlatform
def find_platform_kubernetes_with_cte(environment) def find_platform_kubernetes_with_cte(environment)
if environment if environment
::Clusters::ClustersHierarchy.new(self, include_management_project: cluster_management_project_enabled?) ::Clusters::ClustersHierarchy.new(self)
.base_and_ancestors .base_and_ancestors
.enabled .enabled
.on_environment(environment, relevant_only: true) .on_environment(environment, relevant_only: true)
.first&.platform_kubernetes .first&.platform_kubernetes
else else
Clusters::ClustersHierarchy.new(self, include_management_project: cluster_management_project_enabled?).base_and_ancestors Clusters::ClustersHierarchy.new(self).base_and_ancestors
.enabled.default_environment .enabled.default_environment
.first&.platform_kubernetes .first&.platform_kubernetes
end end
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
.sub-section.form-group .sub-section.form-group
= form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster, html: { class: 'cluster_management_form' } do |field| = form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster, html: { class: 'cluster_management_form' } do |field|
%h4 %h4
= s_('ClusterIntegration|Cluster management project (alpha)') = s_('ClusterIntegration|Cluster management project')
%p %p
= project_select_tag('cluster[management_project_id]', class: 'hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit', = project_select_tag('cluster[management_project_id]', class: 'hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit',
......
---
name: cluster_management_project
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/17866
rollout_issue_url:
milestone: '12.4'
type: development
group: group::configure
default_enabled: true
...@@ -6,10 +6,6 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -6,10 +6,6 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Cluster management project **(FREE)** # Cluster management project **(FREE)**
WARNING:
This is an _alpha_ feature, and it is subject to change at any time without
prior notice.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/32810) in GitLab 12.5 > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/32810) in GitLab 12.5
A project can be designated as the management project for a cluster. A project can be designated as the management project for a cluster.
......
...@@ -7075,7 +7075,7 @@ msgstr "" ...@@ -7075,7 +7075,7 @@ msgstr ""
msgid "ClusterIntegration|Cluster Region" msgid "ClusterIntegration|Cluster Region"
msgstr "" msgstr ""
msgid "ClusterIntegration|Cluster management project (alpha)" msgid "ClusterIntegration|Cluster management project"
msgstr "" msgstr ""
msgid "ClusterIntegration|Cluster name is required." msgid "ClusterIntegration|Cluster name is required."
......
...@@ -4,8 +4,8 @@ require 'spec_helper' ...@@ -4,8 +4,8 @@ require 'spec_helper'
RSpec.describe Clusters::ClustersHierarchy do RSpec.describe Clusters::ClustersHierarchy do
describe '#base_and_ancestors' do describe '#base_and_ancestors' do
def base_and_ancestors(clusterable, include_management_project: true) def base_and_ancestors(clusterable)
described_class.new(clusterable, include_management_project: include_management_project).base_and_ancestors described_class.new(clusterable).base_and_ancestors
end end
context 'project in nested group with clusters at every level' do context 'project in nested group with clusters at every level' do
...@@ -101,10 +101,6 @@ RSpec.describe Clusters::ClustersHierarchy do ...@@ -101,10 +101,6 @@ RSpec.describe Clusters::ClustersHierarchy do
expect(base_and_ancestors(management_project)).to eq([ancestor, child]) expect(base_and_ancestors(management_project)).to eq([ancestor, child])
end end
it 'returns clusters for management_project' do
expect(base_and_ancestors(management_project, include_management_project: false)).to eq([child, ancestor])
end
it 'returns clusters for project' do it 'returns clusters for project' do
expect(base_and_ancestors(project)).to eq([child, ancestor]) expect(base_and_ancestors(project)).to eq([child, ancestor])
end end
......
...@@ -254,20 +254,8 @@ RSpec.describe DeploymentPlatform do ...@@ -254,20 +254,8 @@ RSpec.describe DeploymentPlatform do
create(:cluster, :provided_by_user, projects: [another_project], management_project: project) create(:cluster, :provided_by_user, projects: [another_project], management_project: project)
end end
context 'cluster_management_project feature is enabled' do it 'returns the cluster with management project' do
it 'returns the cluster with management project' do is_expected.to eq(cluster_with_management_project.platform_kubernetes)
is_expected.to eq(cluster_with_management_project.platform_kubernetes)
end
end
context 'cluster_management_project feature is disabled' do
before do
stub_feature_flags(cluster_management_project: false)
end
it 'returns nothing' do
is_expected.to be_nil
end
end end
end end
...@@ -311,20 +299,8 @@ RSpec.describe DeploymentPlatform do ...@@ -311,20 +299,8 @@ RSpec.describe DeploymentPlatform do
create(:cluster, :provided_by_user, projects: [another_project], management_project: project) create(:cluster, :provided_by_user, projects: [another_project], management_project: project)
end end
context 'cluster_management_project feature is enabled' do it 'returns the cluster with management project' do
it 'returns the cluster with management project' do is_expected.to eq(cluster_with_management_project.platform_kubernetes)
is_expected.to eq(cluster_with_management_project.platform_kubernetes)
end
end
context 'cluster_management_project feature is disabled' do
before do
stub_feature_flags(cluster_management_project: false)
end
it 'returns the group cluster' do
is_expected.to eq(group_cluster.platform_kubernetes)
end
end end
end end
......
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