ruby-sfn-local 0.1.3 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sfn/aws_cli.rb +7 -5
- data/lib/sfn/execution_log.rb +15 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d655dc8f501ace970ed5a36bfe03ce609b520c0e5395a15e5ea9e39802da0a7
|
4
|
+
data.tar.gz: 876bb0c3e239c9f23935ab2220f3790dafb58d46c50893f5b90c492cd1a5a732
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7ac6a2a6e99d56fc0dff450504480bf3cc401176e6b09ce9bd00073214bf1d2dde2a33fc239e18adb702e415805113b6bfc78a1838d8afc9c125fbf7548a47e
|
7
|
+
data.tar.gz: d8d38c722b72679eb0cb85e8930f1c3dc773a2803881254db173865d09e0df62b840cd03679ff1b86eb93c502e99ac34e6996838a2956770d4f6d369f4b9f0e0
|
data/lib/sfn/aws_cli.rb
CHANGED
@@ -13,11 +13,13 @@ module Sfn
|
|
13
13
|
"--#{k}=#{v}"
|
14
14
|
end.join(' ')} \
|
15
15
|
--no-cli-pager"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
if command == 'get-execution-history'
|
17
|
+
stdout = `#{cmd}`
|
18
|
+
else
|
19
|
+
stdout, stderr, _status = Open3.capture3(cmd)
|
20
|
+
raise raise ExecutionError, "#{stderr.strip}\n#{debug_info}" unless stderr.strip.empty?
|
21
|
+
end
|
22
|
+
|
21
23
|
unless key.nil?
|
22
24
|
data = JSON.parse(stdout)
|
23
25
|
return data[key].strip if data.key?(key)
|
data/lib/sfn/execution_log.rb
CHANGED
@@ -15,26 +15,31 @@ module Sfn
|
|
15
15
|
attr_accessor :event
|
16
16
|
|
17
17
|
EVENTS = %w[stateEnteredEventDetails stateExitedEventDetails executionSucceededEventDetails
|
18
|
-
executionFailedEventDetails].freeze
|
18
|
+
executionFailedEventDetails taskScheduledEventDetails].freeze
|
19
|
+
|
19
20
|
def self.parse(execution_arn)
|
20
21
|
profile = {}
|
21
22
|
output = nil
|
22
23
|
error = nil
|
24
|
+
state_name = nil
|
23
25
|
events_json = AwsCli.run('stepfunctions', 'get-execution-history',
|
24
26
|
{ 'execution-arn': execution_arn.to_s, query: "'events[?#{EVENTS.join(' || ')}]'" })
|
25
|
-
|
26
27
|
JSON.parse(events_json).each do |event|
|
27
28
|
parsed_event = new(event)
|
28
29
|
|
29
30
|
output ||= parsed_event.output
|
30
31
|
error ||= parsed_event.error(events_json)
|
32
|
+
last_state_name = state_name
|
31
33
|
state_name = parsed_event.state_name
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
unless state_name.nil?
|
36
|
+
profile[state_name] ||= { 'input' => [], 'output' => [], 'parameters' => [] }
|
37
|
+
profile[state_name]['input'] << parsed_event.profile['input'] unless parsed_event.profile['input'].nil?
|
38
|
+
profile[state_name]['output'] << parsed_event.profile['output'] unless parsed_event.profile['output'].nil?
|
39
|
+
end
|
40
|
+
if !last_state_name.nil? && !parsed_event.profile['parameters'].nil?
|
41
|
+
profile[last_state_name]['parameters'] << parsed_event.profile['parameters']
|
42
|
+
end
|
38
43
|
end
|
39
44
|
[output, profile]
|
40
45
|
end
|
@@ -61,8 +66,9 @@ module Sfn
|
|
61
66
|
|
62
67
|
def profile
|
63
68
|
{
|
64
|
-
input
|
65
|
-
output
|
69
|
+
'input' => try_parse(event.dig('stateEnteredEventDetails', 'input')),
|
70
|
+
'output' => try_parse(event.dig('stateExitedEventDetails', 'output')),
|
71
|
+
'parameters' => try_parse(event.dig('taskScheduledEventDetails', 'parameters'))
|
66
72
|
}.compact
|
67
73
|
end
|
68
74
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-sfn-local
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gianni Mazza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-release
|