Skip to content
Snippets Groups Projects
Commit 7eb1c3bc authored by Shinya Maeda's avatar Shinya Maeda
Browse files

Merge branch 'move-ff-license-to-core' into 'master'

Remove Feature Flag License Check RUN AS-IF-FOSS

See merge request gitlab-org/gitlab!42023
parents 982533e4 2aebdde6
Branches 301218-docs-aqualls-fix-core
No related tags found
No related merge requests found
Showing
with 72 additions and 87 deletions
Loading
Loading
@@ -325,6 +325,12 @@ class ProjectPolicy < BasePolicy
enable :destroy_design
enable :read_terraform_state
enable :read_pod_logs
enable :read_feature_flag
enable :create_feature_flag
enable :update_feature_flag
enable :destroy_feature_flag
enable :admin_feature_flag
enable :admin_feature_flags_user_lists
end
 
rule { can?(:developer_access) & user_confirmed? }.policy do
Loading
Loading
@@ -371,6 +377,7 @@ class ProjectPolicy < BasePolicy
enable :read_freeze_period
enable :update_freeze_period
enable :destroy_freeze_period
enable :admin_feature_flags_client
end
 
rule { public_project & metrics_dashboard_allowed }.policy do
Loading
Loading
@@ -447,6 +454,8 @@ class ProjectPolicy < BasePolicy
prevent :read_pipeline
prevent :read_pipeline_schedule
prevent(*create_read_update_admin_destroy(:release))
prevent(*create_read_update_admin_destroy(:feature_flag))
prevent(:admin_feature_flags_user_lists)
end
 
rule { container_registry_disabled }.policy do
Loading
Loading
Loading
Loading
@@ -4,9 +4,10 @@ group: Progressive Delivery
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
---
 
