diff options
Diffstat (limited to 'lib/gitlab/ci/pipeline/seed/stage.rb')
-rw-r--r-- | lib/gitlab/ci/pipeline/seed/stage.rb | 22 |
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 |