floe 0.2.0 → 0.2.2
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 -1
- data/exe/floe +1 -1
- data/lib/floe/version.rb +1 -1
- data/lib/floe/workflow/context.rb +4 -0
- 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 +25 -18
- 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: ad8fec2f632914594254c32b7871eb8a4f23f3dfd2263ef5fe0875d0cccce8fa
|
4
|
+
data.tar.gz: 7e12b5a1a197dc44a7c7bd1b1581891a56908e7ae26836d5e26b73eb41c2a3ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b02c0ff479ff69433994732d6f3371c2a3e27fa36a094d5dea8340798f249015319821de30ad61334bc2bd9a6b25fb1791dfb0b023e7d0097472f35b93279a7
|
7
|
+
data.tar.gz: 49b6adb80c1910c9d006d41418e1741e8c62510633507583d2b34dc526a0ce4b73bb1faaa83b7950f0e1d31cbb9b37bd3e4b566bd2c374c824390a840e2e2519
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,25 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [0.2.2] - 2023-07-24
|
8
|
+
### Fixed
|
9
|
+
- Don't pick up real KUBECONFIG for tests (#73)
|
10
|
+
- Fix double json.parse and context default value (#69)
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- Configure Renovate (#46)
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
- Simplify next state handling (#66)
|
17
|
+
- Refactor Input/Output path handling (#68)
|
18
|
+
|
19
|
+
## [0.2.1] - 2023-07-12
|
20
|
+
### Fixed
|
21
|
+
- Fix State EnteredTime and FinishedTime (#59)
|
22
|
+
|
23
|
+
### Added
|
24
|
+
- Add workflow output (#57)
|
25
|
+
|
7
26
|
## [0.2.0] - 2023-07-05
|
8
27
|
### Added
|
9
28
|
- Add ability to pass options to `Floe::Workflow::Runner` (#48)
|
@@ -23,4 +42,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
23
42
|
### Added
|
24
43
|
- Initial release
|
25
44
|
|
26
|
-
[Unreleased]: https://github.com/ManageIQ/floe/compare/v0.
|
45
|
+
[Unreleased]: https://github.com/ManageIQ/floe/compare/v0.2.2...HEAD
|
46
|
+
[0.2.2]: https://github.com/ManageIQ/floe/compare/v0.2.1...v0.2.2
|
47
|
+
[0.2.1]: https://github.com/ManageIQ/floe/compare/v0.2.0...v0.2.1
|
48
|
+
[0.2.0]: https://github.com/ManageIQ/floe/compare/v0.1.1...v0.2.0
|
49
|
+
[0.1.1]: https://github.com/ManageIQ/floe/compare/v0.1.0...v0.1.1
|
50
|
+
[0.1.0]: https://github.com/ManageIQ/floe/tree/v0.1.0
|
data/exe/floe
CHANGED
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
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "securerandom"
|
3
4
|
require "json"
|
4
5
|
|
5
6
|
module Floe
|
6
7
|
class Workflow
|
8
|
+
include Logging
|
9
|
+
|
7
10
|
class << self
|
8
11
|
def load(path_or_io, context = nil, credentials = {})
|
9
12
|
payload = path_or_io.respond_to?(:read) ? path_or_io.read : File.read(path_or_io)
|
@@ -11,23 +14,22 @@ module Floe
|
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
14
|
-
attr_reader :context, :credentials, :payload, :states, :states_by_name, :current_state, :status
|
17
|
+
attr_reader :context, :credentials, :output, :payload, :states, :states_by_name, :current_state, :status
|
15
18
|
|
16
19
|
def initialize(payload, context = nil, credentials = {})
|
17
20
|
payload = JSON.parse(payload) if payload.kind_of?(String)
|
18
|
-
context = JSON.parse(context) if context.kind_of?(String)
|
19
21
|
credentials = JSON.parse(credentials) if credentials.kind_of?(String)
|
20
22
|
context = Context.new(context) unless context.kind_of?(Context)
|
21
23
|
|
22
24
|
@payload = payload
|
23
|
-
@context = context
|
25
|
+
@context = context
|
24
26
|
@credentials = credentials
|
25
27
|
|
26
28
|
@states = payload["States"].to_a.map { |name, state| State.build!(self, name, state) }
|
27
29
|
@states_by_name = @states.each_with_object({}) { |state, result| result[state.name] = state }
|
28
30
|
start_at = @payload["StartAt"]
|
29
31
|
|
30
|
-
current_state_name =
|
32
|
+
current_state_name = context.state["Name"] || start_at
|
31
33
|
@current_state = @states_by_name[current_state_name]
|
32
34
|
|
33
35
|
@status = current_state_name == start_at ? "pending" : current_state.status
|
@@ -37,29 +39,34 @@ module Floe
|
|
37
39
|
|
38
40
|
def step
|
39
41
|
@status = "running" if @status == "pending"
|
40
|
-
|
42
|
+
context.execution["StartTime"] ||= Time.now.utc
|
43
|
+
|
44
|
+
input = context.state["Output"] || context.execution["Input"].dup
|
41
45
|
|
42
|
-
|
46
|
+
logger.info("Running state: [#{current_state.name}] with input [#{input}]...")
|
47
|
+
|
48
|
+
context.state = {
|
49
|
+
"Guid" => SecureRandom.uuid,
|
50
|
+
"EnteredTime" => Time.now.utc,
|
51
|
+
"Input" => input,
|
52
|
+
"Name" => current_state.name
|
53
|
+
}
|
43
54
|
|
44
55
|
tick = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
45
56
|
next_state, output = current_state.run!(input)
|
46
57
|
tock = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
47
58
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
"Duration" => tock - tick,
|
52
|
-
"Output" => output,
|
53
|
-
"Name" => next_state&.name,
|
54
|
-
"Input" => output
|
55
|
-
}
|
59
|
+
context.state["FinishedTime"] = Time.now.utc
|
60
|
+
context.state["Duration"] = (tock - tick) / 1_000_000.0
|
61
|
+
context.state["Output"] = output
|
56
62
|
|
57
|
-
|
63
|
+
logger.info("Running state: [#{current_state.name}] with input [#{input}]...Complete - next state: [#{next_state}] output: [#{output}]")
|
58
64
|
|
59
|
-
|
65
|
+
context.states << context.state
|
60
66
|
|
61
|
-
|
62
|
-
@current_state =
|
67
|
+
@status = current_state.status
|
68
|
+
@current_state = next_state && @states_by_name[next_state]
|
69
|
+
@output = output if end?
|
63
70
|
|
64
71
|
self
|
65
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.2
|
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-24 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: []
|