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