floe 0.10.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -1
- data/exe/floe +35 -28
- data/lib/floe/container_runner/docker.rb +225 -0
- data/lib/floe/container_runner/docker_mixin.rb +32 -0
- data/lib/floe/container_runner/kubernetes.rb +329 -0
- data/lib/floe/container_runner/podman.rb +104 -0
- data/lib/floe/container_runner.rb +61 -0
- data/lib/floe/runner.rb +82 -0
- data/lib/floe/version.rb +1 -1
- data/lib/floe/workflow/context.rb +3 -1
- data/lib/floe/workflow/states/non_terminal_mixin.rb +3 -1
- data/lib/floe/workflow/states/pass.rb +2 -3
- data/lib/floe/workflow/states/task.rb +2 -7
- data/lib/floe.rb +2 -18
- metadata +8 -7
- data/lib/floe/workflow/runner/docker.rb +0 -227
- data/lib/floe/workflow/runner/docker_mixin.rb +0 -32
- data/lib/floe/workflow/runner/kubernetes.rb +0 -331
- data/lib/floe/workflow/runner/podman.rb +0 -106
- data/lib/floe/workflow/runner.rb +0 -77
@@ -1,106 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Floe
|
4
|
-
class Workflow
|
5
|
-
class Runner
|
6
|
-
class Podman < Floe::Workflow::Runner::Docker
|
7
|
-
DOCKER_COMMAND = "podman"
|
8
|
-
|
9
|
-
def initialize(options = {})
|
10
|
-
require "awesome_spawn"
|
11
|
-
require "securerandom"
|
12
|
-
|
13
|
-
super
|
14
|
-
|
15
|
-
@identity = options["identity"]
|
16
|
-
@log_level = options["log-level"]
|
17
|
-
@network = options["network"]
|
18
|
-
@noout = options["noout"].to_s == "true" if options.key?("noout")
|
19
|
-
@pull_policy = options["pull-policy"]
|
20
|
-
@root = options["root"]
|
21
|
-
@runroot = options["runroot"]
|
22
|
-
@runtime = options["runtime"]
|
23
|
-
@runtime_flag = options["runtime-flag"]
|
24
|
-
@storage_driver = options["storage-driver"]
|
25
|
-
@storage_opt = options["storage-opt"]
|
26
|
-
@syslog = options["syslog"].to_s == "true" if options.key?("syslog")
|
27
|
-
@tmpdir = options["tmpdir"]
|
28
|
-
@transient_store = !!options["transient-store"] if options.key?("transient-store")
|
29
|
-
@volumepath = options["volumepath"]
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def run_container_params(image, env, secret)
|
35
|
-
params = ["run"]
|
36
|
-
params << :detach
|
37
|
-
params += env.map { |k, v| [:e, "#{k}=#{v}"] }
|
38
|
-
params << [:e, "_CREDENTIALS=/run/secrets/#{secret}"] if secret
|
39
|
-
params << [:pull, @pull_policy] if @pull_policy
|
40
|
-
params << [:net, "host"] if @network == "host"
|
41
|
-
params << [:secret, secret] if secret
|
42
|
-
params << [:name, container_name(image)]
|
43
|
-
params << image
|
44
|
-
end
|
45
|
-
|
46
|
-
def create_secret(secrets)
|
47
|
-
secret_guid = SecureRandom.uuid
|
48
|
-
podman!("secret", "create", secret_guid, "-", :in_data => secrets.to_json)
|
49
|
-
secret_guid
|
50
|
-
end
|
51
|
-
|
52
|
-
def delete_secret(secret_guid)
|
53
|
-
podman!("secret", "rm", secret_guid)
|
54
|
-
rescue
|
55
|
-
nil
|
56
|
-
end
|
57
|
-
|
58
|
-
def parse_notice(notice)
|
59
|
-
id, status, exit_code = JSON.parse(notice).values_at("ID", "Status", "ContainerExitCode")
|
60
|
-
|
61
|
-
event = podman_event_status_to_event(status)
|
62
|
-
running = event != :delete
|
63
|
-
|
64
|
-
runner_context = {"container_ref" => id, "container_state" => {"Running" => running, "ExitCode" => exit_code.to_i}}
|
65
|
-
|
66
|
-
[event, runner_context]
|
67
|
-
rescue JSON::ParserError
|
68
|
-
[]
|
69
|
-
end
|
70
|
-
|
71
|
-
def podman_event_status_to_event(status)
|
72
|
-
case status
|
73
|
-
when "create"
|
74
|
-
:create
|
75
|
-
when "init", "start"
|
76
|
-
:update
|
77
|
-
when "died", "cleanup", "remove"
|
78
|
-
:delete
|
79
|
-
else
|
80
|
-
:unknown
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
alias podman! docker!
|
85
|
-
|
86
|
-
def global_docker_options
|
87
|
-
options = []
|
88
|
-
options << [:identity, @identity] if @identity
|
89
|
-
options << [:"log-level", @log_level] if @log_level
|
90
|
-
options << :noout if @noout
|
91
|
-
options << [:root, @root] if @root
|
92
|
-
options << [:runroot, @runroot] if @runroot
|
93
|
-
options << [:runtime, @runtime] if @runtime
|
94
|
-
options << [:"runtime-flag", @runtime_flag] if @runtime_flag
|
95
|
-
options << [:"storage-driver", @storage_driver] if @storage_driver
|
96
|
-
options << [:"storage-opt", @storage_opt] if @storage_opt
|
97
|
-
options << :syslog if @syslog
|
98
|
-
options << [:tmpdir, @tmpdir] if @tmpdir
|
99
|
-
options << [:"transient-store", @transient_store] if @transient_store
|
100
|
-
options << [:volumepath, @volumepath] if @volumepath
|
101
|
-
options
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
data/lib/floe/workflow/runner.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Floe
|
4
|
-
class Workflow
|
5
|
-
class Runner
|
6
|
-
include Logging
|
7
|
-
|
8
|
-
OUTPUT_MARKER = "__FLOE_OUTPUT__\n"
|
9
|
-
|
10
|
-
def initialize(_options = {})
|
11
|
-
end
|
12
|
-
|
13
|
-
@runners = {}
|
14
|
-
class << self
|
15
|
-
# deprecated -- use Floe.set_runner instead
|
16
|
-
def docker_runner=(value)
|
17
|
-
set_runner("docker", value)
|
18
|
-
end
|
19
|
-
|
20
|
-
# see Floe.set_runner
|
21
|
-
def set_runner(scheme, name_or_instance, options = {})
|
22
|
-
@runners[scheme] =
|
23
|
-
case name_or_instance
|
24
|
-
when "docker", nil
|
25
|
-
Floe::Workflow::Runner::Docker.new(options)
|
26
|
-
when "podman"
|
27
|
-
Floe::Workflow::Runner::Podman.new(options)
|
28
|
-
when "kubernetes"
|
29
|
-
Floe::Workflow::Runner::Kubernetes.new(options)
|
30
|
-
when Floe::Workflow::Runner
|
31
|
-
name_or_instance
|
32
|
-
else
|
33
|
-
raise ArgumentError, "docker runner must be one of: docker, podman, kubernetes"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def for_resource(resource)
|
38
|
-
raise ArgumentError, "resource cannot be nil" if resource.nil?
|
39
|
-
|
40
|
-
# if no runners are set, default docker:// to docker
|
41
|
-
set_runner("docker", "docker") if @runners.empty?
|
42
|
-
scheme = resource.split("://").first
|
43
|
-
@runners[scheme] || raise(ArgumentError, "Invalid resource scheme [#{scheme}]")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def run!(resource, env = {}, secrets = {})
|
48
|
-
raise NotImplementedError, "Must be implemented in a subclass"
|
49
|
-
end
|
50
|
-
|
51
|
-
# @return [Hash] runner_context
|
52
|
-
def run_async!(_image, _env = {}, _secrets = {})
|
53
|
-
raise NotImplementedError, "Must be implemented in a subclass"
|
54
|
-
end
|
55
|
-
|
56
|
-
def running?(_runner_context)
|
57
|
-
raise NotImplementedError, "Must be implemented in a subclass"
|
58
|
-
end
|
59
|
-
|
60
|
-
def success?(_runner_context)
|
61
|
-
raise NotImplementedError, "Must be implemented in a subclass"
|
62
|
-
end
|
63
|
-
|
64
|
-
def output(_runner_context)
|
65
|
-
raise NotImplementedError, "Must be implemented in a subclass"
|
66
|
-
end
|
67
|
-
|
68
|
-
def cleanup(_runner_context)
|
69
|
-
raise NotImplementedError, "Must be implemented in a subclass"
|
70
|
-
end
|
71
|
-
|
72
|
-
def wait(timeout: nil, events: %i[create update delete])
|
73
|
-
raise NotImplementedError, "Must be implemented in a subclass"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|