2015-08-26 01:42:46 +00:00
|
|
|
module Ci
|
|
|
|
class Variable < ActiveRecord::Base
|
|
|
|
extend Ci::Model
|
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
|
|
|
|
2016-01-07 12:49:38 +00:00
|
|
|
validates :key,
|
|
|
|
presence: true,
|
2017-03-17 23:06:11 +00:00
|
|
|
uniqueness: { scope: :project_id },
|
2016-12-02 12:54:57 +00:00
|
|
|
length: { maximum: 255 },
|
2016-01-07 12:49:38 +00:00
|
|
|
format: { with: /\A[a-zA-Z0-9_]+\z/,
|
|
|
|
message: "can contain only letters, digits and '_'." }
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2016-09-09 01:01:49 +00:00
|
|
|
scope :order_key_asc, -> { reorder(key: :asc) }
|
|
|
|
|
|
|
|
attr_encrypted :value,
|
2016-05-19 18:55:25 +00:00
|
|
|
mode: :per_attribute_iv_and_salt,
|
2016-06-28 07:55:19 +00:00
|
|
|
insecure_mode: true,
|
2016-05-19 18:55:25 +00:00
|
|
|
key: Gitlab::Application.secrets.db_key_base,
|
|
|
|
algorithm: 'aes-256-cbc'
|
2017-05-26 17:46:57 +00:00
|
|
|
|
|
|
|
def to_runner_variable
|
|
|
|
{ key: key, value: value, public: false }
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|