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

40 lines
846 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
if Feature.enabled?(:environment_auto_stop_start_on_create)
job.environment_auto_stop_in
end
end
2019-12-21 20:55:43 +05:30
def expanded_environment_name
job.expanded_environment_name
end
end
end
end
end
end