# Feature Flags **(PREMIUM)**
# Feature Flags **(STARTER)**
 
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/7433) in GitLab 11.4.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/7433) in GitLab 11.4.
> - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/212318) to [GitLab Starter](https://about.gitlab.com/pricing/) in 13.4
 
With Feature Flags, you can deploy your application's new features to production in smaller batches.
You can toggle a feature on and off to subsets of users, helping you achieve Continuous Delivery.
Loading
Loading
@@ -349,7 +350,7 @@ else
end
```
 
## Feature Flag Related Issues
## Feature Flag Related Issues **(PREMIUM)**
 
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36617) in GitLab 13.2.
> - It's deployed behind a feature flag, enabled by default.
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ module Projects
include IssuableLinks
 
before_action :ensure_feature_enabled!
before_action :authorize_admin_feature_flag!
before_action :authorize_admin_feature_flags_issue_links!
 
private
 
Loading
Loading
Loading
Loading
@@ -30,7 +30,7 @@ module EE
 
override :project_autocomplete
def project_autocomplete
return super unless @project && @project.feature_available?(:feature_flags)
return super unless @project && @project.feature_available?(:repository)
 
super + [{ category: "In this project", label: _("Feature Flags"), url: project_feature_flags_path(@project) }]
end
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ module FeatureFlagsHelper
end
 
def feature_flag_issues_links_endpoint(project, feature_flag, user)
return '' unless Feature.enabled?(:feature_flags_issue_links, project, default_enabled: true) && can?(user, :read_issue_link, project)
return '' unless Feature.enabled?(:feature_flags_issue_links, project, default_enabled: true) && can?(user, :admin_feature_flags_issue_links, project)
 
project_feature_flag_issues_path(project, feature_flag)
end
Loading
Loading
Loading
Loading
@@ -72,7 +72,7 @@ class License < ApplicationRecord
epics
extended_audit_events
external_authorization_service_api_management
feature_flags
feature_flags_related_issues
file_locks
geo
generic_alert_fingerprinting
Loading
Loading
Loading
Loading
@@ -120,11 +120,6 @@ module EE
@subject.feature_available?(:threat_monitoring)
end
 
with_scope :subject
condition(:feature_flags_disabled) do
!@subject.feature_available?(:feature_flags)
end
with_scope :subject
condition(:code_review_analytics_enabled) do
@subject.feature_available?(:code_review_analytics, @user)
Loading
Loading
@@ -142,6 +137,11 @@ module EE
@subject.root_namespace.over_storage_limit?
end
 
with_scope :subject
condition(:feature_flags_related_issues_disabled) do
!@subject.feature_available?(:feature_flags_related_issues)
end
rule { visual_review_bot }.policy do
prevent :read_note
enable :create_note
Loading
Loading
@@ -154,6 +154,10 @@ module EE
prevent :push_code
end
 
rule { feature_flags_related_issues_disabled | repository_disabled }.policy do
prevent :admin_feature_flags_issue_links
end
rule { ~group_timelogs_available }.prevent :read_group_timelogs
 
rule { can?(:guest_access) & iterations_available }.enable :read_iteration
Loading
Loading
@@ -171,13 +175,8 @@ module EE
enable :create_vulnerability_feedback
enable :destroy_vulnerability_feedback
enable :update_vulnerability_feedback
enable :read_feature_flag
enable :create_feature_flag
enable :update_feature_flag
enable :destroy_feature_flag
enable :admin_feature_flag
enable :admin_feature_flags_user_lists
enable :read_ci_minutes_quota
enable :admin_feature_flags_issue_links
end
 
rule { can?(:developer_access) & iterations_available }.policy do
Loading
Loading
@@ -223,16 +222,10 @@ module EE
 
rule { deploy_board_disabled & ~is_development }.prevent :read_deploy_board
 
rule { feature_flags_disabled | repository_disabled }.policy do
prevent(*create_read_update_admin_destroy(:feature_flag))
prevent(:admin_feature_flags_user_lists)
end
rule { can?(:maintainer_access) }.policy do
enable :push_code_to_protected_branches
enable :admin_path_locks
enable :update_approvers
enable :admin_feature_flags_client
enable :modify_approvers_rules
enable :modify_auto_fix_setting
enable :modify_merge_request_author_setting
Loading
Loading
---
title: Remove license check for feature flags
merge_request: 42023
author:
type: changed
---
name: feature_flags_related_issues
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42023
rollout_issue_url:
group: group::progressive delivery
type: licensed
default_enabled: true
Loading
Loading
@@ -66,7 +66,7 @@ module API
end
 
def authorize_feature_flags_feature!
forbidden! unless project.feature_available?(:feature_flags)
forbidden! unless project.feature_available?(:repository)
end
 
def feature_flags
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ RSpec.describe Projects::FeatureFlagIssuesController do
end
 
before do
stub_licensed_features(feature_flags: true)
stub_licensed_features(feature_flags_related_issues: true)
end
 
describe 'GET #index' do
Loading
Loading
@@ -172,19 +172,9 @@ RSpec.describe Projects::FeatureFlagIssuesController do
expect(response).to have_gitlab_http_status(:not_found)
end
 
it 'returns not found when related issues feature is unavailable' do
stub_licensed_features(blocked_issues: false)
feature_flag, _issue = setup
sign_in(developer)
get_request(project, feature_flag)
expect(response).to have_gitlab_http_status(:not_found)
end
context 'when feature flags are unlicensed' do
context 'when feature flag related issues feature is unlicensed' do
before do
stub_licensed_features(feature_flags: false)
stub_licensed_features(feature_flags_related_issues: false)
end
 
it 'does not return linked issues' do
Loading
Loading
@@ -332,23 +322,12 @@ RSpec.describe Projects::FeatureFlagIssuesController do
expect(::FeatureFlagIssue.count).to eq(0)
end
 
it 'does not create a link when the related issues feature is unavailable' do
stub_licensed_features(blocked_issues: false)
feature_flag, issue = setup
sign_in(developer)
post_request(project, feature_flag, issue)
expect(response).to have_gitlab_http_status(:not_found)
expect(::FeatureFlagIssue.count).to eq(0)
end
context 'when feature flags are unlicensed' do
context 'when feature flag related issues feature is unlicensed' do
before do
stub_licensed_features(feature_flags: false)
stub_licensed_features(feature_flags_related_issues: false)
end
 
it 'does not create a link between the feature flag and the issue when feature flags are unlicensed' do
it 'does not create a link between the feature flag and the issue' do
feature_flag, issue = setup
sign_in(developer)
 
Loading
Loading
@@ -400,15 +379,20 @@ RSpec.describe Projects::FeatureFlagIssuesController do
expect(feature_flag.reload.issues).to eq([issue])
end
 
it 'does not unlink the issue when the related issues feature is unavailable' do
stub_licensed_features(blocked_issues: false)
feature_flag, issue, link = setup
sign_in(developer)
context 'when feature flag related issues feature is unlicensed' do
before do
stub_licensed_features(feature_flags_related_issues: false)
end
 
delete_request(project, feature_flag, link)
it 'does not unlink the issue' do
feature_flag, issue, link = setup
sign_in(developer)
 
expect(response).to have_gitlab_http_status(:not_found)
expect(feature_flag.reload.issues).to eq([issue])
delete_request(project, feature_flag, link)
expect(response).to have_gitlab_http_status(:not_found)
expect(feature_flag.reload.issues).to eq([issue])
end
end
end
end
Loading
Loading
@@ -16,7 +16,6 @@ RSpec.describe Projects::FeatureFlagsClientsController do
end
 
before do
stub_licensed_features(feature_flags: true)
sign_in(user)
end
 
Loading
Loading
Loading
Loading
@@ -10,7 +10,6 @@ RSpec.describe Projects::FeatureFlagsController do
let_it_be(:developer) { create(:user) }
let_it_be(:reporter) { create(:user) }
let(:user) { developer }
let(:feature_enabled) { true }
 
before_all do
project.add_developer(developer)
Loading
Loading
@@ -19,7 +18,6 @@ RSpec.describe Projects::FeatureFlagsController do
 
before do
sign_in(user)
stub_licensed_features(feature_flags: feature_enabled)
end
 
describe 'GET index' do
Loading
Loading
@@ -41,14 +39,6 @@ RSpec.describe Projects::FeatureFlagsController do
end
end
 
context 'when feature is not available' do
let(:feature_enabled) { false }
it 'responds with not found' do
is_expected.to have_gitlab_http_status(:not_found)
end
end
context 'when the user is a reporter' do
let(:user) { reporter }
 
Loading
Loading
Loading
Loading
@@ -12,10 +12,6 @@ RSpec.describe Projects::FeatureFlagsUserListsController do
project.add_developer(developer)
end
 
before do
stub_licensed_features(feature_flags: true)
end
def request_params(extra_params = {})
{ namespace_id: project.namespace, project_id: project }.merge(extra_params)
end
Loading
Loading
@@ -44,15 +40,6 @@ RSpec.describe Projects::FeatureFlagsUserListsController do
expect(response).to have_gitlab_http_status(:not_found)
end
 
it 'returns not found when feature flags are not licensed' do
stub_licensed_features(feature_flags: false)
sign_in(developer)
get(:new, params: request_params)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'renders the new page for a developer' do
sign_in(developer)
 
Loading
Loading
Loading
Loading
@@ -8,7 +8,6 @@ RSpec.describe 'User deletes feature flag user list', :js do
 
before do
project.add_developer(developer)
stub_licensed_features(feature_flags: true)
sign_in(developer)
end
 
Loading
Loading
Loading
Loading
@@ -8,7 +8,6 @@ RSpec.describe 'User edits feature flag user list', :js do
 
before do
project.add_developer(developer)
stub_licensed_features(feature_flags: true)
sign_in(developer)
end
 
Loading
Loading
Loading
Loading
@@ -8,7 +8,6 @@ RSpec.describe 'User sees feature flag user list details', :js do
 
before do
project.add_developer(developer)
stub_licensed_features(feature_flags: true)
sign_in(developer)
end
 
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ RSpec.describe 'Feature flag issue links', :js do
end
 
before do
stub_licensed_features(feature_flags: true)
stub_licensed_features(feature_flags_related_issues: true)
sign_in(developer)
end
 
Loading
Loading
@@ -72,6 +72,19 @@ RSpec.describe 'Feature flag issue links', :js do
expect(page).not_to have_selector '#related-issues'
end
end
context 'when the feature is unlicensed' do
before do
stub_licensed_features(feature_flags_related_issues: false)
end
it 'does not show the related issues widget' do
visit(edit_project_feature_flag_path(project, feature_flag))
expect(page).to have_text 'Strategies'
expect(page).not_to have_selector '#related-issues'
end
end
end
 
describe 'unlinking a feature flag from an issue' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment