vagrant-adbinfo 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 588d0db71d2a61c13683f51d90d2c518f5bd2063
4
- data.tar.gz: 7860a8b536c595971661f7f5fe1c4c2ee832f1ef
3
+ metadata.gz: cc166e336921f93c13a2f97ea669a3b370021f9b
4
+ data.tar.gz: 771e12607bf9b39c14bf242e519c217fc11c298a
5
5
  SHA512:
6
- metadata.gz: dfd0a2c04047353a07da79861cef9b08df003fc04eb425aab74b86f05043d91a23fb6b90225c01ebb8bb9864d4b3d04a97d75dadb8e1ad3c325d0fd4a3883638
7
- data.tar.gz: c5c6ccde72ae89c8308afa077de0218d7cf6ad195a90d8bf3ab31e4ca2dcf7aba488466df5f4e261c9156be7f9e968808b414b3f5dfa6a0920099194f6484902
6
+ metadata.gz: cf2bde35fcecd567abb736389428847f42b1135933982bd83cdf1a5b036dbf4717dced5c82c6a22f511f590a630cffdba4e80022c04a1ed00391728d70919faa
7
+ data.tar.gz: 144915b2dfcffde6f1ff52be22b10623c68f4033de9d2d9330e7e45047c7c5403bddecb240fe008faba352f7827de0bf82cc4c7a4d91fde540f069aef1164b90
data/lib/command.rb CHANGED
@@ -24,6 +24,7 @@ module VagrantPlugins
24
24
  # Vagrant box password as defined in the Kickstart for the box <https://github.com/projectatomic/adb-atomic-developer-bundle/blob/master/build_tools/kickstarts/centos-7-kubernetes-vagrant.ks>
25
25
  # On Windows, pscp utility is used to copy the client side certs on the host, this password is used in the pscp command because the ssh keys can not be used. Details: <https://github.com/bexelbie/vagrant-adbinfo/issues/14>
26
26
  @@vagrant_box_password = "vagrant"
27
+
27
28
  def self.synopsis
28
29
  'provides the IP address:port and tls certificate file location for a docker daemon'
29
30
  end
@@ -33,45 +34,68 @@ module VagrantPlugins
33
34
  # Path to the private_key and where we will store the TLS Certificates
34
35
  secrets_path = machine.data_dir
35
36
 
37
+ hIP = machine.ssh_info[:host]
38
+ hport = machine.ssh_info[:port]
39
+ husername = machine.ssh_info[:username]
40
+ guest_ip = "127.0.0.1"
41
+ # Finds the host machine port forwarded from guest docker
42
+ port = machine.provider.capability(:forwarded_ports).key(2376)
43
+
36
44
  # First, get the TLS Certificates, if needed
37
45
  if !File.directory?(File.expand_path(".docker", secrets_path)) then
38
- # Find the ssh information
39
- hIP = machine.ssh_info[:host]
40
- hport = machine.ssh_info[:port]
41
- husername = machine.ssh_info[:username]
42
-
43
- if !OS.windows? then
46
+ if !OS.windows? then
44
47
  hprivate_key_path = machine.ssh_info[:private_key_path][0]
45
48
  # scp over the client side certs from guest to host machine
46
49
  `scp -r -P #{hport} -o LogLevel=FATAL -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i #{hprivate_key_path} #{husername}@#{hIP}:/home/vagrant/.docker #{secrets_path}`
47
- # extending the .docker path to include
48
- secrets_path = File.expand_path(".docker", secrets_path)
49
50
  else
50
51
  `pscp -r -P #{hport} -pw #@@vagrant_box_password -p #{husername}@#{hIP}:/home/vagrant/.docker #{secrets_path}`
51
- # extending the .docker path to include
52
- secrets_path = File.expand_path(".docker", secrets_path)
53
- secrets_path = secrets_path.split('/').join('\\') + '\\'
54
52
  end
55
53
  end
54
+
55
+ # display the information, irrespective of the copy operation
56
+ print_info(guest_ip, port, secrets_path, machine.index_uuid)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
56
62
 
57
- # Finds the host machine port forwarded from guest docker
58
- port = machine.provider.capability(:forwarded_ports).key(2376)
59
- guest_ip = "127.0.0.1"
60
63
 
61
- # Print configuration information for accesing the docker daemon
62
- message =
63
- <<-eos
64
- Set the following environment variables to enable access to the
65
- docker daemon running inside of the vagrant virtual machine:
64
+ def print_info(guest_ip, port, secrets_path, machine_uuid)
65
+ # Print configuration information for accesing the docker daemon
66
+
67
+ # extending the .docker path to include
68
+ secrets_path = File.expand_path(".docker", secrets_path)
69
+
70
+ if !OS.windows? then
71
+ message =
72
+ <<-eos
73
+ # Set the following environment variables to enable access to the
74
+ # docker daemon running inside of the vagrant virtual machine:
66
75
 
67
76
  export DOCKER_HOST=tcp://#{guest_ip}:#{port}
68
77
  export DOCKER_CERT_PATH=#{secrets_path}
69
78
  export DOCKER_TLS_VERIFY=1
70
- export DOCKER_MACHINE_NAME=#{machine.index_uuid[0..6]}
71
- eos
72
- @env.ui.info(puts(message))
73
- end
74
- end
75
- end
76
- end
79
+ export DOCKER_MACHINE_NAME=#{machine_uuid[0..6]}
80
+
81
+ # run following command to configure your shell:
82
+ # eval "$(vagrant adb-info)"
83
+ eos
84
+ @env.ui.info(message)
85
+ else
86
+ # replace / with \ for path in Windows
87
+ secrets_path = secrets_path.split('/').join('\\') + '\\'
88
+ message =
89
+ <<-eos
90
+ # Set the following environment variables to enable access to the
91
+ # docker daemon running inside of the vagrant virtual machine:
92
+
93
+ setx DOCKER_HOST tcp://#{guest_ip}:#{port}
94
+ setx DOCKER_CERT_PATH #{secrets_path}
95
+ setx DOCKER_TLS_VERIFY 1
96
+ setx DOCKER_MACHINE_NAME #{machine_uuid[0..6]}
97
+ eos
98
+ # puts is used here to escape and render the back slashes in Windows path
99
+ @env.ui.info(puts(message))
100
+ end
77
101
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'vagrant-adbinfo'
3
- spec.version = '0.0.4'
3
+ spec.version = '0.0.5'
4
4
  spec.homepage = 'https://github.com/bexelbie/vagrant-adbinfo'
5
5
  spec.summary = 'Vagrant plugin that provides the IP address:port and tls certificate file location for a docker daemon'
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-adbinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Exelbierd
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-09 00:00:00.000000000 Z
12
+ date: 2015-11-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler