Module: Mcrain::Boot2docker
- Defined in:
- lib/mcrain/boot2docker.rb
Class Attribute Summary collapse
-
.certs_dir ⇒ Object
Returns the value of attribute certs_dir.
Class Method Summary collapse
- .build_docker_options(uri) ⇒ Object
- .download_files_from_vm(host, files) ⇒ Object
- .preparing_command ⇒ Object
- .setup_docker_options ⇒ Object
- .used? ⇒ Boolean
Class Attribute Details
.certs_dir ⇒ Object
Returns the value of attribute certs_dir.
14 15 16 |
# File 'lib/mcrain/boot2docker.rb', line 14 def certs_dir @certs_dir end |
Class Method Details
.build_docker_options(uri) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mcrain/boot2docker.rb', line 43 def (uri) d = Boot2docker.certs_dir cert_path = File.join(d, "cert.pem") key_path = File.join(d, "key.pem") files = { ".docker/cert.pem" => cert_path, ".docker/key.pem" => key_path, } download_files_from_vm(uri.host, files) return { client_cert: cert_path, client_key: key_path, scheme: 'https', } end |
.download_files_from_vm(host, files) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/mcrain/boot2docker.rb', line 61 def download_files_from_vm(host, files) return if files.values.all?{|f| File.readable?(f)} files.values.each{|f| FileUtils.mkdir_p(File.dirname(f))} Net::SCP.start(host, "docker", :password => "tcuser") do |scp| files.each do |src, dest| scp.download(src, dest) end end end |
.preparing_command ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/mcrain/boot2docker.rb', line 24 def preparing_command return "" unless used? unless `boot2docker status`.strip == "running" raise "boot2docker is not running. Please `boot2docker start`" end "%s && " % `boot2docker shellinit`.strip.split(/\n/).join(" && ") end |
.setup_docker_options ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mcrain/boot2docker.rb', line 32 def if RbConfig::CONFIG["host_os"] =~ /darwin/ require 'docker' uri = URI.parse(ENV["DOCKER_HOST"]) Excon.defaults[:ssl_verify_peer] = false Docker. = (uri) elsif ENV["DOCKER_HOST"].nil? ENV["DOCKER_HOST"] = "http://localhost:2375" end end |
.used? ⇒ Boolean
20 21 22 |
# File 'lib/mcrain/boot2docker.rb', line 20 def used? RbConfig::CONFIG["host_os"] =~ /darwin/ end |