Class: Fastlane::Actions::DockerMachineClient
- Inherits:
-
Object
- Object
- Fastlane::Actions::DockerMachineClient
- Defined in:
- lib/fastlane/plugin/docker/actions/docker_machine_client.rb
Instance Method Summary collapse
- #configure_env(machine_name) ⇒ Object
- #create_machine(name) ⇒ Object
- #is_running?(machine_name) ⇒ Boolean
- #list ⇒ Object
- #machine_available?(machine_name) ⇒ Boolean
- #start(machine_name) ⇒ Object
Instance Method Details
#configure_env(machine_name) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/fastlane/plugin/docker/actions/docker_machine_client.rb', line 31 def configure_env(machine_name) instructions = (Actions.sh "docker-machine env #{machine_name} --shell sh").lines instructions.map!(&:strip).select! { |i| i =~ /^export/ } instructions.each do |i| key, value = i.split(" ").last.split("=") ENV[key] = value.chomp("\"").reverse.chomp("\"").reverse end end |
#create_machine(name) ⇒ Object
27 28 29 |
# File 'lib/fastlane/plugin/docker/actions/docker_machine_client.rb', line 27 def create_machine(name) Actions.sh "docker-machine create -d virtualbox #{name.shellescape} 1> /dev/null" end |
#is_running?(machine_name) ⇒ Boolean
19 20 21 |
# File 'lib/fastlane/plugin/docker/actions/docker_machine_client.rb', line 19 def is_running?(machine_name) Actions.sh("docker-machine status #{machine_name}").strip == "Running" end |
#list ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/fastlane/plugin/docker/actions/docker_machine_client.rb', line 7 def list script = <<SCRIPT docker-machine ls | tail -n +2 | tr -s " " "," | cut -f 1 -d "," SCRIPT machines = Actions.sh script.strip return machines.lines.map(&:strip) end |
#machine_available?(machine_name) ⇒ Boolean
15 16 17 |
# File 'lib/fastlane/plugin/docker/actions/docker_machine_client.rb', line 15 def machine_available?(machine_name) return list.include? machine_name end |
#start(machine_name) ⇒ Object
23 24 25 |
# File 'lib/fastlane/plugin/docker/actions/docker_machine_client.rb', line 23 def start(machine_name) Actions.sh("docker-machine start #{machine_name}") end |