ruby-sfn-local 0.1.5 → 0.1.8
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 +6 -4
- data/lib/sfn/execution_log.rb +15 -8
- 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: 031c92b9bd2cca0fe86da9f393fd5c8881dbc04bee6c43b189585bdbbd9aa35a
|
4
|
+
data.tar.gz: d6e51f7f87a2278c8f7f12781f1d795d3afb324265287744c0d030d53f70efd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dc87f86c63cd1fe745db17dab08afbd440b76b7d81a6f766b1cfae830acbaf7e475d480aff53a22dd8f015fc73c724951c9ee970ac76c09953970ab7bc768b3
|
7
|
+
data.tar.gz: a31fbba0e5c16e68fd792f959ca88494f3abde0f9caea5a0ca7a1b38671b7ad9bcacb07d5eeeb580579f6f0d8e4626029f8095a4687214ded011b9692a87658a
|
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
|
-
|
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
|
17
22
|
|
18
|
-
raise raise ExecutionError, "#{stderr.strip}\n#{debug_info}" unless stderr.strip.empty?
|
19
|
-
|
20
|
-
stdout = `#{cmd}` if command == 'get-execution-history'
|
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,11 +15,13 @@ 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
27
|
JSON.parse(events_json).each do |event|
|
@@ -27,13 +29,17 @@ module Sfn
|
|
27
29
|
|
28
30
|
output ||= parsed_event.output
|
29
31
|
error ||= parsed_event.error(events_json)
|
32
|
+
last_state_name = state_name
|
30
33
|
state_name = parsed_event.state_name
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
37
43
|
end
|
38
44
|
[output, profile]
|
39
45
|
end
|
@@ -60,8 +66,9 @@ module Sfn
|
|
60
66
|
|
61
67
|
def profile
|
62
68
|
{
|
63
|
-
input
|
64
|
-
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'))
|
65
72
|
}.compact
|
66
73
|
end
|
67
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.8
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-release
|