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.



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

def initialize(token:)
  @token = token
end

Instance Method Details

#executeObject



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

def execute
  execute!
rescue AuthError
end

#execute!Object



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

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

    validate_job!(job)

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