2017-08-24 11:01:33 +00:00
|
|
|
class ProjectAutoDevops < ActiveRecord::Base
|
|
|
|
belongs_to :project
|
2017-09-04 13:44:46 +00:00
|
|
|
|
2017-09-12 10:33:48 +00:00
|
|
|
scope :enabled, -> { where(enabled: true) }
|
|
|
|
scope :disabled, -> { where(enabled: false) }
|
|
|
|
|
2017-09-06 19:00:34 +00:00
|
|
|
validates :domain, allow_blank: true, hostname: { allow_numeric_hostname: true }
|
2017-09-06 16:57:07 +00:00
|
|
|
|
2018-02-01 22:59:14 +00:00
|
|
|
def instance_domain
|
2018-02-03 00:56:11 +00:00
|
|
|
Gitlab::CurrentSettings.auto_devops_domain
|
2018-02-01 22:59:14 +00:00
|
|
|
end
|
|
|
|
|
2017-09-16 13:02:37 +00:00
|
|
|
def has_domain?
|
2018-02-01 22:59:14 +00:00
|
|
|
domain.present? || instance_domain.present?
|
2017-09-16 13:02:37 +00:00
|
|
|
end
|
|
|
|
|
2018-03-13 13:00:14 +00:00
|
|
|
def predefined_variables
|
|
|
|
Gitlab::Ci::Variables::Collection.new.tap do |variables|
|
2018-03-13 14:26:16 +00:00
|
|
|
if has_domain?
|
|
|
|
variables.append(key: 'AUTO_DEVOPS_DOMAIN',
|
|
|
|
value: domain.presence || instance_domain)
|
|
|
|
end
|
2018-03-13 13:00:14 +00:00
|
|
|
end
|
2017-09-06 16:57:07 +00:00
|
|
|
end
|
2017-08-24 11:01:33 +00:00
|
|
|
end
|