Welcome to mirror list, hosted at ThFree Co, Russian Federation.

environment.rb « seed « pipeline « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b20dc383419ffc100924eb2dd1749ee875d06927 (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
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

module Gitlab
  module Ci
    module Pipeline
      module Seed
        class Environment < Seed::Base
          attr_reader :job

          def initialize(job)
            @job = job
          end

          def to_resource
            environments.safe_find_or_create_by(name: expanded_environment_name) do |environment|
              environment.auto_stop_in = auto_stop_in
            end
          end

          private

          def environments
            job.project.environments
          end

          def auto_stop_in
            if Feature.enabled?(:environment_auto_stop_start_on_create)
              job.environment_auto_stop_in
            end
          end

          def expanded_environment_name
            job.expanded_environment_name
          end
        end
      end
    end
  end
end