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: c8795840e5fa7d311d2d4ba0ad82f668def1d4d1 (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
40
41
42
43
# 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|
              # Initialize the attributes at creation
              environment.auto_stop_in = auto_stop_in
              environment.tier = deployment_tier
            end
          end

          private

          def environments
            job.project.environments
          end

          def auto_stop_in
            job.environment_auto_stop_in
          end

          def deployment_tier
            job.environment_deployment_tier
          end

          def expanded_environment_name
            job.expanded_environment_name
          end
        end
      end
    end
  end
end