diff options
Diffstat (limited to 'lib/api/helpers')
-rw-r--r-- | lib/api/helpers/label_helpers.rb | 15 | ||||
-rw-r--r-- | lib/api/helpers/packages/basic_auth_helpers.rb | 8 | ||||
-rw-r--r-- | lib/api/helpers/packages/conan/api_helpers.rb | 4 | ||||
-rw-r--r-- | lib/api/helpers/projects_helpers.rb | 6 | ||||
-rw-r--r-- | lib/api/helpers/runner.rb | 25 | ||||
-rw-r--r-- | lib/api/helpers/services_helpers.rb | 52 |
6 files changed, 68 insertions, 42 deletions
diff --git a/lib/api/helpers/label_helpers.rb b/lib/api/helpers/label_helpers.rb index 796b8928243..da0ee8f207e 100644 --- a/lib/api/helpers/label_helpers.rb +++ b/lib/api/helpers/label_helpers.rb @@ -5,34 +5,27 @@ module API module LabelHelpers extend Grape::API::Helpers - params :optional_label_params do - optional :description, type: String, desc: 'The description of the label' - optional :remove_on_close, type: Boolean, desc: 'Whether the label should be removed from an issue when the issue is closed' - end - params :label_create_params do requires :name, type: String, desc: 'The name of the label to be created' requires :color, type: String, desc: "The color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the allowed CSS color names" - - use :optional_label_params + optional :description, type: String, desc: 'The description of label to be created' end params :label_update_params do optional :new_name, type: String, desc: 'The new name of the label' optional :color, type: String, desc: "The new color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the allowed CSS color names" - - use :optional_label_params + optional :description, type: String, desc: 'The new description of label' end params :project_label_update_params do use :label_update_params optional :priority, type: Integer, desc: 'The priority of the label', allow_blank: true - at_least_one_of :new_name, :color, :description, :priority, :remove_on_close + at_least_one_of :new_name, :color, :description, :priority end params :group_label_update_params do use :label_update_params - at_least_one_of :new_name, :color, :description, :remove_on_close + at_least_one_of :new_name, :color, :description end def find_label(parent, id_or_title, params = { include_ancestor_groups: true }) diff --git a/lib/api/helpers/packages/basic_auth_helpers.rb b/lib/api/helpers/packages/basic_auth_helpers.rb index c32ce199dd6..6c381d85cd8 100644 --- a/lib/api/helpers/packages/basic_auth_helpers.rb +++ b/lib/api/helpers/packages/basic_auth_helpers.rb @@ -22,6 +22,14 @@ module API unauthorized_user_project || not_found! end + def unauthorized_user_group + @unauthorized_user_group ||= find_group(params[:id]) + end + + def unauthorized_user_group! + unauthorized_user_group || not_found! + end + def authorized_user_project @authorized_user_project ||= authorized_project_find! end diff --git a/lib/api/helpers/packages/conan/api_helpers.rb b/lib/api/helpers/packages/conan/api_helpers.rb index b18f52b5be6..4b6dac39348 100644 --- a/lib/api/helpers/packages/conan/api_helpers.rb +++ b/lib/api/helpers/packages/conan/api_helpers.rb @@ -155,7 +155,7 @@ module API conan_package_reference: params[:conan_package_reference] ).execute! - track_package_event('pull_package', :conan, category: 'API::ConanPackages') if params[:file_name] == ::Packages::Conan::FileMetadatum::PACKAGE_BINARY + track_package_event('pull_package', :conan, category: 'API::ConanPackages', user: current_user, project: project, namespace: project.namespace) if params[:file_name] == ::Packages::Conan::FileMetadatum::PACKAGE_BINARY present_carrierwave_file!(package_file.file) end @@ -170,7 +170,7 @@ module API def track_push_package_event if params[:file_name] == ::Packages::Conan::FileMetadatum::PACKAGE_BINARY && params[:file].size > 0 # rubocop: disable Style/ZeroLengthPredicate - track_package_event('push_package', :conan, category: 'API::ConanPackages') + track_package_event('push_package', :conan, category: 'API::ConanPackages', user: current_user, project: project, namespace: project.namespace) end end diff --git a/lib/api/helpers/projects_helpers.rb b/lib/api/helpers/projects_helpers.rb index d9c0b4f67c8..69a83043617 100644 --- a/lib/api/helpers/projects_helpers.rb +++ b/lib/api/helpers/projects_helpers.rb @@ -16,6 +16,7 @@ module API optional :build_coverage_regex, type: String, desc: 'Test coverage parsing' optional :ci_config_path, type: String, desc: 'The path to CI config file. Defaults to `.gitlab-ci.yml`' optional :service_desk_enabled, type: Boolean, desc: 'Disable or enable the service desk' + optional :keep_latest_artifact, type: Boolean, desc: 'Indicates if the latest artifact should be kept for this project.' # TODO: remove in API v5, replaced by *_access_level optional :issues_enabled, type: Boolean, desc: 'Flag indication if the issue tracker is enabled' @@ -51,7 +52,8 @@ module API optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed' optional :allow_merge_on_skipped_pipeline, type: Boolean, desc: 'Allow to merge if pipeline is skipped' optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved' - optional :tag_list, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The list of tags for a project' + optional :tag_list, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'Deprecated: Use :topics instead' + optional :topics, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The list of topics for a project' # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960 optional :avatar, type: File, desc: 'Avatar image for project' # rubocop:disable Scalability/FileUploads optional :printing_merge_request_link_enabled, type: Boolean, desc: 'Show link to create/view merge request when pushing from the command line' @@ -146,6 +148,7 @@ module API :shared_runners_enabled, :snippets_access_level, :tag_list, + :topics, :visibility, :wiki_access_level, :avatar, @@ -154,6 +157,7 @@ module API :compliance_framework_setting, :packages_enabled, :service_desk_enabled, + :keep_latest_artifact, # TODO: remove in API v5, replaced by *_access_level :issues_enabled, diff --git a/lib/api/helpers/runner.rb b/lib/api/helpers/runner.rb index 6f25cf507bc..9ec9b5e1e35 100644 --- a/lib/api/helpers/runner.rb +++ b/lib/api/helpers/runner.rb @@ -25,6 +25,7 @@ module API return get_runner_ip unless params['info'].present? attributes_for_keys(%w(name version revision platform architecture), params['info']) + .merge(get_runner_config_from_request) .merge(get_runner_ip) end @@ -33,8 +34,15 @@ module API end def current_runner + token = params[:token] + + if token + ::Gitlab::Database::LoadBalancing::RackMiddleware + .stick_or_unstick(env, :runner, token) + end + strong_memoize(:current_runner) do - ::Ci::Runner.find_by_token(params[:token].to_s) + ::Ci::Runner.find_by_token(token.to_s) end end @@ -64,8 +72,15 @@ module API end def current_job + id = params[:id] + + if id + ::Gitlab::Database::LoadBalancing::RackMiddleware + .stick_or_unstick(env, :build, id) + end + strong_memoize(:current_job) do - ::Ci::Build.find_by_id(params[:id]) + ::Ci::Build.find_by_id(id) end end @@ -91,6 +106,12 @@ module API def track_ci_minutes_usage!(_build, _runner) # noop: overridden in EE end + + private + + def get_runner_config_from_request + { config: attributes_for_keys(%w(gpus), params.dig('info', 'config')) } + end end end end diff --git a/lib/api/helpers/services_helpers.rb b/lib/api/helpers/services_helpers.rb index d123db8e3df..ca13ea0789a 100644 --- a/lib/api/helpers/services_helpers.rb +++ b/lib/api/helpers/services_helpers.rb @@ -777,41 +777,41 @@ module API ::Integrations::Asana, ::Integrations::Assembla, ::Integrations::Bamboo, + ::Integrations::Bugzilla, + ::Integrations::Buildkite, ::Integrations::Campfire, ::Integrations::Confluence, + ::Integrations::CustomIssueTracker, ::Integrations::Datadog, + ::Integrations::Discord, + ::Integrations::DroneCi, ::Integrations::EmailsOnPush, - ::BugzillaService, - ::BuildkiteService, - ::CustomIssueTrackerService, - ::DiscordService, - ::DroneCiService, - ::EwmService, - ::ExternalWikiService, - ::FlowdockService, - ::HangoutsChatService, - ::IrkerService, - ::JenkinsService, - ::JiraService, - ::MattermostSlashCommandsService, - ::SlackSlashCommandsService, - ::PackagistService, - ::PipelinesEmailService, - ::PivotaltrackerService, - ::PrometheusService, - ::PushoverService, - ::RedmineService, - ::YoutrackService, - ::SlackService, - ::MattermostService, - ::MicrosoftTeamsService, - ::TeamcityService + ::Integrations::Ewm, + ::Integrations::ExternalWiki, + ::Integrations::Flowdock, + ::Integrations::HangoutsChat, + ::Integrations::Irker, + ::Integrations::Jenkins, + ::Integrations::Jira, + ::Integrations::Mattermost, + ::Integrations::MattermostSlashCommands, + ::Integrations::MicrosoftTeams, + ::Integrations::Packagist, + ::Integrations::PipelinesEmail, + ::Integrations::Pivotaltracker, + ::Integrations::Pushover, + ::Integrations::Redmine, + ::Integrations::Slack, + ::Integrations::SlackSlashCommands, + ::Integrations::Teamcity, + ::Integrations::Youtrack, + ::PrometheusService ] end def self.development_service_classes [ - ::MockCiService, + ::Integrations::MockCi, ::MockMonitoringService ] end |