Skip to content
Snippets Groups Projects

Add new jsonb column to store settings for default branch protection

Merged Michael Becker requested to merge feat/408150 into master
7 files
+ 64
1
Compare changes
  • Side-by-side
  • Inline
Files
7
  • Currently, the options for default branch protection at the instance
    and group level lag behind, and are not as fine-grained, as the
    options available from the Protected Branches feature
    
    The branch defaults lag behind because the current implementation uses
    an integer column to store the default settings, which becomes
    difficult to expand as new options and finer detail controls are added
    to the protected branches feature
    
    To offer better support of protected branches features on the default
    branch, we can:
    
      1. use a jsonb column rather than an integer
      2. update the settings API to accept a payload the matches the protected branches API
      3. Pass those settings into the ProtecteBrancheService
    
    This commit performs step 1, by adding a new `jsonb` column
    
    Changelog: added
@@ -89,6 +89,7 @@ def self.kroki_formats_attributes
@@ -89,6 +89,7 @@ def self.kroki_formats_attributes
attribute :id, default: 1
attribute :id, default: 1
attribute :repository_storages_weighted, default: -> { {} }
attribute :repository_storages_weighted, default: -> { {} }
attribute :kroki_formats, default: -> { {} }
attribute :kroki_formats, default: -> { {} }
 
attribute :default_branch_protection_defaults, default: -> { {} }
chronic_duration_attr_writer :archive_builds_in_human_readable, :archive_builds_in_seconds
chronic_duration_attr_writer :archive_builds_in_human_readable, :archive_builds_in_seconds
@@ -96,6 +97,8 @@ def self.kroki_formats_attributes
@@ -96,6 +97,8 @@ def self.kroki_formats_attributes
chronic_duration_attr :group_runner_token_expiration_interval_human_readable, :group_runner_token_expiration_interval
chronic_duration_attr :group_runner_token_expiration_interval_human_readable, :group_runner_token_expiration_interval
chronic_duration_attr :project_runner_token_expiration_interval_human_readable, :project_runner_token_expiration_interval
chronic_duration_attr :project_runner_token_expiration_interval_human_readable, :project_runner_token_expiration_interval
 
validates :default_branch_protection_defaults, json_schema: { filename: 'default_branch_protection_defaults' }
 
validates :grafana_url,
validates :grafana_url,
system_hook_url: ADDRESSABLE_URL_VALIDATION_OPTIONS.merge({
system_hook_url: ADDRESSABLE_URL_VALIDATION_OPTIONS.merge({
blocked_message: "is blocked: %{exception_message}. #{GRAFANA_URL_ERROR_MESSAGE}"
blocked_message: "is blocked: %{exception_message}. #{GRAFANA_URL_ERROR_MESSAGE}"
Loading