Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-08-01 18:10:12 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-08-01 18:10:12 +0300
commit4212e9c2d42fb35dda8694ca5b448e10ffc98211 (patch)
treed0f16aebc55d4f6a003556d1c1c11123923af58a /app
parent5e77663f2e4617be51e387b75872e1bcc8559f54 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/editor/schema/ci.json112
-rw-r--r--app/helpers/admin/application_settings/settings_helper.rb60
-rw-r--r--app/helpers/application_settings_helper.rb2
-rw-r--r--app/models/application_setting.rb5
-rw-r--r--app/models/concerns/application_setting_masked_attrs.rb14
-rw-r--r--app/services/metrics/dashboard/custom_dashboard_service.rb53
-rw-r--r--app/services/metrics/dashboard/update_dashboard_service.rb127
-rw-r--r--app/views/admin/application_settings/_ai_access.html.haml31
8 files changed, 77 insertions, 327 deletions
diff --git a/app/assets/javascripts/editor/schema/ci.json b/app/assets/javascripts/editor/schema/ci.json
index ed1d3d8af08..65091487c93 100644
--- a/app/assets/javascripts/editor/schema/ci.json
+++ b/app/assets/javascripts/editor/schema/ci.json
@@ -1098,6 +1098,73 @@
}
]
},
+ "parallel": {
+ "description": "Splits up a single job into multiple that run in parallel. Provides `CI_NODE_INDEX` and `CI_NODE_TOTAL` environment variables to the jobs.",
+ "oneOf": [
+ {
+ "type": "integer",
+ "description": "Creates N instances of the job that run in parallel.",
+ "default": 0,
+ "minimum": 2,
+ "maximum": 200
+ },
+ {
+ "type": "object",
+ "properties": {
+ "matrix": {
+ "type": "array",
+ "description": "Defines different variables for jobs that are running in parallel.",
+ "items": {
+ "type": "object",
+ "description": "Defines the variables for a specific job.",
+ "additionalProperties": {
+ "type": [
+ "string",
+ "number",
+ "array"
+ ]
+ }
+ },
+ "maxItems": 200
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "matrix"
+ ]
+ }
+ ]
+ },
+ "parallel_matrix": {
+ "description": "Use the `needs:parallel:matrix` keyword to specify parallelized jobs needed to be completed for the job to run. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#needsparallelmatrix)",
+ "oneOf": [
+ {
+ "type": "object",
+ "properties": {
+ "matrix": {
+ "type": "array",
+ "description": "Defines different variables for jobs that are running in parallel.",
+ "items": {
+ "type": "object",
+ "description": "Defines the variables for a specific job.",
+ "additionalProperties": {
+ "type": [
+ "string",
+ "number",
+ "array"
+ ]
+ }
+ },
+ "maxItems": 200
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "matrix"
+ ]
+ }
+ ]
+ },
"when": {
"markdownDescription": "Describes the conditions for when to run the job. Defaults to 'on_success'. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#when).",
"default": "on_success",
@@ -1518,6 +1585,9 @@
},
"optional": {
"type": "boolean"
+ },
+ "parallel": {
+ "$ref": "#/definitions/parallel_matrix"
}
},
"required": [
@@ -1536,6 +1606,9 @@
},
"artifacts": {
"type": "boolean"
+ },
+ "parallel": {
+ "$ref": "#/definitions/parallel_matrix"
}
},
"required": [
@@ -1558,6 +1631,9 @@
},
"artifacts": {
"type": "boolean"
+ },
+ "parallel": {
+ "$ref": "#/definitions/parallel_matrix"
}
},
"required": [
@@ -1771,41 +1847,7 @@
"$ref": "#/definitions/retry"
},
"parallel": {
- "description": "Parallel will split up a single job into several, and provide `CI_NODE_INDEX` and `CI_NODE_TOTAL` environment variables for the running jobs.",
- "oneOf": [
- {
- "type": "integer",
- "description": "Creates N instances of the same job that run in parallel.",
- "default": 0,
- "minimum": 2,
- "maximum": 200
- },
- {
- "type": "object",
- "properties": {
- "matrix": {
- "type": "array",
- "description": "Defines different variables for jobs that are running in parallel.",
- "items": {
- "type": "object",
- "description": "Defines environment variables for specific job.",
- "additionalProperties": {
- "type": [
- "string",
- "number",
- "array"
- ]
- }
- },
- "maxItems": 200
- }
- },
- "additionalProperties": false,
- "required": [
- "matrix"
- ]
- }
- ]
+ "$ref": "#/definitions/parallel"
},
"interruptible": {
"$ref": "#/definitions/interruptible"
diff --git a/app/helpers/admin/application_settings/settings_helper.rb b/app/helpers/admin/application_settings/settings_helper.rb
index 9ea07ba4e6e..1741d6a953a 100644
--- a/app/helpers/admin/application_settings/settings_helper.rb
+++ b/app/helpers/admin/application_settings/settings_helper.rb
@@ -15,66 +15,6 @@ module Admin
def project_missing_pipeline_yaml?(project)
project.repository&.gitlab_ci_yml.blank?
end
-
- def code_suggestions_description
- link_start = code_suggestions_link_start(code_suggestions_docs_url)
-
- # rubocop:disable Layout/LineLength
- # rubocop:disable Style/FormatString
- s_('CodeSuggestionsSM|Enable Code Suggestions for users of this instance. %{link_start}What are Code Suggestions?%{link_end}')
- .html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
- # rubocop:enable Style/FormatString
- # rubocop:enable Layout/LineLength
- end
-
- def code_suggestions_token_explanation
- link_start = code_suggestions_link_start(code_suggestions_pat_docs_url)
-
- # rubocop:disable Layout/LineLength
- # rubocop:disable Style/FormatString
- s_('CodeSuggestionsSM|On GitLab.com, create a token. This token is required to use Code Suggestions on your self-managed instance. %{link_start}How do I create a token?%{link_end}')
- .html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
- # rubocop:enable Style/FormatString
- # rubocop:enable Layout/LineLength
- end
-
- def code_suggestions_agreement
- terms_link_start = code_suggestions_link_start(code_suggestions_agreement_url)
- ai_docs_link_start = code_suggestions_link_start(code_suggestions_ai_docs_url)
-
- # rubocop:disable Layout/LineLength
- # rubocop:disable Style/FormatString
- s_('CodeSuggestionsSM|By enabling this feature, you agree to the %{terms_link_start}GitLab Testing Agreement%{link_end} and acknowledge that GitLab will send data from the instance, including personal data, to our %{ai_docs_link_start}AI providers%{link_end} to provide this feature.')
- .html_safe % { terms_link_start: terms_link_start, ai_docs_link_start: ai_docs_link_start, link_end: '</a>'.html_safe }
- # rubocop:enable Style/FormatString
- # rubocop:enable Layout/LineLength
- end
-
- private
-
- # rubocop:disable Gitlab/DocUrl
- # We want to link SaaS docs for flexibility for every URL related to Code Suggestions on Self Managed.
- # We expect to update docs often during the Beta and we want to point user to the most up to date information.
- def code_suggestions_docs_url
- 'https://docs.gitlab.com/ee/user/project/repository/code_suggestions.html'
- end
-
- def code_suggestions_agreement_url
- 'https://about.gitlab.com/handbook/legal/testing-agreement/'
- end
-
- def code_suggestions_ai_docs_url
- 'https://docs.gitlab.com/ee/user/ai_features.html#third-party-services'
- end
-
- def code_suggestions_pat_docs_url
- 'https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token'
- end
- # rubocop:enable Gitlab/DocUrl
-
- def code_suggestions_link_start(url)
- "<a href=\"#{url}\" target=\"_blank\" rel=\"noopener noreferrer\">".html_safe
- end
end
end
end
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb
index 6af81e2fa06..68bc9970316 100644
--- a/app/helpers/application_settings_helper.rb
+++ b/app/helpers/application_settings_helper.rb
@@ -218,7 +218,6 @@ module ApplicationSettingsHelper
:admin_mode,
:after_sign_out_path,
:after_sign_up_text,
- :ai_access_token,
:akismet_api_key,
:akismet_enabled,
:allow_local_requests_from_hooks_and_services,
@@ -310,7 +309,6 @@ module ApplicationSettingsHelper
:inactive_projects_delete_after_months,
:inactive_projects_min_size_mb,
:inactive_projects_send_warning_email_after_months,
- :instance_level_code_suggestions_enabled,
:invisible_captcha_enabled,
:jira_connect_application_key,
:jira_connect_public_key_storage_enabled,
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 2f6006ce018..94e93404385 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -726,10 +726,6 @@ class ApplicationSetting < MainClusterwide::ApplicationRecord
allow_nil: false,
inclusion: { in: [true, false], message: N_('must be a boolean value') }
- validates :ai_access_token,
- presence: { message: N_("is required to enable Code Suggestions") },
- if: :instance_level_code_suggestions_enabled
-
validates :package_registry_allow_anyone_to_pull_option,
inclusion: { in: [true, false], message: N_('must be a boolean value') }
@@ -968,5 +964,4 @@ class ApplicationSetting < MainClusterwide::ApplicationRecord
end
end
-ApplicationSetting.prepend(ApplicationSettingMaskedAttrs)
ApplicationSetting.prepend_mod_with('ApplicationSetting')
diff --git a/app/models/concerns/application_setting_masked_attrs.rb b/app/models/concerns/application_setting_masked_attrs.rb
deleted file mode 100644
index 14a7185e39e..00000000000
--- a/app/models/concerns/application_setting_masked_attrs.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# frozen_string_literal: true
-
-# Similar to MASK_PASSWORD mechanism we do for EE, see:
-# https://gitlab.com/gitlab-org/gitlab/-/blob/463bb1f855d71fadef931bd50f1692ee04f211a8/ee/app/models/ee/application_setting.rb#L15
-# but for non-EE attributes.
-module ApplicationSettingMaskedAttrs
- MASK = '*****'
-
- def ai_access_token=(value)
- return if value == MASK
-
- super
- end
-end
diff --git a/app/services/metrics/dashboard/custom_dashboard_service.rb b/app/services/metrics/dashboard/custom_dashboard_service.rb
deleted file mode 100644
index bde8e86851a..00000000000
--- a/app/services/metrics/dashboard/custom_dashboard_service.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# frozen_string_literal: true
-
-# Searches a projects repository for a metrics dashboard and formats the output.
-# Expects any custom dashboards will be located in `.gitlab/dashboards`
-# Use Gitlab::Metrics::Dashboard::Finder to retrive dashboards.
-module Metrics
- module Dashboard
- class CustomDashboardService < ::Metrics::Dashboard::BaseService
- class << self
- def valid_params?(params)
- params[:dashboard_path].present?
- end
-
- def all_dashboard_paths(project)
- project.repository.user_defined_metrics_dashboard_paths
- .map do |filepath|
- {
- path: filepath,
- display_name: name_for_path(filepath),
- default: false,
- system_dashboard: false,
- out_of_the_box_dashboard: out_of_the_box_dashboard?
- }
- end
- end
-
- # Grabs the filepath after the base directory.
- def name_for_path(filepath)
- filepath.delete_prefix("#{Gitlab::Metrics::Dashboard::RepoDashboardFinder::DASHBOARD_ROOT}/")
- end
- end
-
- private
-
- # Searches the project repo for a custom-defined dashboard.
- def get_raw_dashboard
- yml = Gitlab::Metrics::Dashboard::RepoDashboardFinder.read_dashboard(project, dashboard_path)
-
- load_yaml(yml)
- end
-
- def cache_key
- "project_#{project.id}_metrics_dashboard_#{dashboard_path}"
- end
-
- def sequence
- [
- ::Gitlab::Metrics::Dashboard::Stages::CustomDashboardMetricsInserter
- ] + super
- end
- end
- end
-end
diff --git a/app/services/metrics/dashboard/update_dashboard_service.rb b/app/services/metrics/dashboard/update_dashboard_service.rb
deleted file mode 100644
index 0574cb15e96..00000000000
--- a/app/services/metrics/dashboard/update_dashboard_service.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-# frozen_string_literal: true
-
-# Updates the content of a specified dashboard in .yml file inside `.gitlab/dashboards`
-module Metrics
- module Dashboard
- class UpdateDashboardService < ::BaseService
- include Stepable
-
- ALLOWED_FILE_TYPE = '.yml'
- USER_DASHBOARDS_DIR = ::Gitlab::Metrics::Dashboard::RepoDashboardFinder::DASHBOARD_ROOT
-
- steps :check_push_authorized,
- :check_branch_name,
- :check_file_type,
- :update_file,
- :create_merge_request
-
- def execute
- execute_steps
- end
-
- private
-
- def check_push_authorized(result)
- return error(_('You are not allowed to push into this branch. Create another branch or open a merge request.'), :forbidden) unless push_authorized?
-
- success(result)
- end
-
- def check_branch_name(result)
- return error(_('There was an error updating the dashboard, branch name is invalid.'), :bad_request) unless valid_branch_name?
- return error(_('There was an error updating the dashboard, branch named: %{branch} already exists.') % { branch: params[:branch] }, :bad_request) unless new_or_default_branch?
-
- success(result)
- end
-
- def check_file_type(result)
- return error(_('The file name should have a .yml extension'), :bad_request) unless target_file_type_valid?
-
- success(result)
- end
-
- def update_file(result)
- file_update_response = ::Files::UpdateService.new(project, current_user, dashboard_attrs).execute
-
- if file_update_response[:status] == :success
- success(result.merge(file_update_response, http_status: :created, dashboard: dashboard_details))
- else
- error(file_update_response[:message], :bad_request)
- end
- end
-
- def create_merge_request(result)
- return success(result) if project.default_branch == branch
-
- merge_request_params = {
- source_branch: branch,
- target_branch: project.default_branch,
- title: params[:commit_message]
- }
- merge_request = ::MergeRequests::CreateService.new(project: project, current_user: current_user, params: merge_request_params).execute
-
- if merge_request.persisted?
- success(result.merge(merge_request: Gitlab::UrlBuilder.build(merge_request)))
- else
- error(merge_request.errors.full_messages.join(','), :bad_request)
- end
- end
-
- def push_authorized?
- Gitlab::UserAccess.new(current_user, container: project).can_push_to_branch?(branch)
- end
-
- def valid_branch_name?
- Gitlab::GitRefValidator.validate(branch)
- end
-
- def new_or_default_branch?
- !repository.branch_exists?(branch) || project.default_branch == branch
- end
-
- def target_file_type_valid?
- File.extname(params[:file_name]) == ALLOWED_FILE_TYPE
- end
-
- def dashboard_attrs
- {
- commit_message: params[:commit_message],
- file_path: update_dashboard_path,
- file_content: update_dashboard_content,
- encoding: 'text',
- branch_name: branch,
- start_branch: repository.branch_exists?(branch) ? branch : project.default_branch
- }
- end
-
- def update_dashboard_path
- File.join(USER_DASHBOARDS_DIR, file_name)
- end
-
- def file_name
- @file_name ||= File.basename(CGI.unescape(params[:file_name]))
- end
-
- def branch
- @branch ||= params[:branch]
- end
-
- def update_dashboard_content
- ::PerformanceMonitoring::PrometheusDashboard.from_json(params[:file_content]).to_yaml
- end
-
- def repository
- @repository ||= project.repository
- end
-
- def dashboard_details
- {
- path: update_dashboard_path,
- display_name: ::Metrics::Dashboard::CustomDashboardService.name_for_path(update_dashboard_path),
- default: false,
- system_dashboard: false
- }
- end
- end
- end
-end
diff --git a/app/views/admin/application_settings/_ai_access.html.haml b/app/views/admin/application_settings/_ai_access.html.haml
deleted file mode 100644
index 97f46adef51..00000000000
--- a/app/views/admin/application_settings/_ai_access.html.haml
+++ /dev/null
@@ -1,31 +0,0 @@
-- return if Gitlab.org_or_com?
-
-- expanded = integration_expanded?('ai_access')
-- token_is_present = @application_setting.ai_access_token.present?
-- token_label = token_is_present ? s_('CodeSuggestionsSM|Enter new personal access token') : s_('CodeSuggestionsSM|Personal access token')
-- token_value = token_is_present ? ApplicationSettingMaskedAttrs::MASK : ''
-
-%section.settings.no-animate#js-ai-access-settings{ class: ('expanded' if expanded) }
- .settings-header
- %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only
- = s_('CodeSuggestionsSM|Code Suggestions')
- = render Pajamas::ButtonComponent.new(button_options: { class: 'js-settings-toggle' }) do
- = expanded ? _('Collapse') : _('Expand')
- %p
- = code_suggestions_description
-
- .settings-content
- = gitlab_ui_form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-ai-access-settings'), html: { class: 'fieldset-form', id: 'ai-access-settings' } do |f|
- = form_errors(@application_setting)
-
- %fieldset
- .form-group
- = f.gitlab_ui_checkbox_component :instance_level_code_suggestions_enabled,
- s_('CodeSuggestionsSM|Enable Code Suggestions for this instance %{beta}').html_safe % { beta: gl_badge_tag(_('Beta'), variant: :neutral, size: :sm) },
- help_text: code_suggestions_agreement
- = f.label :ai_access_token, token_label, class: 'label-bold'
- = f.password_field :ai_access_token, value: token_value, autocomplete: 'on', class: 'form-control gl-form-input', aria: { describedby: 'code_suggestions_token_explanation' }
- %p.form-text.text-muted{ id: 'code_suggestions_token_explanation' }
- = code_suggestions_token_explanation
-
- = f.submit _('Save changes'), pajamas_button: true