gitlab-org--gitlab-foss/app/models/ci/variable.rb

20 lines
564 B
Ruby
Raw Normal View History

2015-08-26 01:42:46 +00:00
module Ci
class Variable < ActiveRecord::Base
extend Ci::Model
2015-12-04 11:55:23 +00:00
belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id
2015-08-26 01:42:46 +00:00
2015-12-04 11:55:23 +00:00
validates_uniqueness_of :key, scope: :gl_project_id
validates :key,
presence: true,
length: { within: 0..255 },
format: { with: /\A[a-zA-Z0-9_]+\z/,
message: "can contain only letters, digits and '_'." }
2015-08-26 01:42:46 +00:00
attr_encrypted :value,
mode: :per_attribute_iv_and_salt,
key: Gitlab::Application.secrets.db_key_base,
algorithm: 'aes-256-cbc'
2015-08-26 01:42:46 +00:00
end
end