class WarpEngine::ApplicationTokenService
Creates, revokes and rotates WarpEngine::ApplicationToken records and keeps the token secret of the matching CI pipelines in step (see SecretSyncService).
Constants
Public Class Methods
Source
# File app/services/warp_engine/application_token_service.rb, line 14 def initialize(ci: WarpEngine.ci) @ci = ci end
- ci
-
the
CIadapter, by defaultWarpEngine.ci
Public Instance Methods
Source
# File app/services/warp_engine/application_token_service.rb, line 20 def create(attributes) token = ApplicationToken.new(attributes) return Result.new(token: token, sync: nil) unless token.save Result.new(token: token, sync: provision(token)) end
Saves a new WarpEngine::ApplicationToken from attributes and, when it saved, provisions it to its pipelines (provision). Returns a Result.
Source
# File app/services/warp_engine/application_token_service.rb, line 30 def provision(token) return nil unless @ci.configured? service = SecretSyncService.new(ci: @ci) pipelines = service.pipelines_for_token(token) return nil if pipelines.empty? service.provision(token.plain_token, pipelines: pipelines) end
Writes the plain value of token as the pipeline secret of every active pipeline the token may publish for. Returns the SecretSyncService#provision result, or nil when the CI is not configured or there are no pipelines.
Source
# File app/services/warp_engine/application_token_service.rb, line 42 def revoke(token) SecretSyncService.new(ci: @ci).deprovision(token) if @ci.configured? token.revoke! end
Removes the pipeline secrets of token (when the CI is configured) and soft-deletes the token.
Source
# File app/services/warp_engine/application_token_service.rb, line 48 def rotate(token) SecretSyncService.new(ci: @ci).rotate(token) end
Replaces token with a new one and provisions it; see SecretSyncService#rotate.