lux 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +7 -0
  3. data/lib/lux.rb +19 -17
  4. data/lib/lux/version.rb +1 -1
  5. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17f092e16bb5301fa762d0137e24918531506458
4
- data.tar.gz: f0ff905d5f5173fdb7ed0bafb14ca14fa876b767
3
+ metadata.gz: b33a925f4741864c351ea1cd82d4ddaec70df75d
4
+ data.tar.gz: e6b6a2f15e7109c3a72238a782fcb5dd5b34883c
5
5
  SHA512:
6
- metadata.gz: 391206b1d269ae2eb0908789297c8e8c79a0b4f6b895f5ba30ac26b8a20b8c1a5b797fb4aaad4e2d58402806f64ad955cb91c80470edd495b18bc5865e6c0d08
7
- data.tar.gz: 3b28efd211f89e4b9071a62121a9a274c1f67fc2da04be69fc42b6882686be62802ad23ea13a2a7596ce9207d5a25694026a294b8ad45d9a71b0634ed1b873bd
6
+ metadata.gz: 1cb51a17a4438e7c25b3151b28c350cb82f2c7aadb7ff3d44141b7f31d71ff26207538eccfdb047f9652f43a2fecef92530f2b5c041178eada76ac55c36fd06e
7
+ data.tar.gz: 5179c4addbd373575ad0efa637b273326fd46c1502bb02521479d8ca915c36c4dfe8ed056412d61942cf340230c427b7980a36e496c487c758ddd835a59ae053
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ lux (1.0.9)
2
+
3
+ * Use docker-api gem to determine Docker URL, not environment
4
+ * Return '127.0.0.1' as address if Unix socket (for Docker for Mac)
5
+
6
+ -- Nick Townsend <nick.townsend@mac.com> Tue, 27 Dec 2016 11:12:10 -0700
7
+
1
8
  lux (1.0.8)
2
9
 
3
10
  * Don't prompt to select image if only one matches
data/lib/lux.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'highline/import'
2
+ require 'docker'
2
3
  require 'uri'
3
4
  require 'socket'
4
5
  require 'json'
@@ -10,29 +11,30 @@ module Lux
10
11
  # Determine the IPv4 address of the current Docker host
11
12
  # Used to avoid long reverse DNS lookups on .local names
12
13
  # Returns an array of four items:
13
- # - the IPv4 address as a string or nil if it couldn't be found
14
- # or wasn't an IP URL
15
- # - a string saying which variable was used, 'URL' or 'HOST'
14
+ # - the IPv4 address as a string or '127.0.0.1' if it was a Unix socket
15
+ # - Used to indicate ENV var, now empty
16
16
  # - a URI object
17
17
  # - a hash containing the Docker version information
18
18
  # Note that DOCKER_URL is used by the docker-api client, but
19
19
  # as Docker uses the misleading DOCKER_HOST we fallback to that.
20
20
  #
21
21
  def dockerip
22
- vars = ['DOCKER_URL', 'DOCKER_HOST']
23
- var, url = vars.map{|v| [v, ENV[v]]}.find{|d| d[1]}
24
- return nil, nil, nil, nil unless var
25
- uri = URI.parse(url)
26
- return nil, var, url, nil unless uri.scheme == 'tcp'
27
- addr = nil
28
- info = nil
29
- Addrinfo.tcp(uri.host, uri.port).connect(timeout: 5) {|s|
30
- addr = s.remote_address.ip_address
31
- s.print "GET /version HTTP/1.0\r\nHost: localhost\r\n\r\n"
32
- response, emptyline, body = s.read.partition(/(\r\n){2}/)
33
- info = JSON.parse(body, symbolize_names: true)
34
- } rescue nil
35
- return addr, var, uri, info
22
+ uri = URI.parse(Docker.url)
23
+ case uri.scheme
24
+ when 'unix'
25
+ addr = '127.0.0.1'
26
+ info = Docker.version
27
+ when 'tcp'
28
+ Addrinfo.tcp(uri.host, uri.port).connect(timeout: 5) {|s|
29
+ addr = s.remote_address.ip_address
30
+ s.print "GET /version HTTP/1.0\r\nHost: localhost\r\n\r\n"
31
+ response, emptyline, body = s.read.partition(/(\r\n){2}/)
32
+ info = JSON.parse(body, symbolize_names: true)
33
+ } rescue nil
34
+ else
35
+ raise "Can't handle #{uri.scheme}"
36
+ end
37
+ return addr, '', uri, info
36
38
  end
37
39
 
38
40
  # Get the current list of images and make a guess at which one it is...
data/lib/lux/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lux
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lux
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Townsend
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-28 00:00:00.000000000 Z
11
+ date: 2016-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -123,9 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.4.5.1
126
+ rubygems_version: 2.5.2
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Handy utilities for working with Docker
130
130
  test_files: []
131
- has_rdoc: