diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-03-25 05:04:39 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-03-27 09:53:36 +0300 |
commit | f93de42974c8250bc4ee7f7aee543a3bc9a029e1 (patch) | |
tree | fc272c8accdc1d9307e0d44856020c2841ce06b8 | |
parent | 912f9f364ae0075ebd397937bc357f5988367214 (diff) |
Add Paas::Cluster model
There are a lot of similaritis with Clusters::Cluster so we may end up
re-using that model instead
-rw-r--r-- | app/models/paas/cluster.rb | 16 | ||||
-rw-r--r-- | db/migrate/20190325014456_create_paas_clusters.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 12 | ||||
-rw-r--r-- | spec/models/paas/cluster_spec.rb | 9 |
4 files changed, 53 insertions, 1 deletions
diff --git a/app/models/paas/cluster.rb b/app/models/paas/cluster.rb new file mode 100644 index 00000000000..02d73ea75be --- /dev/null +++ b/app/models/paas/cluster.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Paas + class Cluster < ActiveRecord::Base + self.table_name = 'paas_clusters' + + attr_encrypted :token, + mode: :per_attribute_iv, + key: Settings.attr_encrypted_db_key_base_truncated, + algorithm: 'aes-256-cbc' + + validates :name, presence: true + validates :api_url, public_url: true, presence: true + validates :token, presence: true + end +end diff --git a/db/migrate/20190325014456_create_paas_clusters.rb b/db/migrate/20190325014456_create_paas_clusters.rb new file mode 100644 index 00000000000..1f04de9c39a --- /dev/null +++ b/db/migrate/20190325014456_create_paas_clusters.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class CreatePaasClusters < ActiveRecord::Migration[5.0] + DOWNTIME = false + + def change + create_table :paas_clusters, id: :bigserial do |t| + t.string :name, null: false + t.text :api_url, null: false + t.text :ca_cert + t.text :encrypted_token + t.string :encrypted_token_iv + + t.timestamps_with_timezone null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index dda0445e3f2..790f88a589e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190301182457) do +ActiveRecord::Schema.define(version: 20190325014456) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1512,6 +1512,16 @@ ActiveRecord::Schema.define(version: 20190301182457) do t.index ["access_grant_id"], name: "index_oauth_openid_requests_on_access_grant_id", using: :btree end + create_table "paas_clusters", id: :bigserial, force: :cascade do |t| + t.string "name", null: false + t.text "api_url", null: false + t.text "ca_cert" + t.text "encrypted_token" + t.string "encrypted_token_iv" + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + end + create_table "pages_domains", force: :cascade do |t| t.integer "project_id" t.text "certificate" diff --git a/spec/models/paas/cluster_spec.rb b/spec/models/paas/cluster_spec.rb new file mode 100644 index 00000000000..56c7ded5931 --- /dev/null +++ b/spec/models/paas/cluster_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Paas::Cluster, type: :model do + it { is_expected.to validate_presence_of(:name) } + it { is_expected.to validate_presence_of(:api_url) } + it { is_expected.to validate_presence_of(:token) } +end |