Skip to content

Commit 1c302d5

Browse files
committed
WIP, try to add views for locked runners
1 parent 0eeb4be commit 1c302d5

File tree

6 files changed

+14
-3
lines changed

6 files changed

+14
-3
lines changed

app/models/ci/runner.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Runner < ActiveRecord::Base
44

55
LAST_CONTACT_TIME = 5.minutes.ago
66
AVAILABLE_SCOPES = %w[specific shared active paused online]
7-
FORM_EDITABLE = %i[description tag_list active run_untagged]
7+
FORM_EDITABLE = %i[description tag_list active run_untagged locked]
88

99
has_many :builds, class_name: 'Ci::Build'
1010
has_many :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject'

app/views/projects/runners/_form.html.haml

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
.checkbox
1313
= f.check_box :run_untagged
1414
%span.light Indicates whether this runner can pick jobs without tags
15+
.form-group
16+
= label :locked, 'Exclusive to this project', class: 'control-label'
17+
.col-sm-10
18+
.checkbox
19+
= f.check_box :locked
20+
%span.light Indicates whether this runner can be enabled for other projects
1521
.form-group
1622
= label_tag :token, class: 'control-label' do
1723
Token

app/views/projects/runners/show.html.haml

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
%tr
2323
%td Can run untagged jobs
2424
%td= @runner.run_untagged? ? 'Yes' : 'No'
25+
%tr
26+
%td Exclusive to this project
27+
%td= @runner.locked? ? 'Yes' : 'No'
2528
%tr
2629
%td Tags
2730
%td

lib/api/entities.rb

+1
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ class Runner < Grape::Entity
413413
class RunnerDetails < Runner
414414
expose :tag_list
415415
expose :run_untagged
416+
expose :locked
416417
expose :version, :revision, :platform, :architecture
417418
expose :contacted_at
418419
expose :token, if: lambda { |runner, options| options[:current_user].is_admin? || !runner.is_shared? }

lib/api/runners.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Runners < Grape::API
4949
runner = get_runner(params[:id])
5050
authenticate_update_runner!(runner)
5151

52-
attrs = attributes_for_keys [:description, :active, :tag_list, :run_untagged]
52+
attrs = attributes_for_keys [:description, :active, :tag_list, :run_untagged, :locked]
5353
if runner.update(attrs)
5454
present runner, with: Entities::RunnerDetails, current_user: current_user
5555
else

lib/ci/api/runners.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class Runners < Grape::API
2929
required_attributes! [:token]
3030

3131
attributes = { description: params[:description],
32-
tag_list: params[:tag_list] }
32+
tag_list: params[:tag_list],
33+
locked: !!params[:locked] }
3334

3435
unless params[:run_untagged].nil?
3536
attributes[:run_untagged] = params[:run_untagged]

0 commit comments

Comments
 (0)