Class: Ci::Runners::UpdateRunnerService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::InternalEventsTracking
Defined in:
app/services/ci/runners/update_runner_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::InternalEventsTracking

#track_internal_event

Constructor Details

#initialize(current_user, runner) ⇒ UpdateRunnerService

Returns a new instance of UpdateRunnerService.



10
11
12
13
# File 'app/services/ci/runners/update_runner_service.rb', line 10

def initialize(current_user, runner)
  @current_user = current_user
  @runner = runner
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



8
9
10
# File 'app/services/ci/runners/update_runner_service.rb', line 8

def current_user
  @current_user
end

#runnerObject (readonly)

Returns the value of attribute runner.



8
9
10
# File 'app/services/ci/runners/update_runner_service.rb', line 8

def runner
  @runner
end

Instance Method Details

#execute(params) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/ci/runners/update_runner_service.rb', line 15

def execute(params)
  params[:active] = !params.delete(:paused) if params.include?(:paused)

  if runner.update(params)
    track_runner_event(params)
    runner.tick_runner_queue

    ServiceResponse.success
  else
    ServiceResponse.error(message: runner.errors.full_messages)
  end
end