Commit 564b6a24 authored by João Cunha's avatar João Cunha Committed by João Alexandre Cunha

Add FF to toggle cert-based clusters features

We're deprecating cert-based clusters and all of its related features
will be removed. So we've decided to use feature flags to hide the
features in the major milestone instead of right away removing them.
This MR introduces the first usage of this FF, but other MRs will come
to put this FF in other places.

At this time, we're hiding everything that makes use of
deployment_platform. The most impactful thing is not creating rollout
jobs anymore during Auto DevOps pipelines. So we're also adding tests
for this.
parent 36e79a9d
......@@ -3,6 +3,8 @@
module DeploymentPlatform
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def deployment_platform(environment: nil)
return if Feature.disabled?(:certificate_based_clusters, default_enabled: :yaml, type: :ops)
@deployment_platform ||= {}
@deployment_platform[environment] ||= find_deployment_platform(environment)
......
---
name: certificate_based_clusters
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81054
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/353410
milestone: '14.9'
type: ops
group: group::configure
default_enabled: true
......@@ -238,14 +238,34 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do
end
it_behaves_like 'pipeline with Kubernetes jobs'
context 'when certificate_based_clusters FF is disabled' do
before do
stub_feature_flags(certificate_based_clusters: false)
end
it 'does not include production job' do
expect(build_names).not_to include('production')
end
end
end
context 'when project has an Agent is present' do
context 'when project has an Agent' do
before do
create(:cluster_agent, project: project)
end
it_behaves_like 'pipeline with Kubernetes jobs'
context 'when certificate_based_clusters FF is disabled' do
before do
stub_feature_flags(certificate_based_clusters: false)
end
it 'includes production job' do
expect(build_names).to include('production')
end
end
end
end
......
......@@ -12,16 +12,28 @@ RSpec.describe DeploymentPlatform do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
shared_examples 'certificate_based_clusters is disabled' do
before do
stub_feature_flags(certificate_based_clusters: false)
end
it { is_expected.to be_nil }
end
shared_examples 'matching environment scope' do
it 'returns environment specific cluster' do
is_expected.to eq(cluster.platform_kubernetes)
end
it_behaves_like 'certificate_based_clusters is disabled'
end
shared_examples 'not matching environment scope' do
it 'returns default cluster' do
is_expected.to eq(default_cluster.platform_kubernetes)
end
it_behaves_like 'certificate_based_clusters is disabled'
end
context 'multiple clusters use the same management project' 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