2018-08-03 07:15:25 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-26 01:42:46 +00:00
|
|
|
module Ci
|
2019-03-28 13:17:42 +00:00
|
|
|
class Variable < ApplicationRecord
|
2017-09-06 11:13:52 +00:00
|
|
|
extend Gitlab::Ci::Model
|
2017-06-26 13:03:34 +00:00
|
|
|
include HasVariable
|
2017-05-03 18:51:55 +00:00
|
|
|
include Presentable
|
2019-02-27 00:22:51 +00:00
|
|
|
include Maskable
|
2016-09-09 01:01:49 +00:00
|
|
|
|
2017-03-17 23:06:11 +00:00
|
|
|
belongs_to :project
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2018-03-17 11:17:40 +00:00
|
|
|
alias_attribute :secret_value, :value
|
|
|
|
|
2018-02-23 00:19:46 +00:00
|
|
|
validates :key, uniqueness: {
|
|
|
|
scope: [:project_id, :environment_scope],
|
|
|
|
message: "(%{value}) has already been taken"
|
|
|
|
}
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-05-31 14:45:51 +00:00
|
|
|
scope :unprotected, -> { where(protected: false) }
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|