diff options
Diffstat (limited to 'app/serializers/ci')
-rw-r--r-- | app/serializers/ci/downloadable_artifact_entity.rb | 17 | ||||
-rw-r--r-- | app/serializers/ci/downloadable_artifact_serializer.rb | 7 | ||||
-rw-r--r-- | app/serializers/ci/pipeline_entity.rb | 2 |
3 files changed, 25 insertions, 1 deletions
diff --git a/app/serializers/ci/downloadable_artifact_entity.rb b/app/serializers/ci/downloadable_artifact_entity.rb new file mode 100644 index 00000000000..1f3885f0715 --- /dev/null +++ b/app/serializers/ci/downloadable_artifact_entity.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Ci + class DownloadableArtifactEntity < Grape::Entity + include RequestAwareEntity + + expose :artifacts do |pipeline, options| + artifacts = pipeline.downloadable_artifacts + + if Feature.enabled?(:non_public_artifacts) + artifacts = artifacts.select { |artifact| can?(request.current_user, :read_job_artifacts, artifact.job) } + end + + BuildArtifactEntity.represent(artifacts, options.merge(project: pipeline.project)) + end + end +end diff --git a/app/serializers/ci/downloadable_artifact_serializer.rb b/app/serializers/ci/downloadable_artifact_serializer.rb new file mode 100644 index 00000000000..fc4c9fa558e --- /dev/null +++ b/app/serializers/ci/downloadable_artifact_serializer.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Ci + class DownloadableArtifactSerializer < BaseSerializer + entity DownloadableArtifactEntity + end +end diff --git a/app/serializers/ci/pipeline_entity.rb b/app/serializers/ci/pipeline_entity.rb index 743643a978f..fa0e904fbde 100644 --- a/app/serializers/ci/pipeline_entity.rb +++ b/app/serializers/ci/pipeline_entity.rb @@ -121,4 +121,4 @@ class Ci::PipelineEntity < Grape::Entity end end -Ci::PipelineEntity.prepend_if_ee('EE::Ci::PipelineEntity') +Ci::PipelineEntity.prepend_mod_with('Ci::PipelineEntity') |