summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-07-31 21:59:04 +0900
committerShinya Maeda <shinya@gitlab.com>2017-07-31 21:59:04 +0900
commit2cfc0cb5c9fae6a44886f2e3e58786b1ad5dfed6 (patch)
treeeb9a829f6580c41cbbd77474b7475cde8d250eed
parent9a3b283402b8cc1c86802c526f19a459ce09c2e3 (diff)
downloadgitlab-ce-feature/sm/33281-persist-protected-flag-on-runner-model.tar.gz
-rw-r--r--app/models/ci/runner.rb2
-rw-r--r--app/views/projects/runners/_form.html.haml6
-rw-r--r--app/views/projects/runners/show.html.haml3
-rw-r--r--db/migrate/20170731123938_add_protected_to_ci_runners.rb15
-rw-r--r--db/schema.rb3
5 files changed, 27 insertions, 2 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index c6d23898560..765a1763b52 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -5,7 +5,7 @@ module Ci
RUNNER_QUEUE_EXPIRY_TIME = 60.minutes
ONLINE_CONTACT_TIMEOUT = 1.hour
AVAILABLE_SCOPES = %w[specific shared active paused online].freeze
- FORM_EDITABLE = %i[description tag_list active run_untagged locked].freeze
+ FORM_EDITABLE = %i[description tag_list active run_untagged locked protected].freeze
has_many :builds
has_many :runner_projects, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
diff --git a/app/views/projects/runners/_form.html.haml b/app/views/projects/runners/_form.html.haml
index 2ef1f98ba48..7dae8ecbb94 100644
--- a/app/views/projects/runners/_form.html.haml
+++ b/app/views/projects/runners/_form.html.haml
@@ -7,6 +7,12 @@
= f.check_box :active
%span.light Paused Runners don't accept new jobs
.form-group
+ = label :protected, "Protected", class: 'control-label'
+ .col-sm-10
+ .checkbox
+ = f.check_box :protected
+ %span.light This runner will only run on pipelines trigged on protected branches
+ .form-group
= label :run_untagged, 'Run untagged jobs', class: 'control-label'
.col-sm-10
.checkbox
diff --git a/app/views/projects/runners/show.html.haml b/app/views/projects/runners/show.html.haml
index 49415ba557b..e51bb299938 100644
--- a/app/views/projects/runners/show.html.haml
+++ b/app/views/projects/runners/show.html.haml
@@ -20,6 +20,9 @@
%td Active
%td= @runner.active? ? 'Yes' : 'No'
%tr
+ %td Protected
+ %td= @runner.protected? ? 'Yes' : 'No'
+ %tr
%td Can run untagged jobs
%td= @runner.run_untagged? ? 'Yes' : 'No'
%tr
diff --git a/db/migrate/20170731123938_add_protected_to_ci_runners.rb b/db/migrate/20170731123938_add_protected_to_ci_runners.rb
new file mode 100644
index 00000000000..3782e047eee
--- /dev/null
+++ b/db/migrate/20170731123938_add_protected_to_ci_runners.rb
@@ -0,0 +1,15 @@
+class AddProtectedToCiRunners < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:ci_runners, :protected, :boolean, default: false)
+ end
+
+ def down
+ remove_column(:ci_runners, :protected)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 0abdb987b77..5dd78c9f071 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170725145659) do
+ActiveRecord::Schema.define(version: 20170731123938) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -363,6 +363,7 @@ ActiveRecord::Schema.define(version: 20170725145659) do
t.string "architecture"
t.boolean "run_untagged", default: true, null: false
t.boolean "locked", default: false, null: false
+ t.boolean "protected", default: false, null: false
end
add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree