Class: Floe::ContainerRunner
- Inherits:
-
Object
- Object
- Floe::ContainerRunner
- Defined in:
- lib/floe/container_runner.rb,
lib/floe/container_runner/docker.rb,
lib/floe/container_runner/podman.rb,
lib/floe/container_runner/kubernetes.rb,
lib/floe/container_runner/docker_mixin.rb
Defined Under Namespace
Modules: DockerMixin Classes: Docker, Kubernetes, Podman
Class Method Summary collapse
- .cli_options(optimist) ⇒ Object
- .resolve_cli_options!(opts) ⇒ Object
- .runner ⇒ Object
- .set_runner(name_or_instance, options = {}) ⇒ Object
Class Method Details
.cli_options(optimist) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/floe/container_runner.rb', line 11 def (optimist) optimist.("") optimist.("Container runner options:") optimist.opt :container_runner, "Type of runner for docker container images (docker, podman, or kubernetes)", :type => :string, :short => 'r' optimist.opt :container_runner_options, "Options to pass to the container runner", :type => :strings, :short => 'o' optimist.opt :docker, "Use docker to run container images (short for --container-runner=docker)", :type => :boolean optimist.opt :podman, "Use podman to run container images (short for --container-runner=podman)", :type => :boolean optimist.opt :kubernetes, "Use kubernetes to run container images (short for --container-runner=kubernetes)", :type => :boolean end |
.resolve_cli_options!(opts) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/floe/container_runner.rb', line 23 def (opts) # shortcut support opts[:container_runner] ||= "docker" if opts[:docker] opts[:container_runner] ||= "podman" if opts[:podman] opts[:container_runner] ||= "kubernetes" if opts[:kubernetes] = opts[:container_runner_options].to_h { |opt| opt.split("=", 2) } begin set_runner(opts[:container_runner], ) rescue ArgumentError => e Optimist.die(:container_runner, e.) end end |
.runner ⇒ Object
38 39 40 |
# File 'lib/floe/container_runner.rb', line 38 def runner @runner || set_runner(nil) end |
.set_runner(name_or_instance, options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/floe/container_runner.rb', line 42 def set_runner(name_or_instance, = {}) @runner = case name_or_instance when "docker", nil Floe::ContainerRunner::Docker.new() when "podman" Floe::ContainerRunner::Podman.new() when "kubernetes" Floe::ContainerRunner::Kubernetes.new() when Floe::Runner name_or_instance else raise ArgumentError, "container runner must be one of: docker, podman, kubernetes" end end |