blob: f052324a219c6f8cb30dd64dd3827fa64f2b9b84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
module Projects
module Settings
class DeployTokensPresenter < Gitlab::View::Presenter::Simple
include Enumerable
presents :deploy_tokens
def length
deploy_tokens.length
end
def each
deploy_tokens.each do |deploy_token|
yield deploy_token
end
end
def temporal_token
@temporal_token ||= Gitlab::Redis::SharedState.with do |redis|
token = redis.get(deploy_token_key)
redis.del(deploy_token_key)
token
end
end
def attributes_deploy_token
@attributes_deploy_token ||= Gitlab::Redis::SharedState.with do |redis|
attributes_key = deploy_token_key + ":attributes"
attributes_content = redis.get(attributes_key) || '{}'
redis.del(attributes_key)
JSON.parse(attributes_content)
end
end
private
def deploy_token_key
@deploy_token_key ||= DeployToken.redis_shared_state_key(current_user.id)
end
end
end
end
|