floe 0.11.3 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yamllint +1 -3
- data/CHANGELOG.md +37 -1
- data/floe.gemspec +2 -2
- data/lib/floe/cli.rb +4 -1
- data/lib/floe/container_runner/docker_mixin.rb +3 -0
- data/lib/floe/validation_mixin.rb +49 -0
- data/lib/floe/version.rb +1 -1
- data/lib/floe/workflow/catcher.rb +17 -3
- data/lib/floe/workflow/choice_rule/data.rb +17 -5
- data/lib/floe/workflow/choice_rule.rb +14 -9
- data/lib/floe/workflow/context.rb +11 -5
- data/lib/floe/workflow/error_matcher_mixin.rb +17 -0
- data/lib/floe/workflow/intrinsic_function/parser.rb +108 -0
- data/lib/floe/workflow/intrinsic_function/transformer.rb +266 -0
- data/lib/floe/workflow/intrinsic_function.rb +34 -0
- data/lib/floe/workflow/path.rb +18 -1
- data/lib/floe/workflow/payload_template.rb +7 -4
- data/lib/floe/workflow/retrier.rb +9 -3
- data/lib/floe/workflow/state.rb +35 -14
- data/lib/floe/workflow/states/choice.rb +6 -5
- data/lib/floe/workflow/states/fail.rb +1 -1
- data/lib/floe/workflow/states/non_terminal_mixin.rb +2 -2
- data/lib/floe/workflow/states/pass.rb +2 -1
- data/lib/floe/workflow/states/succeed.rb +10 -1
- data/lib/floe/workflow/states/task.rb +11 -10
- data/lib/floe/workflow.rb +19 -9
- data/lib/floe.rb +7 -0
- metadata +23 -18
data/lib/floe/workflow.rb
CHANGED
@@ -6,6 +6,7 @@ require "json"
|
|
6
6
|
module Floe
|
7
7
|
class Workflow
|
8
8
|
include Logging
|
9
|
+
include ValidationMixin
|
9
10
|
|
10
11
|
class << self
|
11
12
|
def load(path_or_io, context = nil, credentials = {}, name = nil)
|
@@ -96,19 +97,21 @@ module Floe
|
|
96
97
|
# caller should really put credentials into context and not pass that variable
|
97
98
|
context.credentials = credentials if credentials
|
98
99
|
|
99
|
-
|
100
|
-
|
101
|
-
raise Floe::InvalidWorkflowError, "\"StartAt\" not in the \"States\" field" unless payload["States"].key?(payload["StartAt"])
|
102
|
-
|
103
|
-
@name = name
|
100
|
+
# NOTE: this is a string, and states use an array
|
101
|
+
@name = name || "State Machine"
|
104
102
|
@payload = payload
|
105
103
|
@context = context
|
106
104
|
@comment = payload["Comment"]
|
107
105
|
@start_at = payload["StartAt"]
|
108
106
|
|
109
|
-
|
110
|
-
|
111
|
-
|
107
|
+
# NOTE: Everywhere else we include our name (i.e.: parent name) when building the child name.
|
108
|
+
# When creating the states, we are dropping our name (i.e.: the workflow name)
|
109
|
+
@states = payload["States"].to_a.map { |state_name, state| State.build!(self, ["States", state_name], state) }
|
110
|
+
|
111
|
+
validate_workflow
|
112
|
+
|
113
|
+
@states_by_name = @states.each_with_object({}) { |state, result| result[state.short_name] = state }
|
114
|
+
rescue Floe::Error
|
112
115
|
raise
|
113
116
|
rescue => err
|
114
117
|
raise Floe::InvalidWorkflowError, err.message
|
@@ -157,7 +160,7 @@ module Floe
|
|
157
160
|
end
|
158
161
|
|
159
162
|
def output
|
160
|
-
context.
|
163
|
+
context.json_output if end?
|
161
164
|
end
|
162
165
|
|
163
166
|
def end?
|
@@ -187,8 +190,15 @@ module Floe
|
|
187
190
|
def credentials
|
188
191
|
@context.credentials
|
189
192
|
end
|
193
|
+
|
190
194
|
private
|
191
195
|
|
196
|
+
def validate_workflow
|
197
|
+
missing_field_error!("States") if @states.empty?
|
198
|
+
missing_field_error!("StartAt") if @start_at.nil?
|
199
|
+
invalid_field_error!("StartAt", @start_at, "is not found in \"States\"") unless workflow_state?(@start_at, self)
|
200
|
+
end
|
201
|
+
|
192
202
|
def step!
|
193
203
|
next_state = {"Name" => context.next_state, "Guid" => SecureRandom.uuid, "PreviousStateGuid" => context.state["Guid"]}
|
194
204
|
|
data/lib/floe.rb
CHANGED
@@ -7,7 +7,9 @@ require_relative "floe/logging"
|
|
7
7
|
|
8
8
|
require_relative "floe/runner"
|
9
9
|
|
10
|
+
require_relative "floe/validation_mixin"
|
10
11
|
require_relative "floe/workflow"
|
12
|
+
require_relative "floe/workflow/error_matcher_mixin"
|
11
13
|
require_relative "floe/workflow/catcher"
|
12
14
|
require_relative "floe/workflow/choice_rule"
|
13
15
|
require_relative "floe/workflow/choice_rule/not"
|
@@ -15,6 +17,9 @@ require_relative "floe/workflow/choice_rule/or"
|
|
15
17
|
require_relative "floe/workflow/choice_rule/and"
|
16
18
|
require_relative "floe/workflow/choice_rule/data"
|
17
19
|
require_relative "floe/workflow/context"
|
20
|
+
require_relative "floe/workflow/intrinsic_function"
|
21
|
+
require_relative "floe/workflow/intrinsic_function/parser"
|
22
|
+
require_relative "floe/workflow/intrinsic_function/transformer"
|
18
23
|
require_relative "floe/workflow/path"
|
19
24
|
require_relative "floe/workflow/payload_template"
|
20
25
|
require_relative "floe/workflow/reference_path"
|
@@ -37,6 +42,8 @@ require "time"
|
|
37
42
|
module Floe
|
38
43
|
class Error < StandardError; end
|
39
44
|
class InvalidWorkflowError < Error; end
|
45
|
+
class InvalidExecutionInput < Error; end
|
46
|
+
class PathError < Error; end
|
40
47
|
|
41
48
|
def self.logger
|
42
49
|
@logger ||= NullLogger.new
|
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.
|
4
|
+
version: 0.13.0
|
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-
|
11
|
+
date: 2024-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_spawn
|
@@ -80,20 +80,34 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: parslet
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: manageiq-style
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 1.5.2
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 1.5.2
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,20 +136,6 @@ dependencies:
|
|
122
136
|
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: simplecov
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- lib/floe/logging.rb
|
197
197
|
- lib/floe/null_logger.rb
|
198
198
|
- lib/floe/runner.rb
|
199
|
+
- lib/floe/validation_mixin.rb
|
199
200
|
- lib/floe/version.rb
|
200
201
|
- lib/floe/workflow.rb
|
201
202
|
- lib/floe/workflow/catcher.rb
|
@@ -205,6 +206,10 @@ files:
|
|
205
206
|
- lib/floe/workflow/choice_rule/not.rb
|
206
207
|
- lib/floe/workflow/choice_rule/or.rb
|
207
208
|
- lib/floe/workflow/context.rb
|
209
|
+
- lib/floe/workflow/error_matcher_mixin.rb
|
210
|
+
- lib/floe/workflow/intrinsic_function.rb
|
211
|
+
- lib/floe/workflow/intrinsic_function/parser.rb
|
212
|
+
- lib/floe/workflow/intrinsic_function/transformer.rb
|
208
213
|
- lib/floe/workflow/path.rb
|
209
214
|
- lib/floe/workflow/payload_template.rb
|
210
215
|
- lib/floe/workflow/reference_path.rb
|