exe/floe in floe-0.1.1 vs exe/floe in floe-0.2.0

- old
+ new

@@ -3,19 +3,37 @@ require "floe" require "optimist" opts = Optimist.options do - version "v#{Floe::VERSION}\n" - opt :workflow, "Path to your workflow json", :type => :string, :required => true - opt :inputs, "JSON payload to input to the workflow", :type => :string, :default => '{}' - opt :credentials, "JSON payload with credentials", :type => :string, :default => '{}' + version("v#{Floe::VERSION}\n") + opt :workflow, "Path to your workflow json", :type => :string, :required => true + opt :input, "JSON payload to input to the workflow", :default => '{}' + opt :credentials, "JSON payload with credentials", :default => "{}" + opt :docker_runner, "Type of runner for docker images", :default => "docker" + opt :docker_runner_options, "Options to pass to the runner", :type => :strings end +Optimist.die(:docker_runner, "must be one of #{Floe::Workflow::Runner::TYPES.join(", ")}") unless Floe::Workflow::Runner::TYPES.include?(opts[:docker_runner]) + require "logger" -Floe.logger = Logger.new(STDOUT) +Floe.logger = Logger.new($stdout) -workflow = Floe::Workflow.load(opts[:workflow], opts[:inputs], opts[:credentials]) +context = Floe::Workflow::Context.new(input: opts[:input]) +workflow = Floe::Workflow.load(opts[:workflow], context, opts[:credentials]) -output = workflow.run! +runner_klass = case opts[:docker_runner] + when "docker" + Floe::Workflow::Runner::Docker + when "podman" + Floe::Workflow::Runner::Podman + when "kubernetes" + Floe::Workflow::Runner::Kubernetes + end -puts output.inspect +runner_options = opts[:docker_runner_options].to_h { |opt| opt.split("=", 2) } + +Floe::Workflow::Runner.docker_runner = runner_klass.new(runner_options) + +workflow.run! + +puts workflow.context.state["Output"].inspect