kyklos 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kyklos/adapters/base_adapter.rb +3 -3
- data/lib/kyklos/adapters/shoryuken_adapter.rb +8 -36
- data/lib/kyklos/cli.rb +5 -4
- data/lib/kyklos/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6478471f4b5f7051d22bc6d9df6eb3ae7c060906
|
4
|
+
data.tar.gz: b4a301e84bae1b06d792be5e3f35e04ebcc2d1a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf037f71290ec2e74a16245ce498284ee93b4e55f6142511bc96d7ba3fdae11d49315fa4c526c378105a6a21786ab131c32b32d2aac9b8972d96a1f66104a099
|
7
|
+
data.tar.gz: a56a652c1960dd4f910fccbd961d97c9e14f3b33267949fcb625bd8330bf080c5d5b54b1a0a1dca44aa9fb0ec53f0221a9499c4edee713c7311745724c652ad5
|
@@ -8,12 +8,12 @@ module Kyklos
|
|
8
8
|
|
9
9
|
end
|
10
10
|
|
11
|
-
def assign_cloudwatchevents(job_id:, rule:)
|
11
|
+
def assign_cloudwatchevents(job_id:, rule_name_prefix:,rule:)
|
12
12
|
raise NotImplementedError
|
13
13
|
end
|
14
14
|
|
15
|
-
def unassign_cloudwatchevents(rule:)
|
16
|
-
|
15
|
+
def unassign_cloudwatchevents(rule:, rule_name_prefix:)
|
16
|
+
# no op
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -31,8 +31,8 @@ module Kyklos
|
|
31
31
|
@queue_url = args[0]
|
32
32
|
end
|
33
33
|
|
34
|
-
def assign_cloudwatchevents(job_id:, rule:)
|
35
|
-
assign_queue_policy(job_id, rule.arn)
|
34
|
+
def assign_cloudwatchevents(job_id:, rule_name_prefix:, rule:)
|
35
|
+
assign_queue_policy(job_id, rule_name_prefix, rule.arn)
|
36
36
|
[
|
37
37
|
{
|
38
38
|
id: target_id(job_id),
|
@@ -44,10 +44,6 @@ module Kyklos
|
|
44
44
|
]
|
45
45
|
end
|
46
46
|
|
47
|
-
def unassign_cloudwatchevents(rule:)
|
48
|
-
unassign_queue_policy(rule.arn)
|
49
|
-
end
|
50
|
-
|
51
47
|
private
|
52
48
|
|
53
49
|
def target_id(job_id)
|
@@ -62,10 +58,10 @@ module Kyklos
|
|
62
58
|
resp.attributes['QueueArn']
|
63
59
|
end
|
64
60
|
|
65
|
-
def assign_queue_policy(job_id, rule_arn)
|
61
|
+
def assign_queue_policy(job_id, rule_name_prefix, rule_arn)
|
66
62
|
policy = get_queue_policy
|
67
63
|
new_statement = {
|
68
|
-
'Sid' =>
|
64
|
+
'Sid' => rule_name_prefix.to_s,
|
69
65
|
'Effect' => 'Allow',
|
70
66
|
'Principal' => {
|
71
67
|
"AWS" => '*'
|
@@ -73,8 +69,8 @@ module Kyklos
|
|
73
69
|
'Action' => 'sqs:SendMessage',
|
74
70
|
'Resource' => target_arn,
|
75
71
|
'Condition' => {
|
76
|
-
'
|
77
|
-
'aws:SourceArn' => rule_arn
|
72
|
+
'ArnLike' => {
|
73
|
+
'aws:SourceArn' => rule_arn_like(rule_name_prefix, rule_arn)
|
78
74
|
}
|
79
75
|
}
|
80
76
|
}
|
@@ -115,32 +111,8 @@ module Kyklos
|
|
115
111
|
statements
|
116
112
|
end
|
117
113
|
|
118
|
-
def
|
119
|
-
|
120
|
-
policy['Statement'] = policy['Statement'].reject do |statement|
|
121
|
-
statement['Effect'] == 'Allow' &&
|
122
|
-
statement['Action'] == 'sqs:SendMessage' &&
|
123
|
-
statement['Resource'] == target_arn &&
|
124
|
-
statement['Condition'] &&
|
125
|
-
statement['Condition']['ArnEquals'] &&
|
126
|
-
statement['Condition']['ArnEquals']['aws:SourceArn'] == rule_arn
|
127
|
-
end
|
128
|
-
|
129
|
-
if policy['Statement'].empty?
|
130
|
-
sqs.set_queue_attributes(
|
131
|
-
queue_url: queue_url,
|
132
|
-
attributes: {
|
133
|
-
'Policy' => '',
|
134
|
-
},
|
135
|
-
)
|
136
|
-
else
|
137
|
-
sqs.set_queue_attributes(
|
138
|
-
queue_url: queue_url,
|
139
|
-
attributes: {
|
140
|
-
'Policy' => policy.to_json,
|
141
|
-
},
|
142
|
-
)
|
143
|
-
end
|
114
|
+
def rule_arn_like(rule_name_prefix, rule_arn)
|
115
|
+
[rule_arn.split(rule_name_prefix).first, rule_name_prefix, '*'].join
|
144
116
|
end
|
145
117
|
|
146
118
|
def sqs
|
data/lib/kyklos/cli.rb
CHANGED
@@ -55,6 +55,7 @@ module Kyklos
|
|
55
55
|
rule = cloudwatchevents.describe_rule(name: rule_params[:name])
|
56
56
|
targets = adapter.assign_cloudwatchevents(
|
57
57
|
job_id: job_id,
|
58
|
+
rule_name_prefix: rule_name_prefix,
|
58
59
|
rule: rule)
|
59
60
|
cloudwatchevents.put_targets(
|
60
61
|
rule: rule.name,
|
@@ -64,7 +65,7 @@ module Kyklos
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def remove_job(rule)
|
67
|
-
adapter.unassign_cloudwatchevents(rule: rule)
|
68
|
+
adapter.unassign_cloudwatchevents(rule_name_prefix: rule_name_prefix, rule: rule)
|
68
69
|
|
69
70
|
target_ids = find_targets(rule.name).map(&:id)
|
70
71
|
unless target_ids.empty?
|
@@ -73,12 +74,12 @@ module Kyklos
|
|
73
74
|
cloudwatchevents.delete_rule(name: rule.name)
|
74
75
|
end
|
75
76
|
|
76
|
-
def
|
77
|
+
def rule_name_prefix
|
77
78
|
"kyslos-#{"#{@identifier}/#{Digest::MD5.hexdigest(@identifier)}".sum}-"
|
78
79
|
end
|
79
80
|
|
80
81
|
def eventname(job_id)
|
81
|
-
"#{
|
82
|
+
"#{rule_name_prefix}#{Digest::MD5.hexdigest(job_id.to_s)}"
|
82
83
|
end
|
83
84
|
|
84
85
|
def eventnames
|
@@ -93,7 +94,7 @@ module Kyklos
|
|
93
94
|
def find_rules
|
94
95
|
list_rules = ->(next_token) do
|
95
96
|
resp = cloudwatchevents.
|
96
|
-
list_rules(name_prefix:
|
97
|
+
list_rules(name_prefix: rule_name_prefix,
|
97
98
|
next_token: next_token)
|
98
99
|
if resp.next_token
|
99
100
|
resp.rules + list_rules.call(next_token)
|
data/lib/kyklos/version.rb
CHANGED