lux 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b33a925f4741864c351ea1cd82d4ddaec70df75d
4
- data.tar.gz: e6b6a2f15e7109c3a72238a782fcb5dd5b34883c
3
+ metadata.gz: 52906a201abcf043e68aacfd17f2bd136d1ce65f
4
+ data.tar.gz: e223ae1465b5c7eb1d2ac3f2e91e09bade30ee11
5
5
  SHA512:
6
- metadata.gz: 1cb51a17a4438e7c25b3151b28c350cb82f2c7aadb7ff3d44141b7f31d71ff26207538eccfdb047f9652f43a2fecef92530f2b5c041178eada76ac55c36fd06e
7
- data.tar.gz: 5179c4addbd373575ad0efa637b273326fd46c1502bb02521479d8ca915c36c4dfe8ed056412d61942cf340230c427b7980a36e496c487c758ddd835a59ae053
6
+ metadata.gz: 5d6ad48f9e2d191d701c4ed659b86e38451c7ae5ef88ac07531e021f6dd3fa2422cac42814e97b712ea8ccb0196c4ab473e7d1da6ed159bfe9540cf797de84f3
7
+ data.tar.gz: adc4dcbae8378bf1c4f86b4ae01b245e2f101f43b14311f83f8751d3e40efe4e8e6dabc8dbbb42ea333d23c8688aa954123548b27551fdffd0be0a74f26a29c5
data/CHANGELOG CHANGED
@@ -1,3 +1,14 @@
1
+ lux (1.1.0)
2
+
3
+ Breaking changes:
4
+ * Remove variable name from dockerip() return
5
+ * Use plain strings not symbols for the version info returned by dockerip
6
+
7
+ Improvements
8
+ * Disable Docker tasks when no Docker server present
9
+
10
+ -- Nick Townsend <nick.townsend@mac.com> Wed, 28 Dec 2016 09:41:43 -0800
11
+
1
12
  lux (1.0.9)
2
13
 
3
14
  * Use docker-api gem to determine Docker URL, not environment
data/lib/lux.rb CHANGED
@@ -10,31 +10,36 @@ module Lux
10
10
 
11
11
  # Determine the IPv4 address of the current Docker host
12
12
  # Used to avoid long reverse DNS lookups on .local names
13
- # Returns an array of four items:
13
+ # Also useful when running Docker for macOS which runs on
14
+ # a Unix socket but makes container ports available on localhost
15
+ #
16
+ # Returns an array of three items:
14
17
  # - 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
18
  # - a URI object
17
19
  # - a hash containing the Docker version information
18
- # Note that DOCKER_URL is used by the docker-api client, but
19
- # as Docker uses the misleading DOCKER_HOST we fallback to that.
20
+ # These are all nil if no Docker server is found
20
21
  #
21
22
  def dockerip
22
- uri = URI.parse(Docker.url)
23
- case uri.scheme
24
- when 'unix'
25
- addr = '127.0.0.1'
23
+ begin
26
24
  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}"
25
+ uri = URI.parse Docker.url
26
+ case uri.scheme
27
+ when 'unix'
28
+ addr = '127.0.0.1'
29
+ when 'tcp'
30
+ Addrinfo.tcp(uri.host, uri.port).connect(timeout: 5) {|s|
31
+ addr = s.remote_address.ip_address
32
+ s.print "GET /version HTTP/1.0\r\nHost: localhost\r\n\r\n"
33
+ response, emptyline, body = s.read.partition(/(\r\n){2}/)
34
+ versioninfo = JSON.parse(body, symbolize_names: false)
35
+ }
36
+ else
37
+ raise "Can't handle #{uri.scheme}"
38
+ end
39
+ return addr, uri, info
40
+ rescue
41
+ return nil, nil, nil
36
42
  end
37
- return addr, '', uri, info
38
43
  end
39
44
 
40
45
  # Get the current list of images and make a guess at which one it is...
data/lib/lux/app.rb CHANGED
@@ -15,14 +15,14 @@ class Lux::App < Thor
15
15
  puts "Version #{Lux::VERSION}"
16
16
  end
17
17
 
18
- desc "check", "Check the integrity of the Git repositories"
18
+ desc "check", "Check current Git repository"
19
19
  def check
20
20
  repobranch = `git symbolic-ref -q HEAD`.chomp.gsub(%r{^.*/},'')
21
21
  puts "Repository is on branch #{repobranch}"
22
22
  `git fetch --recurse-submodules=on-demand`
23
23
  nModuleErr = 0
24
24
  nModuleWarn = 0
25
- # Inspect the submodules currently checked out in turtle
25
+ # Inspect any submodules currently checked out
26
26
  submodules = Hash[`git submodule status --recursive`.split(/\n/).map do |s|
27
27
  Lux.die "Bad submodule status #{s}" unless /^(?<flag>[-+U\s])(?<sha>[0-9a-f]{40})\s(?<path>\S+)(\s*\((?<ref>\S+)\))?$/ =~ s
28
28
  case flag
@@ -173,11 +173,17 @@ class Lux::App < Thor
173
173
  end
174
174
  end
175
175
 
176
+ # This was originally designed to allow the easy export of an IPv4 address URL for Docker
177
+ # as early Docker implementations did not honor .local addresses on macOS
178
+ #
176
179
  desc "dockerip", "Show DOCKER_HOST IP address in exportable format. Use $(lux dockerip) to set it"
177
180
  def dockerip
178
- name, var, uri, info = Lux.dockerip
179
- Lux.die "Not found: #{var}=#{uri.to_s}" unless name
180
- if uri.host != name
181
+ name, uri, info = Lux.dockerip
182
+ return Lux.info "Docker is not available" unless name
183
+
184
+ var = 'DOCKER_HOST'
185
+ case uri.scheme
186
+ when 'tcp'
181
187
  uri.host = name
182
188
  if STDOUT.isatty
183
189
  Lux.info "Please export: #{var}=#{uri.to_s}"
@@ -186,10 +192,10 @@ class Lux::App < Thor
186
192
  Lux.info "Exported: #{var}=#{uri.to_s}"
187
193
  puts "export #{var}=#{uri.to_s}"
188
194
  end
189
- else
190
- Lux.info "Found: #{var}=#{uri.to_s}"
195
+ when 'unix'
196
+ Lux.info "Docker is running on a Unix socket"
191
197
  end
192
- Lux.info "Docker version #{info[:Version]}, OS: #{info[:Os]}, Arch: #{info[:Arch]}, Kernel: #{info[:KernelVersion]}" if info
198
+ Lux.info "Version #{info['Version']}, OS: #{info['Os']}, Arch: #{info['Arch']}, Kernel: #{info['KernelVersion']}" if info
193
199
  end
194
200
 
195
201
  end
@@ -18,11 +18,11 @@ end
18
18
 
19
19
  module Lux
20
20
 
21
- addr, var, uri = Lux.dockerip
21
+ version = Docker.version rescue nil
22
22
 
23
23
  DISABLED = case
24
- when !addr && var && uri.scheme == 'tcp'
25
- error "Invalid Docker server, disabling Docker tasks!"
24
+ when version.nil?
25
+ error "Docker server not found, disabling Docker tasks!"
26
26
  true
27
27
  else
28
28
  begin
data/lib/lux/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lux
2
- VERSION = "1.0.9"
2
+ VERSION = "1.1.0"
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.9
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Townsend
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-27 00:00:00.000000000 Z
11
+ date: 2016-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor