diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 21:08:08 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 21:08:08 +0000 |
commit | e0b84f4ba4b44c8ecf00be97843c40df2550b74c (patch) | |
tree | 7cecae4276358dd46d7fa15f84068f7b4c626089 /lib | |
parent | 73391dcc368ef846c2960c1d0ef5e64ca78e1bee (diff) | |
download | gitlab-ce-e0b84f4ba4b44c8ecf00be97843c40df2550b74c.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 12 | ||||
-rw-r--r-- | lib/api/helpers/projects_helpers.rb | 12 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml | 1 | ||||
-rw-r--r-- | lib/gitlab/database_importers/self_monitoring/project/delete_service.rb | 60 |
4 files changed, 85 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index c28d6797c56..e6803d48a47 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -178,6 +178,15 @@ module API expose :only_protected_branches end + class ContainerExpirationPolicy < Grape::Entity + expose :cadence + expose :enabled + expose :keep_n + expose :older_than + expose :name_regex + expose :next_run_at + end + class ProjectImportStatus < ProjectIdentity expose :import_status @@ -276,6 +285,8 @@ module API expose :owner, using: Entities::UserBasic, unless: ->(project, options) { project.group } expose :resolve_outdated_diff_discussions expose :container_registry_enabled + expose :container_expiration_policy, using: Entities::ContainerExpirationPolicy, + if: -> (project, _) { project.container_expiration_policy } # Expose old field names with the new permissions methods to keep API compatible # TODO: remove in API v5, replaced by *_access_level @@ -341,6 +352,7 @@ module API # MR describing the solution: https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/20555 super(projects_relation).preload(:group) .preload(:ci_cd_settings) + .preload(:container_expiration_policy) .preload(:auto_devops) .preload(project_group_links: { group: :route }, fork_network: :root_project, diff --git a/lib/api/helpers/projects_helpers.rb b/lib/api/helpers/projects_helpers.rb index 0ca5b73e270..e4f943bd925 100644 --- a/lib/api/helpers/projects_helpers.rb +++ b/lib/api/helpers/projects_helpers.rb @@ -32,6 +32,9 @@ module API optional :resolve_outdated_diff_discussions, type: Boolean, desc: 'Automatically resolve merge request diffs discussions on lines changed with a push' optional :remove_source_branch_after_merge, type: Boolean, desc: 'Remove the source branch by default after merge' optional :container_registry_enabled, type: Boolean, desc: 'Flag indication if the container registry is enabled for that project' + optional :container_expiration_policy_attributes, type: Hash do + use :optional_container_expiration_policy_params + end optional :lfs_enabled, type: Boolean, desc: 'Flag indication if Git LFS is enabled for that project' optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: 'The visibility of the project.' optional :public_builds, type: Boolean, desc: 'Perform public builds' @@ -72,6 +75,14 @@ module API params :optional_update_params_ee do end + params :optional_container_expiration_policy_params do + optional :cadence, type: String, desc: 'Container expiration policy cadence for recurring job' + optional :keep_n, type: String, desc: 'Container expiration policy number of images to keep' + optional :older_than, type: String, desc: 'Container expiration policy remove images older than value' + optional :name_regex, type: String, desc: 'Container expiration policy regex for image removal' + optional :enabled, type: Boolean, desc: 'Flag indication if container expiration policy is enabled' + end + def self.update_params_at_least_one_of [ :auto_devops_enabled, @@ -84,6 +95,7 @@ module API :ci_config_path, :ci_default_git_depth, :container_registry_enabled, + :container_expiration_policy_attributes, :default_branch, :description, :autoclose_referenced_issues, diff --git a/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml b/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml index e979a6f2de1..6f270897d93 100644 --- a/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml @@ -77,6 +77,7 @@ dependency_scanning: services: [] except: variables: + - $DEPENDENCY_SCANNING_DISABLED - $DS_DISABLE_DIND == 'false' script: - /analyzer run diff --git a/lib/gitlab/database_importers/self_monitoring/project/delete_service.rb b/lib/gitlab/database_importers/self_monitoring/project/delete_service.rb new file mode 100644 index 00000000000..bce0819b700 --- /dev/null +++ b/lib/gitlab/database_importers/self_monitoring/project/delete_service.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +module Gitlab + module DatabaseImporters + module SelfMonitoring + module Project + class DeleteService < ::BaseService + include Stepable + include SelfMonitoring::Helpers + + steps :validate_self_monitoring_project_exists, + :destroy_project_owner, + :delete_project_id + + def initialize + super(nil) + end + + def execute + execute_steps + end + + private + + def validate_self_monitoring_project_exists(result) + unless project_created? || self_monitoring_project_id.present? + return error(_('Self monitoring project does not exist')) + end + + success(result) + end + + def destroy_project_owner(result) + return success(result) unless project_created? + + if self_monitoring_project.owner.destroy + success(result) + else + log_error(self_monitoring_project.errors.full_messages) + error(_('Error deleting project. Check logs for error details.')) + end + end + + def delete_project_id(result) + update_result = application_settings.update( + instance_administration_project_id: nil + ) + + if update_result + success(result) + else + log_error("Could not delete self monitoring project ID, errors: %{errors}" % { errors: application_settings.errors.full_messages }) + error(_('Could not delete project ID')) + end + end + end + end + end + end +end |