floe 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2bab2c07fd71a45bcf896aa219993770c83eedd5c4e3268c318d8b9ba0413ed
4
- data.tar.gz: 786064609be7fee8a19855cb97fd160984b5a8a7aedc85344eab01302155a988
3
+ metadata.gz: 0aac9121f1d393173b2fb11f9422f9e689693318a97dada576f054d827901024
4
+ data.tar.gz: 8118d4632e54c6fa3beb94384be517d5f3bf494890855901ce36af7ea94ee1c2
5
5
  SHA512:
6
- metadata.gz: 45a9fd8a85bb5b1059574c0dc63b0434496b6c75634c567aba9f0008400867b4dbf8c33337b3940084c644606dc3fe6065fc4f79ac5732449ca0d9675d0e2531
7
- data.tar.gz: f4147cd4e1633d2af02b7cbbd04735a9ffdc733359eb7f349b23a2fb8bada9de18a4f37fad82de543f2eb8060fa6fa52d1864a159f3ab3f780cbdab1824b6ab1
6
+ metadata.gz: 3872e70c2bb41e46570bcba95ef63716cdf3ea93bed77e9654db6614f8225982e13e3a83256b97854b6aa4376799e803f2edd5066dc3e304e75e2970c55d60f2
7
+ data.tar.gz: fac7e8815bcff8d93e443653759a6cdf8371c78f9114e3fef133212c0a1ef49d76bb35a0f491ef5abfeb134a21dc11cbbc00a6694d1f05d0e90f5bdae3471c41
data/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.5.0] - 2023-10-12
8
+ ### Added
9
+ - For task errors, use the json on the last line ([#128](https://github.com/ManageIQ/floe/pull/128))
10
+ - Add ability to pass task service account to kube runner ([#131](https://github.com/ManageIQ/floe/pull/131))
11
+
12
+ ### Fixed
13
+ - Don't put credentials file into input ([#124](https://github.com/ManageIQ/floe/pull/124))
14
+ - exe/floe return success status if the workflow was successful ([#129](https://github.com/ManageIQ/floe/pull/129))
15
+ - For error output, drop trailing newline ([#126](https://github.com/ManageIQ/floe/pull/126))
16
+
7
17
  ## [0.4.1] - 2023-10-06
8
18
  ### Added
9
19
  - Add Fail#CausePath and Fail#ErrorPath ([#110](https://github.com/ManageIQ/floe/pull/110))
@@ -4,7 +4,7 @@
4
4
  "States": {
5
5
  "FirstState": {
6
6
  "Type": "Task",
7
- "Resource": "docker://agrare/hello-world:latest",
7
+ "Resource": "docker://docker.io/agrare/hello-world:latest",
8
8
  "Credentials": {
9
9
  "mysecret": "dont tell anyone"
10
10
  },
@@ -49,13 +49,13 @@
49
49
 
50
50
  "FirstMatchState": {
51
51
  "Type" : "Task",
52
- "Resource": "docker://agrare/hello-world:latest",
52
+ "Resource": "docker://docker.io/agrare/hello-world:latest",
53
53
  "Next": "PassState"
54
54
  },
55
55
 
56
56
  "SecondMatchState": {
57
57
  "Type" : "Task",
58
- "Resource": "docker://agrare/hello-world:latest",
58
+ "Resource": "docker://docker.io/agrare/hello-world:latest",
59
59
  "Next": "NextState"
60
60
  },
61
61
 
@@ -87,7 +87,7 @@
87
87
 
88
88
  "NextState": {
89
89
  "Type": "Task",
90
- "Resource": "docker://agrare/hello-world:latest",
90
+ "Resource": "docker://docker.io/agrare/hello-world:latest",
91
91
  "Secrets": ["vmdb:aaa-bbb-ccc"],
92
92
  "End": true
93
93
  }
data/exe/floe CHANGED
@@ -37,3 +37,4 @@ workflow = Floe::Workflow.load(opts[:workflow], context, opts[:credentials])
37
37
  workflow.run!
38
38
 
39
39
  puts workflow.output.inspect
40
+ exit workflow.status == "success" ? 0 : 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.4.1"
4
+ VERSION = "0.5.0".freeze
5
5
  end
@@ -13,24 +13,6 @@ module Floe
13
13
  @network = options.fetch("network", "bridge")
14
14
  end
15
15
 
16
- def run!(resource, env = {}, secrets = {})
17
- raise ArgumentError, "Invalid resource" unless resource&.start_with?("docker://")
18
-
19
- image = resource.sub("docker://", "")
20
-
21
- secrets_file = nil
22
- if secrets && !secrets.empty?
23
- secrets_file = create_secret(secrets)
24
- env["_CREDENTIALS"] = "/run/secrets"
25
- end
26
-
27
- output = run_container(image, env, secrets_file)
28
-
29
- {"exit_code" => 0, "output" => output}
30
- ensure
31
- cleanup({"secrets_ref" => secrets_file})
32
- end
33
-
34
16
  def run_async!(resource, env = {}, secrets = {})
35
17
  raise ArgumentError, "Invalid resource" unless resource&.start_with?("docker://")
36
18
 
@@ -40,11 +22,10 @@ module Floe
40
22
 
41
23
  if secrets && !secrets.empty?
42
24
  runner_context["secrets_ref"] = create_secret(secrets)
43
- env["_CREDENTIALS"] = "/run/secrets"
44
25
  end
45
26
 
46
27
  begin
47
- runner_context["container_ref"] = run_container(image, env, runner_context["secrets_ref"], :detached => true)
28
+ runner_context["container_ref"] = run_container(image, env, runner_context["secrets_ref"])
48
29
  rescue
49
30
  cleanup(runner_context)
50
31
  raise
@@ -81,10 +62,11 @@ module Floe
81
62
 
82
63
  attr_reader :network
83
64
 
84
- def run_container(image, env, secrets_file, detached: false)
65
+ def run_container(image, env, secrets_file)
85
66
  params = ["run"]
86
- params << (detached ? :detach : :rm)
67
+ params << :detach
87
68
  params += env.map { |k, v| [:e, "#{k}=#{v}"] }
69
+ params << [:e, "_CREDENTIALS=/run/secrets"] if secrets_file
88
70
  params << [:net, "host"] if @network == "host"
89
71
  params << [:v, "#{secrets_file}:/run/secrets:z"] if secrets_file
90
72
  params << image
@@ -35,35 +35,9 @@ module Floe
35
35
 
36
36
  @namespace = options.fetch("namespace", "default")
37
37
 
38
- super
39
- end
40
-
41
- def run!(resource, env = {}, secrets = {})
42
- raise ArgumentError, "Invalid resource" unless resource&.start_with?("docker://")
43
-
44
- image = resource.sub("docker://", "")
45
- name = pod_name(image)
46
- secret = create_secret!(secrets) if secrets && !secrets.empty?
47
-
48
- begin
49
- runner_context = {"container_ref" => name}
38
+ @task_service_account = options["task_service_account"]
50
39
 
51
- create_pod!(name, image, env, secret)
52
- loop do
53
- case pod_info(name).dig("status", "phase")
54
- when "Pending", "Running"
55
- sleep(1)
56
- else # also "Succeeded"
57
- runner_context["exit_code"] = 0
58
- output(runner_context)
59
- break
60
- end
61
- end
62
-
63
- runner_context
64
- ensure
65
- cleanup({"container_ref" => name, "secrets_ref" => secret})
66
- end
40
+ super
67
41
  end
68
42
 
69
43
  def run_async!(resource, env = {}, secrets = {})
@@ -148,6 +122,8 @@ module Floe
148
122
  }
149
123
  }
150
124
 
125
+ spec[:spec][:serviceAccountName] = @task_service_account if @task_service_account
126
+
151
127
  if secret
152
128
  spec[:spec][:volumes] = [
153
129
  {
@@ -26,23 +26,6 @@ module Floe
26
26
  @volumepath = options["volumepath"]
27
27
  end
28
28
 
29
- def run!(resource, env = {}, secrets = {})
30
- raise ArgumentError, "Invalid resource" unless resource&.start_with?("docker://")
31
-
32
- image = resource.sub("docker://", "")
33
-
34
- if secrets && !secrets.empty?
35
- secret = create_secret(secrets)
36
- env["_CREDENTIALS"] = "/run/secrets/#{secret}"
37
- end
38
-
39
- output = run_container(image, env, secret)
40
-
41
- {"exit_code" => 0, :output => output}
42
- ensure
43
- delete_secret(secret) if secret
44
- end
45
-
46
29
  def run_async!(resource, env = {}, secrets = {})
47
30
  raise ArgumentError, "Invalid resource" unless resource&.start_with?("docker://")
48
31
 
@@ -50,11 +33,10 @@ module Floe
50
33
 
51
34
  if secrets && !secrets.empty?
52
35
  secret_guid = create_secret(secrets)
53
- env["_CREDENTIALS"] = "/run/secrets/#{secret_guid}"
54
36
  end
55
37
 
56
38
  begin
57
- container_id = run_container(image, env, secret_guid, :detached => true)
39
+ container_id = run_container(image, env, secret_guid)
58
40
  rescue
59
41
  cleanup({"container_ref" => container_id, "secrets_ref" => secret_guid})
60
42
  raise
@@ -89,10 +71,11 @@ module Floe
89
71
 
90
72
  private
91
73
 
92
- def run_container(image, env, secret, detached: false)
74
+ def run_container(image, env, secret)
93
75
  params = ["run"]
94
- params << (detached ? :detach : :rm)
76
+ params << :detach
95
77
  params += env.map { |k, v| [:e, "#{k}=#{v}"] }
78
+ params << [:e, "_CREDENTIALS=/run/secrets/#{secret}"] if secret
96
79
  params << [:net, "host"] if @network == "host"
97
80
  params << [:secret, secret] if secret
98
81
  params << image
@@ -127,9 +127,9 @@ module Floe
127
127
  def parse_error(output)
128
128
  return if output.nil?
129
129
 
130
- JSON.parse(output)
130
+ JSON.parse(output.split("\n").last)
131
131
  rescue JSON::ParserError
132
- {"Error" => output}
132
+ {"Error" => output.chomp}
133
133
  end
134
134
 
135
135
  def parse_output(output)
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.1
4
+ version: 0.5.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: 2023-10-06 00:00:00.000000000 Z
11
+ date: 2023-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_spawn
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
- rubygems_version: 3.3.15
155
+ rubygems_version: 3.2.33
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: Simple Workflow Runner.