Class: Ci::Runners::RunnerCreationStrategies::ProjectRunnerStrategy

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/ci/runners/runner_creation_strategies/project_runner_strategy.rb

Instance Method Summary collapse

Constructor Details

#initialize(user:, params:) ⇒ ProjectRunnerStrategy

Returns a new instance of ProjectRunnerStrategy.



9
10
11
12
# File 'app/services/ci/runners/runner_creation_strategies/project_runner_strategy.rb', line 9

def initialize(user:, params:)
  @user = user
  @params = params
end

Instance Method Details

#authorized_user?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/services/ci/runners/runner_creation_strategies/project_runner_strategy.rb', line 23

def authorized_user?
  user.present? && user.can?(:create_runner, scope)
end

#normalize_paramsObject



14
15
16
17
# File 'app/services/ci/runners/runner_creation_strategies/project_runner_strategy.rb', line 14

def normalize_params
  params[:runner_type] = 'project_type'
  params[:projects] = [scope]
end

#validate_paramsObject



19
20
21
# File 'app/services/ci/runners/runner_creation_strategies/project_runner_strategy.rb', line 19

def validate_params
  _('Missing/invalid scope') unless scope.present?
end