Class: Gitlab::Audit::CiRunnerTokenAuthor

Inherits:
NullAuthor
  • Object
show all
Defined in:
lib/gitlab/audit/ci_runner_token_author.rb

Instance Attribute Summary collapse

Attributes inherited from NullAuthor

#id, #name

Instance Method Summary collapse

Methods inherited from NullAuthor

#current_sign_in_ip, for, #impersonated?, #to_global_id

Constructor Details

#initialize(entity_type:, entity_path:, runner_authentication_token: nil, runner_registration_token: nil) ⇒ CiRunnerTokenAuthor

Represents a CI Runner token (registration or authentication)

Parameters:

  • entity_type ("gitlab_instance", "Group", "Project")

    type of the scope that the token applies to

  • entity_path (String)

    full path to the scope that the token applies to

  • runner_authentication_token (String) (defaults to: nil)

    authentication token used in a runner registration/un-registration operation

  • runner_registration_token (String) (defaults to: nil)

    authentication token used in a runner registration operation



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/audit/ci_runner_token_author.rb', line 15

def initialize(entity_type:, entity_path:, runner_authentication_token: nil, runner_registration_token: nil)
  name =
    if runner_authentication_token.present?
      "Authentication token: #{runner_authentication_token}"
    elsif runner_registration_token.present?
      "Registration token: #{runner_registration_token}"
    else
      "Token not available"
    end

  super(id: -1, name: name)

  @entity_type = entity_type
  @entity_path = entity_path
end

Instance Attribute Details

#entity_pathObject (readonly)

Returns the value of attribute entity_path.



6
7
8
# File 'lib/gitlab/audit/ci_runner_token_author.rb', line 6

def entity_path
  @entity_path
end

#entity_typeObject (readonly)

Returns the value of attribute entity_type.



6
7
8
# File 'lib/gitlab/audit/ci_runner_token_author.rb', line 6

def entity_type
  @entity_type
end

Instance Method Details

#full_pathObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gitlab/audit/ci_runner_token_author.rb', line 31

def full_path
  url_helpers = ::Gitlab::Routing.url_helpers

  case @entity_type
  when 'Group'
    url_helpers.group_runners_path(@entity_path)
  when 'Project'
    project = Project.find_by_full_path(@entity_path)
    url_helpers.project_settings_ci_cd_path(project, anchor: 'js-runners-settings') if project
  else
    url_helpers.admin_runners_path
  end
end