Class: ManageIQ::Floe::Workflow::Runner::Docker
- Inherits:
-
ManageIQ::Floe::Workflow::Runner
- Object
- ManageIQ::Floe::Workflow::Runner
- ManageIQ::Floe::Workflow::Runner::Docker
- Defined in:
- lib/manageiq/floe/workflow/runner/docker.rb
Instance Method Summary collapse
-
#initialize ⇒ Docker
constructor
A new instance of Docker.
- #run!(resource, env = {}, secrets = {}) ⇒ Object
Methods inherited from ManageIQ::Floe::Workflow::Runner
Methods included from Logging
Constructor Details
#initialize ⇒ Docker
Returns a new instance of Docker.
6 7 8 9 10 11 |
# File 'lib/manageiq/floe/workflow/runner/docker.rb', line 6 def initialize(*) require "awesome_spawn" require "tempfile" super end |
Instance Method Details
#run!(resource, env = {}, secrets = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/manageiq/floe/workflow/runner/docker.rb', line 13 def run!(resource, env = {}, secrets = {}) raise ArgumentError, "Invalid resource" unless resource&.start_with?("docker://") image = resource.sub("docker://", "") params = ["run", :rm, [:net, "host"]] params += env.map { |k, v| [:e, "#{k}=#{v}"] } if env secrets_file = nil if secrets && !secrets.empty? secrets_file = Tempfile.new secrets_file.write(secrets.to_json) secrets_file.flush params << [:e, "SECRETS=/run/secrets"] params << [:v, "#{secrets_file.path}:/run/secrets:z"] end params << image logger.debug("Running docker: #{AwesomeSpawn.build_command_line("docker", params)}") result = AwesomeSpawn.run!("docker", :params => params) [result.exit_status, result.output] ensure secrets_file&.close! end |