lux 1.0.9 → 1.1.0
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 +4 -4
- data/CHANGELOG +11 -0
- data/lib/lux.rb +23 -18
- data/lib/lux/app.rb +14 -8
- data/lib/lux/docker_tasks.rb +3 -3
- data/lib/lux/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52906a201abcf043e68aacfd17f2bd136d1ce65f
|
4
|
+
data.tar.gz: e223ae1465b5c7eb1d2ac3f2e91e09bade30ee11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
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
|
-
#
|
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
|
-
|
23
|
-
case uri.scheme
|
24
|
-
when 'unix'
|
25
|
-
addr = '127.0.0.1'
|
23
|
+
begin
|
26
24
|
info = Docker.version
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
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
|
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,
|
179
|
-
Lux.
|
180
|
-
|
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
|
-
|
190
|
-
|
195
|
+
when 'unix'
|
196
|
+
Lux.info "Docker is running on a Unix socket"
|
191
197
|
end
|
192
|
-
Lux.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
|
data/lib/lux/docker_tasks.rb
CHANGED
@@ -18,11 +18,11 @@ end
|
|
18
18
|
|
19
19
|
module Lux
|
20
20
|
|
21
|
-
|
21
|
+
version = Docker.version rescue nil
|
22
22
|
|
23
23
|
DISABLED = case
|
24
|
-
when
|
25
|
-
error "
|
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
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
|
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-
|
11
|
+
date: 2016-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|