Class: Ci::AuthJobFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/ci/auth_job_finder.rb

Constant Summary collapse

AuthError =
Class.new(StandardError)
NotRunningJobError =
Class.new(AuthError)
ErasedJobError =
Class.new(AuthError)
DeletedProjectError =
Class.new(AuthError)

Instance Method Summary collapse

Constructor Details

#initialize(token:) ⇒ AuthJobFinder

Returns a new instance of AuthJobFinder.



9
10
11
# File 'app/finders/ci/auth_job_finder.rb', line 9

def initialize(token:)
  @token = token
end

Instance Method Details

#executeObject



25
26
27
28
# File 'app/finders/ci/auth_job_finder.rb', line 25

def execute
  execute!
rescue AuthError
end

#execute!Object



13
14
15
16
17
18
19
20
21
22
23
# File 'app/finders/ci/auth_job_finder.rb', line 13

def execute!
  find_job_by_token.tap do |job|
    next unless job

    validate_job!(job)

    if job.user
      job.user.set_ci_job_token_scope!(job)
    end
  end
end