From 7dda4c72cad94a88e36b8a507017dd3c55dbf5d6 Mon Sep 17 00:00:00 2001 From: Sheldon Led Date: Fri, 28 Nov 2025 07:01:57 -0300 Subject: [PATCH 1/4] Add display_gitlab_credits_user_data to app and namespace settings Changelog: added --- .../display_gitlab_credits_user_data.yml | 12 ++++++++++++ ...tlab_credits_user_data_to_application_settings.rb | 9 +++++++++ ...gitlab_credits_user_data_to_namespace_settings.rb | 9 +++++++++ db/schema_migrations/20251128092834 | 1 + db/schema_migrations/20251128093920 | 1 + db/structure.sql | 2 ++ .../cells/application_settings_analysis.md | 7 ++++--- ee/app/models/ee/application_setting.rb | 4 ++++ ee/app/models/ee/namespace_setting.rb | 4 ++++ ee/spec/models/application_setting_spec.rb | 7 +++++++ ee/spec/models/namespace_setting_spec.rb | 9 +++++++-- 11 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 config/application_setting_columns/display_gitlab_credits_user_data.yml create mode 100644 db/migrate/20251128092834_add_display_gitlab_credits_user_data_to_application_settings.rb create mode 100644 db/migrate/20251128093920_add_display_gitlab_credits_user_data_to_namespace_settings.rb create mode 100644 db/schema_migrations/20251128092834 create mode 100644 db/schema_migrations/20251128093920 diff --git a/config/application_setting_columns/display_gitlab_credits_user_data.yml b/config/application_setting_columns/display_gitlab_credits_user_data.yml new file mode 100644 index 00000000000000..638a30cd87f85d --- /dev/null +++ b/config/application_setting_columns/display_gitlab_credits_user_data.yml @@ -0,0 +1,12 @@ +--- +api_type: +attr: display_gitlab_credits_user_data +clusterwide: true +column: display_gitlab_credits_user_data +db_type: boolean +default: 'false' +description: +encrypted: false +gitlab_com_different_than_default: false +jihu: false +not_null: true diff --git a/db/migrate/20251128092834_add_display_gitlab_credits_user_data_to_application_settings.rb b/db/migrate/20251128092834_add_display_gitlab_credits_user_data_to_application_settings.rb new file mode 100644 index 00000000000000..eb63632d352d93 --- /dev/null +++ b/db/migrate/20251128092834_add_display_gitlab_credits_user_data_to_application_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddDisplayGitlabCreditsUserDataToApplicationSettings < Gitlab::Database::Migration[2.3] + milestone '18.7' + + def change + add_column :application_settings, :display_gitlab_credits_user_data, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20251128093920_add_display_gitlab_credits_user_data_to_namespace_settings.rb b/db/migrate/20251128093920_add_display_gitlab_credits_user_data_to_namespace_settings.rb new file mode 100644 index 00000000000000..59ca374b8c737c --- /dev/null +++ b/db/migrate/20251128093920_add_display_gitlab_credits_user_data_to_namespace_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddDisplayGitlabCreditsUserDataToNamespaceSettings < Gitlab::Database::Migration[2.3] + milestone '18.7' + + def change + add_column :namespace_settings, :display_gitlab_credits_user_data, :boolean, default: false, null: false + end +end diff --git a/db/schema_migrations/20251128092834 b/db/schema_migrations/20251128092834 new file mode 100644 index 00000000000000..c30693b28be954 --- /dev/null +++ b/db/schema_migrations/20251128092834 @@ -0,0 +1 @@ +62c38c6fb10c0b55d025fa8e72474dee753d6dbd8fbba1159e1314f9a522a231 \ No newline at end of file diff --git a/db/schema_migrations/20251128093920 b/db/schema_migrations/20251128093920 new file mode 100644 index 00000000000000..b22bd040ed2366 --- /dev/null +++ b/db/schema_migrations/20251128093920 @@ -0,0 +1 @@ +7cb4f1f15fcd6b0078d82fa1534d7c7bec9465b131e60d42fe3baaa4d5db9490 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index ed9d388320b36c..b83e7eda360d50 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -12471,6 +12471,7 @@ CREATE TABLE application_settings ( iframe_rendering_enabled boolean DEFAULT false NOT NULL, iframe_rendering_allowlist text, database_settings jsonb DEFAULT '{}'::jsonb NOT NULL, + display_gitlab_credits_user_data boolean DEFAULT false NOT NULL, CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)), CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)), CONSTRAINT app_settings_ext_pipeline_validation_service_url_text_limit CHECK ((char_length(external_pipeline_validation_service_url) <= 255)), @@ -21656,6 +21657,7 @@ CREATE TABLE namespace_settings ( lock_duo_foundational_flows_enabled boolean DEFAULT false NOT NULL, duo_sast_fp_detection_enabled boolean, lock_duo_sast_fp_detection_enabled boolean DEFAULT false NOT NULL, + display_gitlab_credits_user_data boolean DEFAULT false NOT NULL, CONSTRAINT check_0ba93c78c7 CHECK ((char_length(default_branch_name) <= 255)), CONSTRAINT check_d9644d516f CHECK ((char_length(step_up_auth_required_oauth_provider) <= 255)), CONSTRAINT check_namespace_settings_security_policies_is_hash CHECK ((jsonb_typeof(security_policies) = 'object'::text)), diff --git a/doc/development/cells/application_settings_analysis.md b/doc/development/cells/application_settings_analysis.md index e2c7643c11847d..fd1a8269e91246 100644 --- a/doc/development/cells/application_settings_analysis.md +++ b/doc/development/cells/application_settings_analysis.md @@ -14,12 +14,12 @@ title: Application Settings analysis ## Statistics -- Number of attributes: 508 +- Number of attributes: 509 - Number of encrypted attributes: 42 (8.0%) - Number of attributes documented: 297 (57.99999999999999%) - Number of attributes on GitLab.com different from the defaults: 224 (44.0%) -- Number of attributes with `clusterwide` set: 508 (100.0%) -- Number of attributes with `clusterwide: true` set: 135 (27.0%) +- Number of attributes with `clusterwide` set: 509 (100.0%) +- Number of attributes with `clusterwide: true` set: 136 (27.0%) ## Individual columns @@ -144,6 +144,7 @@ title: Application Settings analysis | `disable_overriding_approvers_per_merge_request` | `false` | `boolean` | `boolean` | `true` | `false` | `false` | `false`| `true` | | `disable_personal_access_tokens` | `false` | `boolean` | `boolean` | `true` | `false` | `false` | `false`| `true` | | `disabled_oauth_sign_in_sources` | `false` | `text` | `array of strings` | `false` | `null` | `false` | `false`| `true` | +| `display_gitlab_credits_user_data` | `false` | `boolean` | `` | `true` | `false` | `false` | `true`| `false` | | `dns_rebinding_protection_enabled` | `false` | `boolean` | `boolean` | `true` | `true` | `false` | `false`| `true` | | `domain_allowlist` | `false` | `text` | `array of strings` | `false` | `null` | `false` | `false`| `true` | | `domain_denylist` | `false` | `text` | `array of strings` | `false` | `null` | `true` | `true`| `true` | diff --git a/ee/app/models/ee/application_setting.rb b/ee/app/models/ee/application_setting.rb index 2fc8a20c772192..cdfd457550db30 100644 --- a/ee/app/models/ee/application_setting.rb +++ b/ee/app/models/ee/application_setting.rb @@ -385,6 +385,10 @@ module ApplicationSetting :duo_foundational_flows_enabled, :duo_sast_fp_detection_enabled, inclusion: { in: [true, false] } + validates :display_gitlab_credits_user_data, + allow_nil: false, + inclusion: { in: [true, false], message: N_('must be a boolean value') } + validate :duo_settings_immutable_on_saas, on: :update, if: -> { ::Gitlab::Saas.feature_available?(:gitlab_duo_saas_only) } diff --git a/ee/app/models/ee/namespace_setting.rb b/ee/app/models/ee/namespace_setting.rb index c47e1fdcd6a2f2..7155059460e04c 100644 --- a/ee/app/models/ee/namespace_setting.rb +++ b/ee/app/models/ee/namespace_setting.rb @@ -84,6 +84,10 @@ module NamespaceSetting only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 20, allow_nil: true } + validates :display_gitlab_credits_user_data, + allow_nil: false, + inclusion: { in: [true, false], message: N_('must be a boolean value') } + jsonb_accessor :security_policies, pipeline_execution_policies_per_configuration_limit: [:integer, { default: 0 }] jsonb_accessor :security_policies, scan_execution_policies_per_configuration_limit: [:integer, { default: 0 }] jsonb_accessor :security_policies, approval_policies_per_configuration_limit: [:integer, { default: 0 }] diff --git a/ee/spec/models/application_setting_spec.rb b/ee/spec/models/application_setting_spec.rb index 2a08c933d98d5c..0130c52d5b6b5e 100644 --- a/ee/spec/models/application_setting_spec.rb +++ b/ee/spec/models/application_setting_spec.rb @@ -1454,6 +1454,13 @@ it { is_expected.to allow_value(['project'] * 1000).for(:ci_cd_catalog_projects_allowlist) } it { is_expected.not_to allow_value(['project'] * 1001).for(:ci_cd_catalog_projects_allowlist) } end + + describe 'display_gitlab_credits_user_data' do + it 'validates display_gitlab_credits_user_data' do + expect(setting).to validate_inclusion_of(:display_gitlab_credits_user_data) + .in_array([true, false]) + end + end end describe 'search curation settings after .create_from_defaults', feature_category: :global_search do diff --git a/ee/spec/models/namespace_setting_spec.rb b/ee/spec/models/namespace_setting_spec.rb index 55059eee021c49..899751ebafee73 100644 --- a/ee/spec/models/namespace_setting_spec.rb +++ b/ee/spec/models/namespace_setting_spec.rb @@ -63,8 +63,6 @@ describe 'experiment features' do let(:attr) { :experiment_features_enabled } - subject(:settings) { group.namespace_settings } - before do allow(subject).to receive(:experiment_settings_allowed?).and_return(true) end @@ -295,6 +293,13 @@ .is_less_than_or_equal_to(1827) end end + + describe 'display_gitlab_credits_user_data' do + it 'validates display_gitlab_credits_user_data' do + expect(settings).to validate_inclusion_of(:display_gitlab_credits_user_data) + .in_array([true, false]) + end + end end describe 'after_commit' do -- GitLab From a65aaff8b0b57bca724cb1c7adafce5608257193 Mon Sep 17 00:00:00 2001 From: Sheldon Led Date: Tue, 2 Dec 2025 10:29:13 -0300 Subject: [PATCH 2/4] Change new setting column to be of jsonb type --- .../display_gitlab_credits_user_data.yml | 12 ------ .../usage_billing.yml | 13 ++++++ ...edits_user_data_to_application_settings.rb | 9 ---- ...credits_user_data_to_namespace_settings.rb | 9 ---- ...2_add_usage_billing_application_setting.rb | 9 ++++ ...837_add_usage_billing_namespace_setting.rb | 12 ++++++ ...hash_constraint_to_application_settings.rb | 20 +++++++++ ...g_hash_constraint_to_namespace_settings.rb | 20 +++++++++ db/schema_migrations/20251128092834 | 1 - db/schema_migrations/20251128093920 | 1 - db/schema_migrations/20251202120752 | 1 + db/schema_migrations/20251202120837 | 1 + db/schema_migrations/20251202120931 | 1 + db/schema_migrations/20251202120957 | 1 + db/structure.sql | 6 ++- doc/api/settings.md | 1 + .../cells/application_settings_analysis.md | 10 ++--- ee/app/models/ee/application_setting.rb | 42 +++++++++---------- ee/app/models/ee/namespace_setting.rb | 15 +++++-- .../json_schemas/usage_billing_settings.json | 12 ++++++ ee/spec/models/application_setting_spec.rb | 3 +- 21 files changed, 132 insertions(+), 67 deletions(-) delete mode 100644 config/application_setting_columns/display_gitlab_credits_user_data.yml create mode 100644 config/application_setting_columns/usage_billing.yml delete mode 100644 db/migrate/20251128092834_add_display_gitlab_credits_user_data_to_application_settings.rb delete mode 100644 db/migrate/20251128093920_add_display_gitlab_credits_user_data_to_namespace_settings.rb create mode 100644 db/migrate/20251202120752_add_usage_billing_application_setting.rb create mode 100644 db/migrate/20251202120837_add_usage_billing_namespace_setting.rb create mode 100644 db/migrate/20251202120931_add_usage_billing_hash_constraint_to_application_settings.rb create mode 100644 db/migrate/20251202120957_add_usage_billing_hash_constraint_to_namespace_settings.rb delete mode 100644 db/schema_migrations/20251128092834 delete mode 100644 db/schema_migrations/20251128093920 create mode 100644 db/schema_migrations/20251202120752 create mode 100644 db/schema_migrations/20251202120837 create mode 100644 db/schema_migrations/20251202120931 create mode 100644 db/schema_migrations/20251202120957 create mode 100644 ee/app/validators/json_schemas/usage_billing_settings.json diff --git a/config/application_setting_columns/display_gitlab_credits_user_data.yml b/config/application_setting_columns/display_gitlab_credits_user_data.yml deleted file mode 100644 index 638a30cd87f85d..00000000000000 --- a/config/application_setting_columns/display_gitlab_credits_user_data.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -api_type: -attr: display_gitlab_credits_user_data -clusterwide: true -column: display_gitlab_credits_user_data -db_type: boolean -default: 'false' -description: -encrypted: false -gitlab_com_different_than_default: false -jihu: false -not_null: true diff --git a/config/application_setting_columns/usage_billing.yml b/config/application_setting_columns/usage_billing.yml new file mode 100644 index 00000000000000..bac043f03c1d7f --- /dev/null +++ b/config/application_setting_columns/usage_billing.yml @@ -0,0 +1,13 @@ +--- +api_type: object +attr: usage_billing +clusterwide: true +column: usage_billing +db_type: jsonb +default: "'{}'::jsonb" +description: Usage Billing Settings. Check `ee/app/validators/json_schemas/usage_billing_settings.json` + for schema definition +encrypted: false +gitlab_com_different_than_default: false +jihu: false +not_null: true diff --git a/db/migrate/20251128092834_add_display_gitlab_credits_user_data_to_application_settings.rb b/db/migrate/20251128092834_add_display_gitlab_credits_user_data_to_application_settings.rb deleted file mode 100644 index eb63632d352d93..00000000000000 --- a/db/migrate/20251128092834_add_display_gitlab_credits_user_data_to_application_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddDisplayGitlabCreditsUserDataToApplicationSettings < Gitlab::Database::Migration[2.3] - milestone '18.7' - - def change - add_column :application_settings, :display_gitlab_credits_user_data, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20251128093920_add_display_gitlab_credits_user_data_to_namespace_settings.rb b/db/migrate/20251128093920_add_display_gitlab_credits_user_data_to_namespace_settings.rb deleted file mode 100644 index 59ca374b8c737c..00000000000000 --- a/db/migrate/20251128093920_add_display_gitlab_credits_user_data_to_namespace_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class AddDisplayGitlabCreditsUserDataToNamespaceSettings < Gitlab::Database::Migration[2.3] - milestone '18.7' - - def change - add_column :namespace_settings, :display_gitlab_credits_user_data, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20251202120752_add_usage_billing_application_setting.rb b/db/migrate/20251202120752_add_usage_billing_application_setting.rb new file mode 100644 index 00000000000000..6a6035d5a21688 --- /dev/null +++ b/db/migrate/20251202120752_add_usage_billing_application_setting.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddUsageBillingApplicationSetting < Gitlab::Database::Migration[2.3] + milestone '18.7' + + def change + add_column :application_settings, :usage_billing, :jsonb, default: {}, null: false + end +end diff --git a/db/migrate/20251202120837_add_usage_billing_namespace_setting.rb b/db/migrate/20251202120837_add_usage_billing_namespace_setting.rb new file mode 100644 index 00000000000000..2e9e1d24eddaf0 --- /dev/null +++ b/db/migrate/20251202120837_add_usage_billing_namespace_setting.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddUsageBillingNamespaceSetting < Gitlab::Database::Migration[2.3] + milestone '18.7' + + def change + add_column :namespace_settings, :usage_billing, :jsonb, default: {}, null: false + end +end diff --git a/db/migrate/20251202120931_add_usage_billing_hash_constraint_to_application_settings.rb b/db/migrate/20251202120931_add_usage_billing_hash_constraint_to_application_settings.rb new file mode 100644 index 00000000000000..31a8fa5e3f2703 --- /dev/null +++ b/db/migrate/20251202120931_add_usage_billing_hash_constraint_to_application_settings.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddUsageBillingHashConstraintToApplicationSettings < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + milestone '18.7' + + CONSTRAINT_NAME = 'check_application_settings_usage_billing_is_hash' + + def up + add_check_constraint( + :application_settings, + "(jsonb_typeof(usage_billing) = 'object')", + CONSTRAINT_NAME + ) + end + + def down + remove_check_constraint :application_settings, CONSTRAINT_NAME + end +end diff --git a/db/migrate/20251202120957_add_usage_billing_hash_constraint_to_namespace_settings.rb b/db/migrate/20251202120957_add_usage_billing_hash_constraint_to_namespace_settings.rb new file mode 100644 index 00000000000000..335aeeb5ec86a0 --- /dev/null +++ b/db/migrate/20251202120957_add_usage_billing_hash_constraint_to_namespace_settings.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddUsageBillingHashConstraintToNamespaceSettings < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + milestone '18.7' + + CONSTRAINT_NAME = 'check_namespace_settings_usage_billing_is_hash' + + def up + add_check_constraint( + :namespace_settings, + "(jsonb_typeof(usage_billing) = 'object')", + CONSTRAINT_NAME + ) + end + + def down + remove_check_constraint :namespace_settings, CONSTRAINT_NAME + end +end diff --git a/db/schema_migrations/20251128092834 b/db/schema_migrations/20251128092834 deleted file mode 100644 index c30693b28be954..00000000000000 --- a/db/schema_migrations/20251128092834 +++ /dev/null @@ -1 +0,0 @@ -62c38c6fb10c0b55d025fa8e72474dee753d6dbd8fbba1159e1314f9a522a231 \ No newline at end of file diff --git a/db/schema_migrations/20251128093920 b/db/schema_migrations/20251128093920 deleted file mode 100644 index b22bd040ed2366..00000000000000 --- a/db/schema_migrations/20251128093920 +++ /dev/null @@ -1 +0,0 @@ -7cb4f1f15fcd6b0078d82fa1534d7c7bec9465b131e60d42fe3baaa4d5db9490 \ No newline at end of file diff --git a/db/schema_migrations/20251202120752 b/db/schema_migrations/20251202120752 new file mode 100644 index 00000000000000..cb6e4534859a0f --- /dev/null +++ b/db/schema_migrations/20251202120752 @@ -0,0 +1 @@ +e4de3d81fb9a25156abc39a78c5ed22cbd36c4b5b9d639dbe34436a5f57c2105 \ No newline at end of file diff --git a/db/schema_migrations/20251202120837 b/db/schema_migrations/20251202120837 new file mode 100644 index 00000000000000..65673254b29a91 --- /dev/null +++ b/db/schema_migrations/20251202120837 @@ -0,0 +1 @@ +ccb776b0058751c517b6806afe11d2e563ce15e784931ba80f8ed365d846eb88 \ No newline at end of file diff --git a/db/schema_migrations/20251202120931 b/db/schema_migrations/20251202120931 new file mode 100644 index 00000000000000..0317ceff34245c --- /dev/null +++ b/db/schema_migrations/20251202120931 @@ -0,0 +1 @@ +fc85115f5ced481a7a2843050c498145d5e725c75d7251ed3f0a9adcea077593 \ No newline at end of file diff --git a/db/schema_migrations/20251202120957 b/db/schema_migrations/20251202120957 new file mode 100644 index 00000000000000..384c81e1ccb743 --- /dev/null +++ b/db/schema_migrations/20251202120957 @@ -0,0 +1 @@ +bd0d5b5dbcdb1496e2e80b8badf17dce4f539807ff1d0e818bf635fed15b0538 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index b83e7eda360d50..0807e60d9211ea 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -12471,7 +12471,7 @@ CREATE TABLE application_settings ( iframe_rendering_enabled boolean DEFAULT false NOT NULL, iframe_rendering_allowlist text, database_settings jsonb DEFAULT '{}'::jsonb NOT NULL, - display_gitlab_credits_user_data boolean DEFAULT false NOT NULL, + usage_billing jsonb DEFAULT '{}'::jsonb NOT NULL, CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)), CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)), CONSTRAINT app_settings_ext_pipeline_validation_service_url_text_limit CHECK ((char_length(external_pipeline_validation_service_url) <= 255)), @@ -12545,6 +12545,7 @@ CREATE TABLE application_settings ( CONSTRAINT check_application_settings_sign_in_restrictions_is_hash CHECK ((jsonb_typeof(sign_in_restrictions) = 'object'::text)), CONSTRAINT check_application_settings_token_prefixes_is_hash CHECK ((jsonb_typeof(token_prefixes) = 'object'::text)), CONSTRAINT check_application_settings_transactional_emails_is_hash CHECK ((jsonb_typeof(transactional_emails) = 'object'::text)), + CONSTRAINT check_application_settings_usage_billing_is_hash CHECK ((jsonb_typeof(usage_billing) = 'object'::text)), CONSTRAINT check_application_settings_vscode_extension_marketplace_is_hash CHECK ((jsonb_typeof(vscode_extension_marketplace) = 'object'::text)), CONSTRAINT check_b8c74ea5b3 CHECK ((char_length(deactivation_email_additional_text) <= 1000)), CONSTRAINT check_babd774f3c CHECK ((char_length(secret_detection_service_url) <= 255)), @@ -21657,10 +21658,11 @@ CREATE TABLE namespace_settings ( lock_duo_foundational_flows_enabled boolean DEFAULT false NOT NULL, duo_sast_fp_detection_enabled boolean, lock_duo_sast_fp_detection_enabled boolean DEFAULT false NOT NULL, - display_gitlab_credits_user_data boolean DEFAULT false NOT NULL, + usage_billing jsonb DEFAULT '{}'::jsonb NOT NULL, CONSTRAINT check_0ba93c78c7 CHECK ((char_length(default_branch_name) <= 255)), CONSTRAINT check_d9644d516f CHECK ((char_length(step_up_auth_required_oauth_provider) <= 255)), CONSTRAINT check_namespace_settings_security_policies_is_hash CHECK ((jsonb_typeof(security_policies) = 'object'::text)), + CONSTRAINT check_namespace_settings_usage_billing_is_hash CHECK ((jsonb_typeof(usage_billing) = 'object'::text)), CONSTRAINT namespace_settings_unique_project_download_limit_alertlist_size CHECK ((cardinality(unique_project_download_limit_alertlist) <= 100)), CONSTRAINT namespace_settings_unique_project_download_limit_allowlist_size CHECK ((cardinality(unique_project_download_limit_allowlist) <= 100)) ); diff --git a/doc/api/settings.md b/doc/api/settings.md index 7f25b302f01167..0a755fe104d5ec 100644 --- a/doc/api/settings.md +++ b/doc/api/settings.md @@ -844,6 +844,7 @@ to configure other related settings. These requirements are | `iframe_rendering_enabled` | boolean | no | Allow rendering of iframes in Markdown. Disabled by default. | | `iframe_rendering_allowlist` | array of strings | no | List of allowed iframe `src` host[:port] entries used for Content Security Policy and sanitization. | | `iframe_rendering_allowlist_raw` | string | no | Raw newline- or comma-separated list of allowed iframe `src` host[:port] entries. | +| `usage_billing` | object | no | Usage Billing Settings. Check `ee/app/validators/json_schemas/usage_billing_settings.json` for schema definition | ### Dormant project settings diff --git a/doc/development/cells/application_settings_analysis.md b/doc/development/cells/application_settings_analysis.md index fd1a8269e91246..a7e7d0b2267a30 100644 --- a/doc/development/cells/application_settings_analysis.md +++ b/doc/development/cells/application_settings_analysis.md @@ -14,12 +14,12 @@ title: Application Settings analysis ## Statistics -- Number of attributes: 509 +- Number of attributes: 510 - Number of encrypted attributes: 42 (8.0%) -- Number of attributes documented: 297 (57.99999999999999%) +- Number of attributes documented: 298 (57.99999999999999%) - Number of attributes on GitLab.com different from the defaults: 224 (44.0%) -- Number of attributes with `clusterwide` set: 509 (100.0%) -- Number of attributes with `clusterwide: true` set: 136 (27.0%) +- Number of attributes with `clusterwide` set: 510 (100.0%) +- Number of attributes with `clusterwide: true` set: 137 (27.0%) ## Individual columns @@ -144,7 +144,6 @@ title: Application Settings analysis | `disable_overriding_approvers_per_merge_request` | `false` | `boolean` | `boolean` | `true` | `false` | `false` | `false`| `true` | | `disable_personal_access_tokens` | `false` | `boolean` | `boolean` | `true` | `false` | `false` | `false`| `true` | | `disabled_oauth_sign_in_sources` | `false` | `text` | `array of strings` | `false` | `null` | `false` | `false`| `true` | -| `display_gitlab_credits_user_data` | `false` | `boolean` | `` | `true` | `false` | `false` | `true`| `false` | | `dns_rebinding_protection_enabled` | `false` | `boolean` | `boolean` | `true` | `true` | `false` | `false`| `true` | | `domain_allowlist` | `false` | `text` | `array of strings` | `false` | `null` | `false` | `false`| `true` | | `domain_denylist` | `false` | `text` | `array of strings` | `false` | `null` | `true` | `true`| `true` | @@ -508,6 +507,7 @@ title: Application Settings analysis | `update_runner_versions_enabled` | `false` | `boolean` | `boolean` | `true` | `true` | `false` | `false`| `true` | | `updated_at` | `false` | `timestamp` | `` | `false` | `null` | `true` | `false`| `false` | | `updating_name_disabled_for_users` | `false` | `boolean` | `boolean` | `true` | `false` | `false` | `false`| `true` | +| `usage_billing` | `false` | `jsonb` | `object` | `true` | `'{}'::jsonb` | `false` | `true`| `true` | | `usage_ping_enabled` | `false` | `boolean` | `boolean` | `true` | `true` | `false` | `false`| `true` | | `usage_ping_features_enabled` | `false` | `boolean` | `` | `true` | `false` | `false` | `false`| `false` | | `usage_ping_generation_enabled` | `false` | `boolean` | `` | `true` | `true` | `false` | `false`| `false` | diff --git a/ee/app/models/ee/application_setting.rb b/ee/app/models/ee/application_setting.rb index cdfd457550db30..afe9cf8a2cb717 100644 --- a/ee/app/models/ee/application_setting.rb +++ b/ee/app/models/ee/application_setting.rb @@ -66,6 +66,11 @@ module ApplicationSetting message: "must be one of: #{Ai::Conversation::Thread::EXPIRATION_COLUMNS.join(', ')}" } + jsonb_accessor :usage_billing, + display_gitlab_credits_user_data: [:boolean, { default: false }] + + validates :usage_billing, json_schema: { filename: "usage_billing_settings" } + jsonb_accessor :integrations, allow_all_integrations: [:boolean, { default: true }], allowed_integrations: [:string, { array: true, default: [] }] @@ -264,8 +269,6 @@ module ApplicationSetting :virtual_registries_endpoints_api_limit, numericality: { only_integer: true, greater_than_or_equal_to: 0 } - validates :dashboard_limit_enabled, inclusion: { in: [true, false], message: 'must be a boolean value' } - validates :cube_api_base_url, length: { maximum: 512 }, addressable_url: ::ApplicationSetting::ADDRESSABLE_URL_VALIDATION_OPTIONS.merge({ allow_localhost: true }), @@ -287,9 +290,6 @@ module ApplicationSetting presence: true, if: ->(setting) { setting.product_analytics_enabled } - validates :security_policy_global_group_approvers_enabled, - inclusion: { in: [true, false], message: 'must be a boolean value' } - validates :security_approval_policies_limit, numericality: { only_integer: true, @@ -325,9 +325,6 @@ module ApplicationSetting validates :package_metadata_purl_types, inclusion: { in: ::Enums::Sbom.purl_types.values } - validates :allow_account_deletion, - inclusion: { in: [true, false], message: N_('must be a boolean value') } - validates :delete_unconfirmed_users, inclusion: { in: [true, false], message: N_('must be a boolean value') }, unless: :email_confirmation_setting_off? @@ -348,10 +345,6 @@ module ApplicationSetting inclusion: { in: [true, false], message: N_('must be a boolean value') }, if: :gitlab_dedicated_instance - validates :instance_level_ai_beta_features_enabled, - allow_nil: false, - inclusion: { in: [true, false], message: N_('must be a boolean value') } - validates :zoekt_settings, json_schema: { filename: 'application_setting_zoekt_settings' } validates :zoekt_cpu_to_tasks_ratio, numericality: { greater_than: 0.0 } validates :zoekt_indexing_parallelism, numericality: { greater_than: 0 } @@ -377,17 +370,20 @@ module ApplicationSetting validates :code_creation, json_schema: { filename: 'application_setting_code_creation' } - validates :observability_backend_ssl_verification_enabled, - allow_nil: false, - inclusion: { in: [true, false], message: N_('must be a boolean value') } - - validates :auto_duo_code_review_enabled, :duo_remote_flows_enabled, - :duo_foundational_flows_enabled, :duo_sast_fp_detection_enabled, - inclusion: { in: [true, false] } - - validates :display_gitlab_credits_user_data, - allow_nil: false, - inclusion: { in: [true, false], message: N_('must be a boolean value') } + with_options(inclusion: { in: [true, false], message: N_('must be a boolean value') }) do + validates( + :dashboard_limit_enabled, + :security_policy_global_group_approvers_enabled, + :allow_account_deletion, + :instance_level_ai_beta_features_enabled, + :observability_backend_ssl_verification_enabled, + :auto_duo_code_review_enabled, + :duo_remote_flows_enabled, + :duo_foundational_flows_enabled, + :duo_sast_fp_detection_enabled, + :display_gitlab_credits_user_data + ) + end validate :duo_settings_immutable_on_saas, on: :update, diff --git a/ee/app/models/ee/namespace_setting.rb b/ee/app/models/ee/namespace_setting.rb index 7155059460e04c..0bb14076ddf0ab 100644 --- a/ee/app/models/ee/namespace_setting.rb +++ b/ee/app/models/ee/namespace_setting.rb @@ -41,7 +41,6 @@ module NamespaceSetting allow_nil: false, user_id_existence: true, if: :unique_project_download_limit_alertlist_changed? - validates :experiment_features_enabled, inclusion: { in: [true, false] } alias_attribute :duo_core_features_enabled, :duo_nano_features_enabled @@ -84,9 +83,17 @@ module NamespaceSetting only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 20, allow_nil: true } - validates :display_gitlab_credits_user_data, - allow_nil: false, - inclusion: { in: [true, false], message: N_('must be a boolean value') } + with_options(inclusion: { in: [true, false], message: N_('must be a boolean value') }) do + validates( + :experiment_features_enabled, + :display_gitlab_credits_user_data + ) + end + + jsonb_accessor :usage_billing, + display_gitlab_credits_user_data: [:boolean, { default: false }] + + validates :usage_billing, json_schema: { filename: "usage_billing_settings" } jsonb_accessor :security_policies, pipeline_execution_policies_per_configuration_limit: [:integer, { default: 0 }] jsonb_accessor :security_policies, scan_execution_policies_per_configuration_limit: [:integer, { default: 0 }] diff --git a/ee/app/validators/json_schemas/usage_billing_settings.json b/ee/app/validators/json_schemas/usage_billing_settings.json new file mode 100644 index 00000000000000..ea617ab53c7369 --- /dev/null +++ b/ee/app/validators/json_schemas/usage_billing_settings.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Usage Billing settings", + "type": "object", + "additionalProperties": false, + "properties": { + "display_gitlab_credits_user_data": { + "type": "boolean", + "description": "Enable display of user data in GitLab Credits dashboards" + } + } +} diff --git a/ee/spec/models/application_setting_spec.rb b/ee/spec/models/application_setting_spec.rb index 0130c52d5b6b5e..851f777fbe4eec 100644 --- a/ee/spec/models/application_setting_spec.rb +++ b/ee/spec/models/application_setting_spec.rb @@ -172,7 +172,8 @@ zoekt_rollout_retry_interval: Search::Zoekt::Settings::DEFAULT_ROLLOUT_RETRY_INTERVAL, zoekt_lost_node_threshold: Search::Zoekt::Settings::DEFAULT_LOST_NODE_THRESHOLD, zoekt_search_enabled: false, - enforce_pipl_compliance: false + enforce_pipl_compliance: false, + display_gitlab_credits_user_data: false ) end end -- GitLab From 95154b9b9ee9033e18a12343daa9bf572f36221d Mon Sep 17 00:00:00 2001 From: Sheldon Led Date: Thu, 4 Dec 2025 09:01:21 -0300 Subject: [PATCH 3/4] Remove unnecessary comment --- .../20251202120837_add_usage_billing_namespace_setting.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/db/migrate/20251202120837_add_usage_billing_namespace_setting.rb b/db/migrate/20251202120837_add_usage_billing_namespace_setting.rb index 2e9e1d24eddaf0..8ec73f662e666d 100644 --- a/db/migrate/20251202120837_add_usage_billing_namespace_setting.rb +++ b/db/migrate/20251202120837_add_usage_billing_namespace_setting.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddUsageBillingNamespaceSetting < Gitlab::Database::Migration[2.3] milestone '18.7' -- GitLab From 424b157ad3c97a88ba80bf5163706e82470bb201 Mon Sep 17 00:00:00 2001 From: Suraj Tripathi Date: Mon, 8 Dec 2025 16:37:08 +0530 Subject: [PATCH 4/4] Fix broken pipeline --- .../lib/namespaces/namespace_setting_changes_auditor_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ee/spec/lib/namespaces/namespace_setting_changes_auditor_spec.rb b/ee/spec/lib/namespaces/namespace_setting_changes_auditor_spec.rb index 1e54928522a304..dea1f4d160de54 100644 --- a/ee/spec/lib/namespaces/namespace_setting_changes_auditor_spec.rb +++ b/ee/spec/lib/namespaces/namespace_setting_changes_auditor_spec.rb @@ -130,7 +130,8 @@ web_based_commit_signing_enabled allow_enterprise_bypass_placeholder_confirmation enterprise_bypass_expires_at allow_personal_snippets lock_auto_duo_code_review_enabled auto_duo_code_review_enabled lock_duo_remote_flows_enabled duo_remote_flows_enabled lock_duo_foundational_flows_enabled - duo_foundational_flows_enabled lock_duo_sast_fp_detection_enabled duo_sast_fp_detection_enabled] + duo_foundational_flows_enabled lock_duo_sast_fp_detection_enabled duo_sast_fp_detection_enabled + usage_billing] columns_to_audit = Namespaces::NamespaceSettingChangesAuditor::EVENT_NAME_PER_COLUMN.keys.map(&:to_s) -- GitLab