floe 0.14.0 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/inline"
4
+ gemfile do
5
+ source "https://rubygems.org"
6
+ gem "optimist"
7
+ gem "colorize"
8
+ end
9
+ require "pp"
10
+
11
+ SUB_COMMANDS = {
12
+ "execute" => "Execute an .asl file through the stepfunctions simulator.",
13
+ "intrinsic" => "Execute an intrinsic function or JSONPath standalone."
14
+ }.freeze
15
+ Optimist.options do
16
+ banner "Run the aws stepfunctions simulator."
17
+ banner ""
18
+ banner "Notes:"
19
+ banner " This tool requires the stepfunctions simulator to be installed locally and running."
20
+ banner " Installation instructions can be found at https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local.html."
21
+ banner ""
22
+ banner "Commands:"
23
+ SUB_COMMANDS.each { |k, v| banner " #{k.ljust(14)}#{v}" }
24
+ banner ""
25
+ banner " For more help with a specific command use #{$PROGRAM_NAME} <command> --help"
26
+ banner ""
27
+ banner "Global Options:"
28
+ stop_on SUB_COMMANDS.keys
29
+ end
30
+ cmd = ARGV.shift
31
+ Optimist.educate if cmd.nil?
32
+ Optimist.die "unknown subcommand #{cmd.inspect}" unless SUB_COMMANDS.include?(cmd)
33
+
34
+ def aws_stepfunctions(args)
35
+ cmd = "aws stepfunctions --endpoint-url http://localhost:8083 #{args}"
36
+ puts "** #{cmd}".light_black if ENV["DEBUG"]
37
+ output = `#{cmd}`.chomp
38
+ output = output.empty? ? {} : JSON.parse(output)
39
+ puts output.pretty_inspect.light_black if ENV["DEBUG"]
40
+ output
41
+ rescue JSON::ParserError => err
42
+ warn "ERROR: #{err}".light_red if ENV["DEBUG"]
43
+ {}
44
+ end
45
+
46
+ def execute_stepfunction(definition, input)
47
+ require "json"
48
+ require "shellwords"
49
+
50
+ begin
51
+ state_machine_arn = aws_stepfunctions("create-state-machine --definition #{Shellwords.escape(definition)} --name 'StateMachine' --role-arn 'arn:aws:iam::012345678901:role/DummyRole'")["stateMachineArn"]
52
+ exit 1 if state_machine_arn.nil?
53
+
54
+ input = input ? "--input #{Shellwords.escape(input)}" : ""
55
+ execution_arn = aws_stepfunctions("start-execution --state-machine-arn #{state_machine_arn} #{input}")["executionArn"]
56
+ exit 1 if execution_arn.nil?
57
+
58
+ status, output = aws_stepfunctions("describe-execution --execution-arn #{execution_arn}").values_at("status", "output")
59
+ if status == "FAILED"
60
+ warn "ERROR: Execution failed. See simulator for reason.".light_red
61
+ exit 1
62
+ end
63
+ ensure
64
+ aws_stepfunctions("stop-execution --execution-arn #{execution_arn}") if execution_arn
65
+ aws_stepfunctions("delete-state-machine --state-machine-arn #{state_machine_arn}") if state_machine_arn
66
+ end
67
+
68
+ puts output if output
69
+ end
70
+
71
+ def execute
72
+ opts = Optimist.options do
73
+ banner SUB_COMMANDS["execute"]
74
+ banner ""
75
+
76
+ opt :file, "The .asl file to execute", :default => "definition.asl"
77
+ opt :input, "Input to the execution", :type => :string
78
+ end
79
+
80
+ definition = File.read(opts[:file]).chomp
81
+ execute_stepfunction(definition, opts[:input])
82
+ end
83
+
84
+ def intrinsic
85
+ opts = Optimist.options do
86
+ banner SUB_COMMANDS["intrinsic"]
87
+ banner ""
88
+
89
+ opt :function, "The intrinsic function or JSONPath to run", :type => :string, :required => true
90
+ opt :input, "Input to the execution", :type => :string
91
+ end
92
+
93
+ require "json"
94
+
95
+ definition = {
96
+ "StartAt" => "ExecState",
97
+ "States" => {
98
+ "ExecState" => {
99
+ "Type" => "Pass",
100
+ "Parameters" => {"data.$" => opts[:function]},
101
+ "OutputPath" => "$.data",
102
+ "End" => true
103
+ }
104
+ }
105
+ }.to_json
106
+
107
+ execute_stepfunction(definition, opts[:input])
108
+ end
109
+
110
+ send(cmd)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: floe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-20 00:00:00.000000000 Z
11
+ date: 2024-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_spawn
@@ -182,6 +182,8 @@ files:
182
182
  - LICENSE.txt
183
183
  - README.md
184
184
  - Rakefile
185
+ - examples/map.asl
186
+ - examples/parallel.asl
185
187
  - examples/set-credential.asl
186
188
  - examples/workflow.asl
187
189
  - exe/floe
@@ -199,6 +201,7 @@ files:
199
201
  - lib/floe/validation_mixin.rb
200
202
  - lib/floe/version.rb
201
203
  - lib/floe/workflow.rb
204
+ - lib/floe/workflow/branch.rb
202
205
  - lib/floe/workflow/catcher.rb
203
206
  - lib/floe/workflow/choice_rule.rb
204
207
  - lib/floe/workflow/choice_rule/and.rb
@@ -210,11 +213,13 @@ files:
210
213
  - lib/floe/workflow/intrinsic_function.rb
211
214
  - lib/floe/workflow/intrinsic_function/parser.rb
212
215
  - lib/floe/workflow/intrinsic_function/transformer.rb
216
+ - lib/floe/workflow/item_processor.rb
213
217
  - lib/floe/workflow/path.rb
214
218
  - lib/floe/workflow/payload_template.rb
215
219
  - lib/floe/workflow/reference_path.rb
216
220
  - lib/floe/workflow/retrier.rb
217
221
  - lib/floe/workflow/state.rb
222
+ - lib/floe/workflow/states/child_workflow_mixin.rb
218
223
  - lib/floe/workflow/states/choice.rb
219
224
  - lib/floe/workflow/states/fail.rb
220
225
  - lib/floe/workflow/states/input_output_mixin.rb
@@ -222,11 +227,13 @@ files:
222
227
  - lib/floe/workflow/states/non_terminal_mixin.rb
223
228
  - lib/floe/workflow/states/parallel.rb
224
229
  - lib/floe/workflow/states/pass.rb
230
+ - lib/floe/workflow/states/retry_catch_mixin.rb
225
231
  - lib/floe/workflow/states/succeed.rb
226
232
  - lib/floe/workflow/states/task.rb
227
233
  - lib/floe/workflow/states/wait.rb
234
+ - lib/floe/workflow_base.rb
228
235
  - renovate.json
229
- - sig/floe.rbs/floe.rbs
236
+ - tools/step_functions
230
237
  homepage: https://github.com/ManageIQ/floe
231
238
  licenses:
232
239
  - Apache-2.0
@@ -1,4 +0,0 @@
1
- module Floe
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end