summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/pipeline/seed/stage.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-21 14:40:27 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-21 14:40:27 +0100
commitdb3d0319699cf39e55f79678969bfdb4cc8d2924 (patch)
treeca0551e8c20c8203a2bd744b84f73e0c69d26e71 /lib/gitlab/ci/pipeline/seed/stage.rb
parent9b5a912f9377a77e52e9acdf7471acd27c709264 (diff)
downloadgitlab-ce-db3d0319699cf39e55f79678969bfdb4cc8d2924.tar.gz
Evaluate only/except policies outside of YAML processor
Diffstat (limited to 'lib/gitlab/ci/pipeline/seed/stage.rb')
-rw-r--r--lib/gitlab/ci/pipeline/seed/stage.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/gitlab/ci/pipeline/seed/stage.rb b/lib/gitlab/ci/pipeline/seed/stage.rb
index 6d824e52334..bed514c02ca 100644
--- a/lib/gitlab/ci/pipeline/seed/stage.rb
+++ b/lib/gitlab/ci/pipeline/seed/stage.rb
@@ -8,11 +8,11 @@ module Gitlab
delegate :size, to: :seeds
delegate :dig, to: :seeds
- def initialize(pipeline, name, builds)
+ def initialize(pipeline, attributes)
@pipeline = pipeline
- @name = name
+ @attributes = attributes
- @seeds = builds.map do |attributes|
+ @seeds = attributes.fetch(:builds).map do |attributes|
Seed::Build.new(@pipeline, attributes)
end
end
@@ -22,17 +22,23 @@ module Gitlab
end
def attributes
- { name: @name,
+ { name: @attributes.fetch(:name),
pipeline: @pipeline,
project: @pipeline.project }
end
+ # TODO specs
+ #
+ def included?
+ @seeds.any?(&:included?)
+ end
+
def to_resource
- ::Ci::Stage.new(attributes).tap do |stage|
+ @stage ||= ::Ci::Stage.new(attributes).tap do |stage|
@seeds.each do |seed|
- seed.to_resource.tap do |build|
- stage.builds << build
- end
+ next unless seed.included?
+
+ stage.builds << seed.to_resource
end
end
end