Commit 685ea799 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'add_feature_flag_for_serverless_removal' into 'master'

Put deprecated serverless features behind feature flag

See merge request gitlab-org/gitlab!81493
parents cee763c2 ef88f5c5
......@@ -3,6 +3,7 @@
module Projects
module Serverless
class FunctionsController < Projects::ApplicationController
before_action :ensure_feature_enabled!
before_action :authorize_read_cluster!
feature_category :not_owned
......@@ -69,6 +70,10 @@ module Projects
def serialize_function(function)
Projects::Serverless::ServiceSerializer.new(current_user: @current_user, project: project).represent(function)
end
def ensure_feature_enabled!
render_404 unless Feature.enabled?(:deprecated_serverless, project, default_enabled: :yaml, type: :ops)
end
end
end
end
---
name: deprecated_serverless
introduced_by_url: 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81493'
rollout_issue_url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/353901'
milestone: '14.9'
type: ops
group: 'group::configure'
default_enabled: true
......@@ -64,7 +64,7 @@ module Sidebars
end
def serverless_menu_item
unless can?(context.current_user, :read_cluster, context.project)
unless Feature.enabled?(:deprecated_serverless, context.project, default_enabled: :yaml, type: :ops) && can?(context.current_user, :read_cluster, context.project)
return ::Sidebars::NilMenuItem.new(item_id: :serverless)
end
......
......@@ -39,9 +39,24 @@ RSpec.describe Projects::Serverless::FunctionsController do
project_id: project.to_param)
end
shared_examples_for 'behind :deprecated_serverless feature flag' do
before do
stub_feature_flags(deprecated_serverless: false)
end
it 'returns 404' do
action
expect(response).to have_gitlab_http_status(:not_found)
end
end
describe 'GET #index' do
let(:expected_json) { { 'knative_installed' => knative_state, 'functions' => functions } }
it_behaves_like 'behind :deprecated_serverless feature flag' do
let(:action) { get :index, params: params({ format: :json }) }
end
context 'when cache is being read' do
let(:knative_state) { 'checking' }
let(:functions) { [] }
......@@ -147,6 +162,10 @@ RSpec.describe Projects::Serverless::FunctionsController do
end
describe 'GET #show' do
it_behaves_like 'behind :deprecated_serverless feature flag' do
let(:action) { get :show, params: params({ format: :json, environment_id: "*", id: "foo" }) }
end
context 'with function that does not exist' do
it 'returns 404' do
get :show, params: params({ format: :json, environment_id: "*", id: "foo" })
......@@ -239,6 +258,10 @@ RSpec.describe Projects::Serverless::FunctionsController do
end
describe 'GET #metrics' do
it_behaves_like 'behind :deprecated_serverless feature flag' do
let(:action) { get :metrics, params: params({ format: :json, environment_id: "*", id: "foo" }) }
end
context 'invalid data' do
it 'has a bad function name' do
get :metrics, params: params({ format: :json, environment_id: "*", id: "foo" })
......
......@@ -92,6 +92,14 @@ RSpec.describe Sidebars::Projects::Menus::InfrastructureMenu do
let(:item_id) { :serverless }
it_behaves_like 'access rights checks'
context 'when feature :deprecated_serverless is disabled' do
before do
stub_feature_flags(deprecated_serverless: false)
end
it { is_expected.to be_nil }
end
end
describe 'Terraform' 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