dory 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dory/config.rb +44 -20
- data/lib/dory/dnsmasq.rb +19 -5
- data/lib/dory/docker_service.rb +12 -12
- data/lib/dory/version.rb +2 -2
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd130b3cf0b939ac79261dced4f91430d1c391ba
|
4
|
+
data.tar.gz: 2f7465a0c96d42c3a13f2d725f8b8f8e0c931a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2efd954506347e634028b6c5f7aebd0305736eba68921d3e415574bc5922def0bc4a17639054e60cfdf4796dda0b8b23b5ecd32f1e3e453a107a6f3b731e4ea5
|
7
|
+
data.tar.gz: 2393eac90e2b129a9cc60d77c1f6f35fe3bd63771d7454d129ad75769e6ce8dbeb4a1e920588f650a23f335a2f7114c5cc267643a029f17dc1e291154de12508
|
data/lib/dory/config.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
2
3
|
|
3
4
|
module Dory
|
4
5
|
class Config
|
@@ -8,7 +9,7 @@ module Dory
|
|
8
9
|
|
9
10
|
def self.default_yaml
|
10
11
|
%q(---
|
11
|
-
|
12
|
+
dory:
|
12
13
|
# Be careful if you change the settings of some of
|
13
14
|
# these services. They may not talk to each other
|
14
15
|
# if you change IP Addresses.
|
@@ -17,35 +18,38 @@ module Dory
|
|
17
18
|
# but if you disable dnsmasq, it
|
18
19
|
# will make your system look for a name server that
|
19
20
|
# doesn't exist.
|
20
|
-
|
21
|
-
|
22
|
-
:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
:
|
30
|
-
|
31
|
-
:
|
32
|
-
:
|
21
|
+
dnsmasq:
|
22
|
+
enabled: true
|
23
|
+
domains: # array of domains that will be resolved to the specified address
|
24
|
+
- domain: docker # you can set '#' for a wilcard
|
25
|
+
address: 127.0.0.1 # return for queries against the domain
|
26
|
+
- domain: dev
|
27
|
+
address: 127.0.0.1
|
28
|
+
container_name: dory_dnsmasq
|
29
|
+
nginx_proxy:
|
30
|
+
enabled: true
|
31
|
+
container_name: dory_dinghy_http_proxy
|
32
|
+
https_enabled: true
|
33
|
+
ssl_certs_dir: '' # leave as empty string to use default certs
|
34
|
+
resolv:
|
35
|
+
enabled: true
|
36
|
+
nameserver: 127.0.0.1
|
33
37
|
).split("\n").map{|s| s.sub(' ' * 8, '')}.join("\n")
|
34
38
|
end
|
35
39
|
|
36
40
|
def self.default_settings
|
37
|
-
YAML.load(self.default_yaml)
|
41
|
+
YAML.load(self.default_yaml).with_indifferent_access
|
38
42
|
end
|
39
43
|
|
40
44
|
def self.settings(filename = self.filename)
|
41
45
|
if File.exist?(filename)
|
42
|
-
|
43
|
-
config_file_settings = YAML.load_file(filename)
|
46
|
+
defaults = self.default_settings.dup
|
47
|
+
config_file_settings = YAML.load_file(filename).with_indifferent_access
|
44
48
|
[:dnsmasq, :nginx_proxy, :resolv].each do |service|
|
45
|
-
|
49
|
+
defaults[:dory][service].merge!(config_file_settings[:dory][service] || {})
|
46
50
|
end
|
47
|
-
|
48
|
-
|
51
|
+
defaults[:dory][:debug] = config_file_settings[:dory][:debug]
|
52
|
+
defaults
|
49
53
|
else
|
50
54
|
self.default_settings
|
51
55
|
end
|
@@ -60,8 +64,28 @@ module Dory
|
|
60
64
|
self.write_settings(self.default_yaml, filename, is_yaml: true)
|
61
65
|
end
|
62
66
|
|
67
|
+
def self.upgrade_settings_file(filename = self.filename)
|
68
|
+
self.write_settings(self.upgrade(self.settings), filename, is_yaml: false)
|
69
|
+
end
|
70
|
+
|
63
71
|
def self.debug?
|
64
72
|
self.settings[:dory][:debug]
|
65
73
|
end
|
74
|
+
|
75
|
+
def self.upgrade(old_hash)
|
76
|
+
newsettings = old_hash.dup
|
77
|
+
|
78
|
+
# If there's a single domain and address, upgrade to the array format
|
79
|
+
if newsettings[:dory][:dnsmasq][:domain]
|
80
|
+
newsettings[:dory][:dnsmasq][:domains] = [{
|
81
|
+
domain: newsettings[:dory][:dnsmasq][:domain],
|
82
|
+
address: newsettings[:dory][:dnsmasq][:address] || '127.0.0.1'
|
83
|
+
}]
|
84
|
+
newsettings[:dory][:dnsmasq].delete(:domain)
|
85
|
+
newsettings[:dory][:dnsmasq].delete(:address)
|
86
|
+
end
|
87
|
+
|
88
|
+
newsettings
|
89
|
+
end
|
66
90
|
end
|
67
91
|
end
|
data/lib/dory/dnsmasq.rb
CHANGED
@@ -37,25 +37,39 @@ module Dory
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.dnsmasq_image_name
|
40
|
-
'freedomben/dory-dnsmasq'
|
40
|
+
'freedomben/dory-dnsmasq:1.1.0'
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.container_name
|
44
44
|
Dory::Config.settings[:dory][:dnsmasq][:container_name]
|
45
45
|
end
|
46
46
|
|
47
|
-
def self.
|
47
|
+
def self.domains
|
48
|
+
Dory::Config.settings[:dory][:dnsmasq][:domains]
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.old_domain
|
48
52
|
Dory::Config.settings[:dory][:dnsmasq][:domain]
|
49
53
|
end
|
50
54
|
|
51
|
-
def self.
|
55
|
+
def self.old_address
|
52
56
|
Dory::Config.settings[:dory][:dnsmasq][:address]
|
53
57
|
end
|
54
58
|
|
55
|
-
def self.
|
59
|
+
def self.domain_addr_arg_string
|
60
|
+
if self.old_domain
|
61
|
+
"#{Shellwords.escape(self.old_domain)} #{Shellwords.escape(self.old_address)}"
|
62
|
+
else
|
63
|
+
self.domains.map do |domain|
|
64
|
+
"#{Shellwords.escape(domain[:domain])} #{Shellwords.escape(domain[:address])}"
|
65
|
+
end.join(" ")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.run_command(domains = self.domains)
|
56
70
|
"docker run -d -p 53:53/tcp -p 53:53/udp --name=#{Shellwords.escape(self.container_name)} " \
|
57
71
|
"--cap-add=NET_ADMIN #{Shellwords.escape(self.dnsmasq_image_name)} " \
|
58
|
-
"#{
|
72
|
+
"#{self.domain_addr_arg_string}"
|
59
73
|
end
|
60
74
|
|
61
75
|
def self.check_port(port_num)
|
data/lib/dory/docker_service.rb
CHANGED
@@ -16,18 +16,18 @@ module Dory
|
|
16
16
|
unless self.running?
|
17
17
|
self.run_preconditions
|
18
18
|
status = if self.container_exists?
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
19
|
+
if Dory::Config.debug?
|
20
|
+
puts "[DEBUG] Container '#{self.container_name}' already exists. " \
|
21
|
+
"Starting with '#{self.start_cmd}'"
|
22
|
+
end
|
23
|
+
Sh.run_command(self.start_cmd)
|
24
|
+
else
|
25
|
+
if Dory::Config.debug?
|
26
|
+
puts "[DEBUG] Container '#{self.container_name}' does not exist. " \
|
27
|
+
"Creating/starting with '#{self.run_command}'"
|
28
|
+
end
|
29
|
+
Sh.run_command(self.run_command)
|
30
|
+
end
|
31
31
|
unless status.success?
|
32
32
|
if !handle_error || !self.handle_error(status)
|
33
33
|
raise RuntimeError.new(
|
data/lib/dory/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.2'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,3 +172,4 @@ specification_version: 4
|
|
158
172
|
summary: slackbot_frd provides a dirt-simple framework for implementing one or more
|
159
173
|
slack bots
|
160
174
|
test_files: []
|
175
|
+
has_rdoc:
|