ruby-sfn-local 0.1.3 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c56a390adcd8cefff1fa95e14db7b966e40058f81fe7d775edf31256d7eaf76
4
- data.tar.gz: 7da9325fb01e571bf5769e6d890547c91f684742cd872d43decbd0b6bd798f1c
3
+ metadata.gz: 1d655dc8f501ace970ed5a36bfe03ce609b520c0e5395a15e5ea9e39802da0a7
4
+ data.tar.gz: 876bb0c3e239c9f23935ab2220f3790dafb58d46c50893f5b90c492cd1a5a732
5
5
  SHA512:
6
- metadata.gz: e88364b74f3ed18ba23d4aab7b1e7df243a56893693af3c30531ef04c9cbc0e6f91657eb59f291eeef6e131ed3b6e55a3720cf7ce9dedb68096cce2e26c1ec1b
7
- data.tar.gz: 3091356de9b879a01978babcd45ca8939f4d3b8f4e28a84e9e1c5f7dc1df4d2c8662867cdebaf677553adbfeee8401824d5ee0ddb61ba00b99455aabbd0dbade
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
- stdout, stderr, _status = Open3.capture3(cmd)
18
- raise raise ExecutionError, "#{stderr.strip}\n#{debug_info}" unless stderr.strip.empty?
19
-
20
- stdout = `#{cmd}`
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)
@@ -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
- next if state_name.nil?
34
-
35
- profile[state_name] ||= { input: [], output: [] }
36
- profile[state_name][:input] << parsed_event.profile[:input] unless parsed_event.profile[:input].nil?
37
- profile[state_name][:output] << parsed_event.profile[:output] unless parsed_event.profile[:output].nil?
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: try_parse(event.dig('stateEnteredEventDetails', 'input')),
65
- output: try_parse(event.dig('stateExitedEventDetails', '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.3
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-04 00:00:00.000000000 Z
11
+ date: 2022-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-release