debian-mirror-gitlab/lib/gitlab/ci/pipeline/seed/environment.rb

38 lines
756 B
Ruby
Raw Normal View History

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|
environment.auto_stop_in = auto_stop_in
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
2019-12-21 20:55:43 +05:30
def expanded_environment_name
job.expanded_environment_name
end
end
end
end
end
end