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
|
2020-03-18 08:09:13 -04:00
|
|
|
include Ci::HasVariable
|
2017-05-03 14:51:55 -04:00
|
|
|
include Presentable
|
2020-03-18 08:09:13 -04:00
|
|
|
include Ci::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) }
|
2020-07-08 05:09:17 -04:00
|
|
|
scope :by_key, -> (key) { where(key: key) }
|
|
|
|
scope :by_environment_scope, -> (environment_scope) { where(environment_scope: environment_scope) }
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
end
|