2019-12-21 20:55:43 +05:30
|
|
|
# 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
|
2021-01-29 00:20:46 +05:30
|
|
|
environments.safe_find_or_create_by(name: expanded_environment_name) do |environment|
|
2021-04-17 20:07:23 +05:30
|
|
|
# Initialize the attributes at creation
|
2021-01-29 00:20:46 +05:30
|
|
|
environment.auto_stop_in = auto_stop_in
|
2021-04-17 20:07:23 +05:30
|
|
|
environment.tier = deployment_tier
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
def environments
|
|
|
|
job.project.environments
|
|
|
|
end
|
|
|
|
|
|
|
|
def auto_stop_in
|
2021-02-22 17:27:13 +05:30
|
|
|
job.environment_auto_stop_in
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
def deployment_tier
|
|
|
|
job.environment_deployment_tier
|
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
def expanded_environment_name
|
|
|
|
job.expanded_environment_name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|