diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-20 00:09:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-20 00:09:01 +0300 |
commit | 8acf72a1d95677e37ca2c3a8bea3e65139443527 (patch) | |
tree | dcb7f53c394ff29b5bee9bc1a60f19c4cda29b40 /lib | |
parent | 91aa6c6479ec883328ae656ab70d6fc3824b5673 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/jwt_v2.rb | 22 | ||||
-rw-r--r-- | lib/gitlab/ci/project_config.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/ci/project_config/auto_devops.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/project_config/bridge.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/ci/project_config/external_project.rb | 11 | ||||
-rw-r--r-- | lib/gitlab/ci/project_config/parameter.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/project_config/remote.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/project_config/repository.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/project_config/source.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/database/background_migration/batched_migration.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/source.rb | 6 |
11 files changed, 8 insertions, 87 deletions
diff --git a/lib/gitlab/ci/jwt_v2.rb b/lib/gitlab/ci/jwt_v2.rb index 34549f4e019..aff30455d09 100644 --- a/lib/gitlab/ci/jwt_v2.rb +++ b/lib/gitlab/ci/jwt_v2.rb @@ -45,30 +45,10 @@ module Gitlab super.merge( runner_id: runner&.id, runner_environment: runner_environment, - sha: pipeline.sha, - pipeline_ref: pipeline_ref, - pipeline_sha: pipeline.repository_source? ? pipeline.sha : nil + sha: pipeline.sha ) end - def pipeline_ref - project_config = Gitlab::Ci::ProjectConfig.new( - project: project, - sha: pipeline.sha, - pipeline_source: pipeline.source&.to_sym, - pipeline_source_bridge: pipeline.source_bridge, - pipeline: pipeline - ) - - project_config&.url - - # Errors are rescued to mitigate risk. This can be removed if no errors are observed. - # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/117923#note_1387660746 for context. - rescue StandardError => e - Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, pipeline_id: pipeline.id) - nil - end - def runner_environment return unless runner diff --git a/lib/gitlab/ci/project_config.rb b/lib/gitlab/ci/project_config.rb index 0eed673f266..00b2ad58428 100644 --- a/lib/gitlab/ci/project_config.rb +++ b/lib/gitlab/ci/project_config.rb @@ -21,14 +21,11 @@ module Gitlab ProjectConfig::AutoDevops ].freeze - def initialize( - project:, sha:, custom_content: nil, pipeline_source: nil, - pipeline_source_bridge: nil, pipeline: nil - ) - @config = find_config(project, sha, custom_content, pipeline_source, pipeline_source_bridge, pipeline) + def initialize(project:, sha:, custom_content: nil, pipeline_source: nil, pipeline_source_bridge: nil) + @config = find_config(project, sha, custom_content, pipeline_source, pipeline_source_bridge) end - delegate :content, :source, :url, to: :@config, allow_nil: true + delegate :content, :source, to: :@config, allow_nil: true delegate :internal_include_prepended?, to: :@config def exists? @@ -37,9 +34,9 @@ module Gitlab private - def find_config(project, sha, custom_content, pipeline_source, pipeline_source_bridge, pipeline) + def find_config(project, sha, custom_content, pipeline_source, pipeline_source_bridge) sources.each do |source| - config = source.new(project, sha, custom_content, pipeline_source, pipeline_source_bridge, pipeline) + config = source.new(project, sha, custom_content, pipeline_source, pipeline_source_bridge) return config if config.exists? end diff --git a/lib/gitlab/ci/project_config/auto_devops.rb b/lib/gitlab/ci/project_config/auto_devops.rb index 24e19a1183b..c5f010ebaea 100644 --- a/lib/gitlab/ci/project_config/auto_devops.rb +++ b/lib/gitlab/ci/project_config/auto_devops.rb @@ -21,10 +21,6 @@ module Gitlab :auto_devops_source end - def url - Gitlab::Source.blob_url('lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml') - end - private def template_name diff --git a/lib/gitlab/ci/project_config/bridge.rb b/lib/gitlab/ci/project_config/bridge.rb index 4c64e43b8a5..c342ab2c215 100644 --- a/lib/gitlab/ci/project_config/bridge.rb +++ b/lib/gitlab/ci/project_config/bridge.rb @@ -13,19 +13,6 @@ module Gitlab def source :bridge_source end - - def url - source_pipeline = pipeline_source_bridge.pipeline - - Repository.new( - source_pipeline.project, - source_pipeline.sha, - custom_content, - source_pipeline.source.to_sym, - source_pipeline.source_bridge, - source_pipeline - ).url - end end end end diff --git a/lib/gitlab/ci/project_config/external_project.rb b/lib/gitlab/ci/project_config/external_project.rb index c65d1e658b9..0afdab23886 100644 --- a/lib/gitlab/ci/project_config/external_project.rb +++ b/lib/gitlab/ci/project_config/external_project.rb @@ -25,17 +25,6 @@ module Gitlab :external_project_source end - def url - path_file, path_project, ref = extract_location_tokens - ref ||= 'HEAD' - - namespace, _, project = path_project.partition('/') - return unless namespace.present? && project.present? - - blob = File.join(ref, path_file) - Rails.application.routes.url_helpers.namespace_project_blob_url(namespace, project, blob) - end - private # Example: path/to/.gitlab-ci.yml@another-group/another-project diff --git a/lib/gitlab/ci/project_config/parameter.rb b/lib/gitlab/ci/project_config/parameter.rb index 4a7b68c59e8..69e699c27f1 100644 --- a/lib/gitlab/ci/project_config/parameter.rb +++ b/lib/gitlab/ci/project_config/parameter.rb @@ -15,10 +15,6 @@ module Gitlab def source :parameter_source end - - def url - nil - end end end end diff --git a/lib/gitlab/ci/project_config/remote.rb b/lib/gitlab/ci/project_config/remote.rb index dabb107aee7..19cbf8e9c1e 100644 --- a/lib/gitlab/ci/project_config/remote.rb +++ b/lib/gitlab/ci/project_config/remote.rb @@ -19,10 +19,6 @@ module Gitlab def source :remote_source end - - def url - ci_config_path - end end end end diff --git a/lib/gitlab/ci/project_config/repository.rb b/lib/gitlab/ci/project_config/repository.rb index e5afb2565db..272425fd546 100644 --- a/lib/gitlab/ci/project_config/repository.rb +++ b/lib/gitlab/ci/project_config/repository.rb @@ -20,10 +20,6 @@ module Gitlab :repository_source end - def url - Rails.application.routes.url_helpers.project_blob_url(project, File.join(sha, ci_config_path)) - end - private def file_in_repository? diff --git a/lib/gitlab/ci/project_config/source.rb b/lib/gitlab/ci/project_config/source.rb index 195a77f2f3d..9a4a6394fa1 100644 --- a/lib/gitlab/ci/project_config/source.rb +++ b/lib/gitlab/ci/project_config/source.rb @@ -6,13 +6,12 @@ module Gitlab class Source include Gitlab::Utils::StrongMemoize - def initialize(project, sha, custom_content, pipeline_source, pipeline_source_bridge, pipeline) + def initialize(project, sha, custom_content, pipeline_source, pipeline_source_bridge) @project = project @sha = sha @custom_content = custom_content @pipeline_source = pipeline_source @pipeline_source_bridge = pipeline_source_bridge - @pipeline = pipeline end def exists? @@ -34,14 +33,9 @@ module Gitlab raise NotImplementedError end - # Used to populate the pipeline_ref claim in Ci::JwtV2 - def url - raise NotImplementedError - end - private - attr_reader :project, :sha, :custom_content, :pipeline_source, :pipeline_source_bridge, :pipeline + attr_reader :project, :sha, :custom_content, :pipeline_source, :pipeline_source_bridge def ci_config_path @ci_config_path ||= project.ci_config_path_or_default diff --git a/lib/gitlab/database/background_migration/batched_migration.rb b/lib/gitlab/database/background_migration/batched_migration.rb index a883996a5c5..2c1a14c56f6 100644 --- a/lib/gitlab/database/background_migration/batched_migration.rb +++ b/lib/gitlab/database/background_migration/batched_migration.rb @@ -92,10 +92,6 @@ module Gitlab for_configuration(gitlab_schema, job_class_name, table_name, column_name, job_arguments).first end - def self.active_migration(connection:) - active_migrations_distinct_on_table(connection: connection, limit: 1).first - end - def self.find_executable(id, connection:) for_gitlab_schema(Gitlab::Database.gitlab_schemas_for_connection(connection)) .executable.find_by_id(id) diff --git a/lib/gitlab/source.rb b/lib/gitlab/source.rb index 0944b5cfc51..0e9fb39156d 100644 --- a/lib/gitlab/source.rb +++ b/lib/gitlab/source.rb @@ -19,12 +19,6 @@ module Gitlab Gitlab::Utils.append_path(host_url, path) end - def blob_url(source_file_path) - blob_id = File.join(ref, source_file_path) - - host_url + url_helpers.namespace_project_blob_path(group, project, blob_id) - end - private def host_url |