floe 0.2.1 → 0.2.2

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: b6602a2b11185c6d720b8be59bc69f0e5b115af19e23f64a0e8718fdc8828321
4
- data.tar.gz: cf88494cf2e4e3ae9227a5f0e7a19cf91c6e7d20f691fc36643b870e10255afd
3
+ metadata.gz: ad8fec2f632914594254c32b7871eb8a4f23f3dfd2263ef5fe0875d0cccce8fa
4
+ data.tar.gz: 7e12b5a1a197dc44a7c7bd1b1581891a56908e7ae26836d5e26b73eb41c2a3ae
5
5
  SHA512:
6
- metadata.gz: b1ffab71c8fc58a0190aa6e2a7db223f7b9968bb78d8cb08fadfcbd3b8edcac2f155aa92125f92e259f3c1423fe98ac61508cec71ee6aaca52b2135e819e9b26
7
- data.tar.gz: 500f7734ecd0e6731d0324db59eecb50f1f0b99efbb33e6a0acc0e9dfbdde6f6c18a3a2b074c271f16b8dd64971aec4ae42e2810819eb9765c39e8c2b6ce0c1b
6
+ metadata.gz: 0b02c0ff479ff69433994732d6f3371c2a3e27fa36a094d5dea8340798f249015319821de30ad61334bc2bd9a6b25fb1791dfb0b023e7d0097472f35b93279a7
7
+ data.tar.gz: 49b6adb80c1910c9d006d41418e1741e8c62510633507583d2b34dc526a0ce4b73bb1faaa83b7950f0e1d31cbb9b37bd3e4b566bd2c374c824390a840e2e2519
data/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ 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
+
7
19
  ## [0.2.1] - 2023-07-12
8
20
  ### Fixed
9
21
  - Fix State EnteredTime and FinishedTime (#59)
@@ -30,7 +42,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
30
42
  ### Added
31
43
  - Initial release
32
44
 
33
- [Unreleased]: https://github.com/ManageIQ/floe/compare/v0.2.1...HEAD
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
34
47
  [0.2.1]: https://github.com/ManageIQ/floe/compare/v0.2.0...v0.2.1
35
48
  [0.2.0]: https://github.com/ManageIQ/floe/compare/v0.1.1...v0.2.0
36
49
  [0.1.1]: https://github.com/ManageIQ/floe/compare/v0.1.0...v0.1.1
data/lib/floe/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Floe
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
@@ -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
- super do |input|
21
- next_state_name = choices.detect { |choice| choice.true?(context, input) }&.next || default
22
- next_state = workflow.states_by_name[next_state_name]
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
- output = input
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
- logger.info("Running state: [#{name}] with input [#{input}]")
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
- super do |input|
23
- output = input
24
- output = result_path.set(output, result) if result && result_path
25
- output
26
- end
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
- @input_path = Path.new(payload.fetch("InputPath", "$"))
13
- @output_path = Path.new(payload.fetch("OutputPath", "$"))
12
+ @end = true
14
13
  end
15
14
 
16
- def end?
17
- true # TODO: Handle if this is ending a parallel or map state
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
- super do |input|
30
- input = parameters.value(context, input) if parameters
28
+ def run!(input)
29
+ input = input_path.value(context, input)
30
+ input = parameters.value(context, input) if parameters
31
31
 
32
- runner = Floe::Workflow::Runner.for_resource(resource)
33
- _exit_status, results = runner.run!(resource, input, credentials&.value({}, workflow.credentials))
32
+ runner = Floe::Workflow::Runner.for_resource(resource)
33
+ _exit_status, results = runner.run!(resource, input, credentials&.value({}, workflow.credentials))
34
34
 
35
- output = input
36
- process_output!(output, results)
37
- rescue => err
38
- retrier = self.retry.detect { |r| (r.error_equals & [err.to_s, "States.ALL"]).any? }
39
- retry if retry!(retrier)
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
- catcher = self.catch.detect { |c| (c.error_equals & [err.to_s, "States.ALL"]).any? }
42
- raise if catcher.nil?
41
+ catcher = self.catch.detect { |c| (c.error_equals & [err.to_s, "States.ALL"]).any? }
42
+ raise if catcher.nil?
43
43
 
44
- [output, workflow.states_by_name[catcher.next]]
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
- super do
21
- sleep(seconds)
22
- nil
23
- end
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,12 +18,11 @@ 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 || {"global" => {}}
25
+ @context = context
25
26
  @credentials = credentials
26
27
 
27
28
  @states = payload["States"].to_a.map { |name, state| State.build!(self, name, state) }
@@ -42,6 +43,8 @@ module Floe
42
43
 
43
44
  input = context.state["Output"] || context.execution["Input"].dup
44
45
 
46
+ logger.info("Running state: [#{current_state.name}] with input [#{input}]...")
47
+
45
48
  context.state = {
46
49
  "Guid" => SecureRandom.uuid,
47
50
  "EnteredTime" => Time.now.utc,
@@ -57,13 +60,13 @@ module Floe
57
60
  context.state["Duration"] = (tock - tick) / 1_000_000.0
58
61
  context.state["Output"] = output
59
62
 
60
- context.states << context.state
63
+ logger.info("Running state: [#{current_state.name}] with input [#{input}]...Complete - next state: [#{next_state}] output: [#{output}]")
61
64
 
62
- @status = current_state.status
63
- @output = output if end?
65
+ context.states << context.state
64
66
 
65
- next_state_name = next_state&.name
66
- @current_state = next_state_name && @states_by_name[next_state_name]
67
+ @status = current_state.status
68
+ @current_state = next_state && @states_by_name[next_state]
69
+ @output = output if end?
67
70
 
68
71
  self
69
72
  end
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:base"
5
+ ]
6
+ }
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.1
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-12 00:00:00.000000000 Z
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: []