summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/pipeline/seed/build.rb
blob: f5dbb3a1c40a1d9e42a261f78d8715fee9276d98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Gitlab
  module Ci
    module Pipeline
      module Seed
        class Build < Seed::Base
          def initialize(pipeline, attributes)
            @pipeline = pipeline
            @attributes = attributes
          end

          # TODO find a different solution
          #
          def user=(current_user)
            @attributes.merge!(user: current_user)
          end

          def attributes
            @attributes.merge(project: @pipeline.project,
                              ref: @pipeline.ref,
                              tag: @pipeline.tag,
                              trigger_request: @pipeline.legacy_trigger,
                              protected: @pipeline.protected_ref?)
          end
        end
      end
    end
  end
end