Class: DockerEnvCommand
- Inherits:
-
Object
- Object
- DockerEnvCommand
- Defined in:
- lib/vagrant/docker/env/command.rb
Overview
Reads the docker env from the global $DOCKER_ENV
Instance Method Summary collapse
- #execute ⇒ Object
- #execute_subcommand(subcommand) ⇒ Object
- #load_config ⇒ Object
- #print_env ⇒ Object
Instance Method Details
#execute ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vagrant/docker/env/command.rb', line 6 def execute marker_found = false subcommand, _ = ARGV.partition do |e| marker_found.tap do |_| marker_found = true if e == '--' end end load_config if subcommand.empty? print_env else execute_subcommand(subcommand) end 0 end |
#execute_subcommand(subcommand) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/vagrant/docker/env/command.rb', line 27 def execute_subcommand(subcommand) ($DOCKER_ENV || {}).each do |k,v| ENV[k.to_s] = v end system(*subcommand) end |
#load_config ⇒ Object
22 23 24 25 |
# File 'lib/vagrant/docker/env/command.rb', line 22 def load_config loader = @env.config_loader loader.load([]) end |
#print_env ⇒ Object
34 35 36 37 38 39 |
# File 'lib/vagrant/docker/env/command.rb', line 34 def print_env str = ($DOCKER_ENV || {}).map do |k,v| "export #{k}=\"#{v}\"" end.join("\n") STDOUT.puts str end |