project_import_data.rb 940 Bytes
Newer Older
1
2
# == Schema Information
#
Stan Hu's avatar
Stan Hu committed
3
# Table name: project_import_data
4
#
Zeger-Jan van de Weg's avatar
Zeger-Jan van de Weg committed
5
6
7
8
#  id                         :integer          not null, primary key
#  project_id                 :integer
#  data                       :text
#  encrypted_credentials      :text
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
9
10
#  encrypted_credentials_iv   :string
#  encrypted_credentials_salt :string
11
12
13
14
15
16
#

require 'carrierwave/orm/activerecord'

class ProjectImportData < ActiveRecord::Base
  belongs_to :project
17
18
19
20
21
  attr_encrypted :credentials,
                 key: Gitlab::Application.secrets.db_key_base,
                 marshal: true,
                 encode: true,
                 mode: :per_attribute_iv_and_salt
22

23
24
25
  serialize :data, JSON

  validates :project, presence: true
James Lopez's avatar
James Lopez committed
26

27
28
29
  before_validation :symbolize_credentials

  def symbolize_credentials
30
    # bang doesn't work here - attr_encrypted makes it not to work
James Lopez's avatar
James Lopez committed
31
    self.credentials = self.credentials.deep_symbolize_keys unless self.credentials.blank?
James Lopez's avatar
James Lopez committed
32
  end
33
end