floe 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -8
- data/lib/floe/version.rb +1 -1
- data/lib/floe/workflow/state.rb +0 -16
- data/lib/floe/workflow/states/choice.rb +5 -8
- data/lib/floe/workflow/states/fail.rb +2 -12
- data/lib/floe/workflow/states/pass.rb +6 -6
- data/lib/floe/workflow/states/succeed.rb +3 -4
- data/lib/floe/workflow/states/task.rb +15 -15
- data/lib/floe/workflow/states/wait.rb +5 -5
- data/lib/floe/workflow.rb +19 -16
- data/renovate.json +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68fc7de6c5112f8717f2941c4f89f22d688092a2ab15a6fe5b859c0f6684c177
|
4
|
+
data.tar.gz: 23172e12b50792acbc0891dd9b0fa0a9e4d0583aa6e52e85fae408faa33ffdd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 157482ec4fd0914d18cb87c06d1ee61f91668baf9c6592451f6c8c1e5de206f088256ef8c45ff29e6d26fb175e3750e1b0ed1008a76910f6520bd424977a0763
|
7
|
+
data.tar.gz: 7c5c586d0087914944e577a6af4f8ca99ebc8ef15798fcb6ed5f50b46a99e368c8315b087c1ad823e2809b24e8539f479f26699b56618324b4850e98bed9b63e
|
data/CHANGELOG.md
CHANGED
@@ -4,33 +4,50 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [0.2.3] - 2023-07-28
|
8
|
+
### Fixed
|
9
|
+
- Fix storing next_state in Context ([#76])(https://github.com/ManageIQ/floe/pull/76)
|
10
|
+
|
11
|
+
## [0.2.2] - 2023-07-24
|
12
|
+
### Fixed
|
13
|
+
- Don't pick up real KUBECONFIG for tests ([#73](https://github.com/ManageIQ/floe/pull/73))
|
14
|
+
- Fix double json.parse and context default value ([#69](https://github.com/ManageIQ/floe/pull/69))
|
15
|
+
|
16
|
+
### Added
|
17
|
+
- Configure Renovate ([#46](https://github.com/ManageIQ/floe/pull/46))
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
- Simplify next state handling ([#66](https://github.com/ManageIQ/floe/pull/66))
|
21
|
+
- Refactor Input/Output path handling ([#68](https://github.com/ManageIQ/floe/pull/68))
|
22
|
+
|
7
23
|
## [0.2.1] - 2023-07-12
|
8
24
|
### Fixed
|
9
|
-
- Fix State EnteredTime and FinishedTime (#59)
|
25
|
+
- Fix State EnteredTime and FinishedTime ([#59](https://github.com/ManageIQ/floe/pull/59))
|
10
26
|
|
11
27
|
### Added
|
12
|
-
- Add workflow output (#57)
|
28
|
+
- Add workflow output ([#57](https://github.com/ManageIQ/floe/pull/57))
|
13
29
|
|
14
30
|
## [0.2.0] - 2023-07-05
|
15
31
|
### Added
|
16
|
-
- Add ability to pass options to `Floe::Workflow::Runner` (#48)
|
17
|
-
- Add kubeconfig file support to `Floe::Workflow::Runner::Kubernetes` (#53)
|
32
|
+
- Add ability to pass options to `Floe::Workflow::Runner` ([#48](https://github.com/ManageIQ/floe/pull/48))
|
33
|
+
- Add kubeconfig file support to `Floe::Workflow::Runner::Kubernetes` ([#53](https://github.com/ManageIQ/floe/pull/53))
|
18
34
|
|
19
35
|
### Removed
|
20
|
-
- Remove to_dot/to_svg code (#54)
|
36
|
+
- Remove to_dot/to_svg code ([#54](https://github.com/ManageIQ/floe/pull/54))
|
21
37
|
|
22
38
|
### Fixed
|
23
|
-
- Fixed default rake task to spec (#55)
|
39
|
+
- Fixed default rake task to spec ([#55](https://github.com/ManageIQ/floe/pull/55))
|
24
40
|
|
25
41
|
## [0.1.1] - 2023-06-05
|
26
42
|
### Fixed
|
27
|
-
- Fix States::Wait Path initializer arguments (#47)
|
43
|
+
- Fix States::Wait Path initializer arguments ([#47](https://github.com/ManageIQ/floe/pull/47))
|
28
44
|
|
29
45
|
## [0.1.0] - 2023-03-13
|
30
46
|
### Added
|
31
47
|
- Initial release
|
32
48
|
|
33
|
-
[Unreleased]: https://github.com/ManageIQ/floe/compare/v0.2.
|
49
|
+
[Unreleased]: https://github.com/ManageIQ/floe/compare/v0.2.2...HEAD
|
50
|
+
[0.2.2]: https://github.com/ManageIQ/floe/compare/v0.2.1...v0.2.2
|
34
51
|
[0.2.1]: https://github.com/ManageIQ/floe/compare/v0.2.0...v0.2.1
|
35
52
|
[0.2.0]: https://github.com/ManageIQ/floe/compare/v0.1.1...v0.2.0
|
36
53
|
[0.1.1]: https://github.com/ManageIQ/floe/compare/v0.1.0...v0.1.1
|
data/lib/floe/version.rb
CHANGED
data/lib/floe/workflow/state.rb
CHANGED
@@ -41,22 +41,6 @@ module Floe
|
|
41
41
|
def status
|
42
42
|
end? ? "success" : "running"
|
43
43
|
end
|
44
|
-
|
45
|
-
def run!(input)
|
46
|
-
logger.info("Running state: [#{name}] with input [#{input}]")
|
47
|
-
|
48
|
-
input = input_path.value(context, input)
|
49
|
-
|
50
|
-
output, next_state = block_given? ? yield(input) : input
|
51
|
-
next_state ||= workflow.states_by_name[payload["Next"]] unless end?
|
52
|
-
|
53
|
-
output ||= input
|
54
|
-
output = output_path&.value(context, output)
|
55
|
-
|
56
|
-
logger.info("Running state: [#{name}] with input [#{input}]...Complete - next state: [#{next_state&.name}] output: [#{output}]")
|
57
|
-
|
58
|
-
[next_state, output]
|
59
|
-
end
|
60
44
|
end
|
61
45
|
end
|
62
46
|
end
|
@@ -16,15 +16,12 @@ module Floe
|
|
16
16
|
@output_path = Path.new(payload.fetch("OutputPath", "$"))
|
17
17
|
end
|
18
18
|
|
19
|
-
def run!(
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
def run!(input)
|
20
|
+
input = input_path.value(context, input)
|
21
|
+
next_state = choices.detect { |choice| choice.true?(context, input) }&.next || default
|
22
|
+
output = output_path.value(context, input)
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
[output, next_state]
|
27
|
-
end
|
24
|
+
[next_state, output]
|
28
25
|
end
|
29
26
|
end
|
30
27
|
end
|
@@ -11,21 +11,11 @@ module Floe
|
|
11
11
|
|
12
12
|
@cause = payload["Cause"]
|
13
13
|
@error = payload["Error"]
|
14
|
+
@end = true
|
14
15
|
end
|
15
16
|
|
16
17
|
def run!(input)
|
17
|
-
|
18
|
-
|
19
|
-
next_state = nil
|
20
|
-
output = input
|
21
|
-
|
22
|
-
logger.info("Running state: [#{name}] with input [#{input}]...Complete - next state: [#{next_state&.name}]")
|
23
|
-
|
24
|
-
[next_state, output]
|
25
|
-
end
|
26
|
-
|
27
|
-
def end?
|
28
|
-
true
|
18
|
+
[nil, input]
|
29
19
|
end
|
30
20
|
|
31
21
|
def status
|
@@ -18,12 +18,12 @@ module Floe
|
|
18
18
|
@result_path = ReferencePath.new(payload.fetch("ResultPath", "$"))
|
19
19
|
end
|
20
20
|
|
21
|
-
def run!(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
def run!(input)
|
22
|
+
output = input_path.value(context, input)
|
23
|
+
output = result_path.set(output, result) if result && result_path
|
24
|
+
output = output_path.value(context, output)
|
25
|
+
|
26
|
+
[@next, output]
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -9,12 +9,11 @@ module Floe
|
|
9
9
|
def initialize(workflow, name, payload)
|
10
10
|
super
|
11
11
|
|
12
|
-
@
|
13
|
-
@output_path = Path.new(payload.fetch("OutputPath", "$"))
|
12
|
+
@end = true
|
14
13
|
end
|
15
14
|
|
16
|
-
def
|
17
|
-
|
15
|
+
def run!(input)
|
16
|
+
[nil, input]
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -25,24 +25,23 @@ module Floe
|
|
25
25
|
@credentials = PayloadTemplate.new(payload["Credentials"]) if payload["Credentials"]
|
26
26
|
end
|
27
27
|
|
28
|
-
def run!(
|
29
|
-
|
30
|
-
|
28
|
+
def run!(input)
|
29
|
+
input = input_path.value(context, input)
|
30
|
+
input = parameters.value(context, input) if parameters
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
runner = Floe::Workflow::Runner.for_resource(resource)
|
33
|
+
_exit_status, results = runner.run!(resource, input, credentials&.value({}, workflow.credentials))
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
output = process_output!(input, results)
|
36
|
+
[@next, output]
|
37
|
+
rescue => err
|
38
|
+
retrier = self.retry.detect { |r| (r.error_equals & [err.to_s, "States.ALL"]).any? }
|
39
|
+
retry if retry!(retrier)
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
catcher = self.catch.detect { |c| (c.error_equals & [err.to_s, "States.ALL"]).any? }
|
42
|
+
raise if catcher.nil?
|
43
43
|
|
44
|
-
|
45
|
-
end
|
44
|
+
[catcher.next, output]
|
46
45
|
end
|
47
46
|
|
48
47
|
private
|
@@ -75,7 +74,8 @@ module Floe
|
|
75
74
|
end
|
76
75
|
|
77
76
|
results = result_selector.value(context, results) if result_selector
|
78
|
-
result_path.set(output, results)
|
77
|
+
output = result_path.set(output, results)
|
78
|
+
output_path.value(context, output)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -16,11 +16,11 @@ module Floe
|
|
16
16
|
@output_path = Path.new(payload.fetch("OutputPath", "$"))
|
17
17
|
end
|
18
18
|
|
19
|
-
def run!(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
def run!(input)
|
20
|
+
input = input_path.value(context, input)
|
21
|
+
sleep(seconds)
|
22
|
+
output = output_path.value(context, input)
|
23
|
+
[@next, output]
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/floe/workflow.rb
CHANGED
@@ -5,6 +5,8 @@ require "json"
|
|
5
5
|
|
6
6
|
module Floe
|
7
7
|
class Workflow
|
8
|
+
include Logging
|
9
|
+
|
8
10
|
class << self
|
9
11
|
def load(path_or_io, context = nil, credentials = {})
|
10
12
|
payload = path_or_io.respond_to?(:read) ? path_or_io.read : File.read(path_or_io)
|
@@ -16,20 +18,21 @@ module Floe
|
|
16
18
|
|
17
19
|
def initialize(payload, context = nil, credentials = {})
|
18
20
|
payload = JSON.parse(payload) if payload.kind_of?(String)
|
19
|
-
context = JSON.parse(context) if context.kind_of?(String)
|
20
21
|
credentials = JSON.parse(credentials) if credentials.kind_of?(String)
|
21
22
|
context = Context.new(context) unless context.kind_of?(Context)
|
22
23
|
|
23
24
|
@payload = payload
|
24
|
-
@context = context
|
25
|
+
@context = context
|
25
26
|
@credentials = credentials
|
26
27
|
|
27
28
|
@states = payload["States"].to_a.map { |name, state| State.build!(self, name, state) }
|
28
29
|
@states_by_name = @states.each_with_object({}) { |state, result| result[state.name] = state }
|
29
30
|
start_at = @payload["StartAt"]
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
context.state["Name"] ||= start_at
|
33
|
+
|
34
|
+
current_state_name = context.state["Name"]
|
35
|
+
@current_state = @states_by_name[current_state_name]
|
33
36
|
|
34
37
|
@status = current_state_name == start_at ? "pending" : current_state.status
|
35
38
|
rescue JSON::ParserError => err
|
@@ -40,30 +43,30 @@ module Floe
|
|
40
43
|
@status = "running" if @status == "pending"
|
41
44
|
context.execution["StartTime"] ||= Time.now.utc
|
42
45
|
|
43
|
-
|
46
|
+
context.state["Guid"] = SecureRandom.uuid
|
47
|
+
context.state["Input"] ||= context.execution["Input"].dup
|
44
48
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
"Input" => input,
|
49
|
-
"Name" => current_state.name
|
50
|
-
}
|
49
|
+
logger.info("Running state: [#{current_state.name}] with input [#{context.state["Input"]}]...")
|
50
|
+
|
51
|
+
context.state["EnteredTime"] = Time.now.utc
|
51
52
|
|
52
53
|
tick = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
53
|
-
next_state, output = current_state.run!(
|
54
|
+
next_state, output = current_state.run!(context.state["Input"])
|
54
55
|
tock = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
55
56
|
|
56
57
|
context.state["FinishedTime"] = Time.now.utc
|
57
58
|
context.state["Duration"] = (tock - tick) / 1_000_000.0
|
58
59
|
context.state["Output"] = output
|
59
60
|
|
61
|
+
logger.info("Running state: [#{current_state.name}] with input [#{context["Input"]}]...Complete - next state: [#{next_state}] output: [#{output}]")
|
62
|
+
|
60
63
|
context.states << context.state
|
61
64
|
|
62
|
-
@status
|
63
|
-
@
|
65
|
+
@status = current_state.status
|
66
|
+
@current_state = next_state && @states_by_name[next_state]
|
67
|
+
@output = output if end?
|
64
68
|
|
65
|
-
|
66
|
-
@current_state = next_state_name && @states_by_name[next_state_name]
|
69
|
+
context.state = {"Name" => next_state, "Input" => output} unless end?
|
67
70
|
|
68
71
|
self
|
69
72
|
end
|
data/renovate.json
ADDED
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.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ManageIQ Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_spawn
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/floe/workflow/states/succeed.rb
|
169
169
|
- lib/floe/workflow/states/task.rb
|
170
170
|
- lib/floe/workflow/states/wait.rb
|
171
|
+
- renovate.json
|
171
172
|
- sig/floe.rbs/floe.rbs
|
172
173
|
homepage: https://github.com/ManageIQ/floe
|
173
174
|
licenses: []
|