Commit 2bc3005f authored by Alex Pooley's avatar Alex Pooley

Merge branch 'if-351565-configure_granting_of_os_license' into 'master'

Make granting of open-source license to public projects configurable

See merge request gitlab-org/gitlab!79855
parents 2a8dd7b5 cfdf221a
...@@ -19,6 +19,10 @@ class ProjectSetting < ApplicationRecord ...@@ -19,6 +19,10 @@ class ProjectSetting < ApplicationRecord
validates :merge_commit_template, length: { maximum: Project::MAX_COMMIT_TEMPLATE_LENGTH } validates :merge_commit_template, length: { maximum: Project::MAX_COMMIT_TEMPLATE_LENGTH }
validates :squash_commit_template, length: { maximum: Project::MAX_COMMIT_TEMPLATE_LENGTH } validates :squash_commit_template, length: { maximum: Project::MAX_COMMIT_TEMPLATE_LENGTH }
default_value_for(:legacy_open_source_license_available) do
Feature.enabled?(:legacy_open_source_license_available, default_enabled: :yaml, type: :ops)
end
def squash_enabled_by_default? def squash_enabled_by_default?
%w[always default_on].include?(squash_option) %w[always default_on].include?(squash_option)
end end
......
---
name: legacy_open_source_license_available
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79855
rollout_issue_url:
milestone: '14.8'
type: ops
group: 'group::authentication and authorization'
default_enabled: true
# frozen_string_literal: true
class AddLegacyOpenSourceLicenseAvailableToProjectSettings < Gitlab::Database::Migration[1.0]
enable_lock_retries!
def change
add_column :project_settings, :legacy_open_source_license_available, :boolean, default: true, null: false
end
end
5642cf604a1aaf8bef6098a9918b582e0e336d79ca3b2a005cf90bb8eab0ca13
\ No newline at end of file
...@@ -18724,6 +18724,7 @@ CREATE TABLE project_settings ( ...@@ -18724,6 +18724,7 @@ CREATE TABLE project_settings (
has_shimo boolean DEFAULT false NOT NULL, has_shimo boolean DEFAULT false NOT NULL,
squash_commit_template text, squash_commit_template text,
show_diff_preview_in_email boolean DEFAULT true NOT NULL, show_diff_preview_in_email boolean DEFAULT true NOT NULL,
legacy_open_source_license_available boolean DEFAULT true NOT NULL,
CONSTRAINT check_3a03e7557a CHECK ((char_length(previous_default_branch) <= 4096)), CONSTRAINT check_3a03e7557a CHECK ((char_length(previous_default_branch) <= 4096)),
CONSTRAINT check_b09644994b CHECK ((char_length(squash_commit_template) <= 500)), CONSTRAINT check_b09644994b CHECK ((char_length(squash_commit_template) <= 500)),
CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL)), CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL)),
...@@ -928,12 +928,18 @@ module EE ...@@ -928,12 +928,18 @@ module EE
if ::Gitlab::CurrentSettings.should_check_namespace_plan? && namespace if ::Gitlab::CurrentSettings.should_check_namespace_plan? && namespace
globally_available && globally_available &&
(public? && namespace.public? || namespace.feature_available_in_plan?(feature)) (open_source_license_granted? || namespace.feature_available_in_plan?(feature))
else else
globally_available globally_available
end end
end end
def open_source_license_granted?
public? &&
namespace.public? &&
project_setting.legacy_open_source_license_available?
end
def user_defined_rules def user_defined_rules
strong_memoize(:user_defined_rules) do strong_memoize(:user_defined_rules) do
# Loading the relation in order to memoize it loaded # Loading the relation in order to memoize it loaded
......
...@@ -1257,6 +1257,35 @@ RSpec.describe Project do ...@@ -1257,6 +1257,35 @@ RSpec.describe Project do
subject subject
end end
end end
context 'legacy open-source license' do
let(:feature) { :sast }
before do
stub_application_setting(check_namespace_plan: true)
stub_licensed_features(feature => true)
end
context 'public projects' do
let(:project) { build(:project, :public, namespace: namespace) }
context 'when legacy_open_source_license_available feature flag is enabled' do
it 'allows ultimate features' do
is_expected.to eq(true)
end
end
context 'when legacy_open_source_license_available feature flag is disabled' do
before do
stub_feature_flags(legacy_open_source_license_available: false)
end
it 'prevent ultimate features' do
is_expected.to eq(false)
end
end
end
end
end end
describe '#fetch_mirror' do describe '#fetch_mirror' do
......
...@@ -139,6 +139,7 @@ project_setting: ...@@ -139,6 +139,7 @@ project_setting:
- has_confluence - has_confluence
- has_shimo - has_shimo
- has_vulnerabilities - has_vulnerabilities
- legacy_open_source_license_available
- prevent_merge_without_jira_issue - prevent_merge_without_jira_issue
- warn_about_potentially_unwanted_characters - warn_about_potentially_unwanted_characters
- previous_default_branch - previous_default_branch
......
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