docker-sync 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/docker-sync/config.rb +7 -2
- data/lib/docker-sync/config_template.rb +6 -3
- data/lib/docker-sync/preconditions.rb +1 -2
- data/lib/docker-sync/sync_manager.rb +16 -5
- data/lib/docker-sync/sync_strategy/rsync.rb +3 -3
- data/lib/docker-sync/sync_strategy/unison.rb +3 -3
- data/tasks/sync/sync.thor +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: 2c634ad99d5e88d69c686388e3346c96b3d2c30f
|
4
|
+
data.tar.gz: d87d180c0ca6bbe42c7b29fd8d3d90ee203edfb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dbce940c38568427f7c2a845ed380caec3f41ccb6f5a3beb4d0ef16cf1913b5dc5ee4a2586785423529c242100710b09a4311d26dd436ed964e9820d86f85c9
|
7
|
+
data.tar.gz: ffa6b76d564ee17c3fa1a34e56a37138de831996cab2da60765aeb635b62150accd41579377e5dbaf9789005f71845b8c0242c5034f93ba5acc27b01c2c41c2a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/docker-sync/config.rb
CHANGED
@@ -8,7 +8,12 @@ require 'docker-sync/config_template'
|
|
8
8
|
module DockerSyncConfig
|
9
9
|
|
10
10
|
def initialize(options)
|
11
|
-
|
11
|
+
load_dotenv
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.load_dotenv
|
15
|
+
env_file = ENV.fetch('DOCKER_SYNC_ENV_FILE', '.env')
|
16
|
+
Dotenv.load(env_file)
|
12
17
|
end
|
13
18
|
|
14
19
|
def self.global_config_location
|
@@ -112,4 +117,4 @@ module DockerSyncConfig
|
|
112
117
|
def self.escape_globs(path)
|
113
118
|
path.to_s.gsub(/[*?{}\[\]]/, '\\\\\\&')
|
114
119
|
end
|
115
|
-
end
|
120
|
+
end
|
@@ -2,13 +2,16 @@ require "yaml"
|
|
2
2
|
require 'dotenv'
|
3
3
|
|
4
4
|
module ConfigTemplate
|
5
|
-
def self.
|
5
|
+
def self.interpolate_config_string(config_string)
|
6
6
|
env_hash = {}
|
7
7
|
ENV.each {|k,v| env_hash[k.to_sym] = v }
|
8
|
-
# assuming the checks that file exist have already been performed
|
9
|
-
config_string = File.read(config_path)
|
10
8
|
config_string.gsub!('${', '%{')
|
11
9
|
config_string = config_string % env_hash
|
12
10
|
return YAML.load(config_string)
|
13
11
|
end
|
12
|
+
def self.interpolate_config_file(config_path)
|
13
|
+
# assuming the checks that file exist have already been performed
|
14
|
+
config_string = File.read(config_path)
|
15
|
+
self.interpolate_config_string(config_string)
|
16
|
+
end
|
14
17
|
end
|
@@ -55,7 +55,7 @@ module Preconditions
|
|
55
55
|
if Thor::Shell::Basic.new.yes?('Shall I install unison-fsmonitor for you? (y/N)')
|
56
56
|
system cmd1
|
57
57
|
else
|
58
|
-
raise("Please install it, see https://github.com/hnsl/unox, or simply run :\n #{cmd1}
|
58
|
+
raise("Please install it, see https://github.com/hnsl/unox, or simply run :\n #{cmd1}")
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -65,7 +65,6 @@ module Preconditions
|
|
65
65
|
`python -c 'import fsevents'`
|
66
66
|
unless $?.success?
|
67
67
|
Thor::Shell::Basic.new.say_status 'warning','Could not find macfsevents. Will try to install it using pip', :red
|
68
|
-
sudo = false
|
69
68
|
if find_executable0('python') == '/usr/bin/python'
|
70
69
|
Thor::Shell::Basic.new.say_status 'ok','You seem to use the system python, we will need sudo below'
|
71
70
|
sudo = true
|
@@ -6,6 +6,7 @@ require 'docker-sync/execution'
|
|
6
6
|
require 'yaml'
|
7
7
|
require 'dotenv'
|
8
8
|
require 'docker-sync/config_template'
|
9
|
+
require 'docker-sync/config'
|
9
10
|
|
10
11
|
module Docker_sync
|
11
12
|
class SyncManager
|
@@ -16,21 +17,26 @@ module Docker_sync
|
|
16
17
|
@config_path
|
17
18
|
|
18
19
|
def initialize(options)
|
19
|
-
|
20
|
+
DockerSyncConfig.load_dotenv
|
20
21
|
|
21
22
|
@sync_processes = []
|
22
23
|
@config_syncs = []
|
23
24
|
@config_global = []
|
25
|
+
@config_string = options[:config_string]
|
24
26
|
@config_path = options[:config_path]
|
25
27
|
load_configuration
|
26
28
|
end
|
27
29
|
|
28
|
-
def
|
30
|
+
def load_configuration_file
|
29
31
|
unless File.exist?(@config_path)
|
30
32
|
raise "Config could not be loaded from #{@config_path} - it does not exist"
|
31
33
|
end
|
32
|
-
|
33
|
-
|
34
|
+
return File.read(@config_path)
|
35
|
+
end
|
36
|
+
|
37
|
+
def load_configuration
|
38
|
+
# try to interpolate supplied inline config string, alternatively load the configuration file
|
39
|
+
config = ConfigTemplate::interpolate_config_string(@config_string || load_configuration_file())
|
34
40
|
|
35
41
|
validate_config(config)
|
36
42
|
@config_global = config['options'] || {}
|
@@ -66,6 +72,11 @@ module Docker_sync
|
|
66
72
|
end
|
67
73
|
end
|
68
74
|
|
75
|
+
# set default value for 'dest'
|
76
|
+
if !@config_syncs[name].key?('dest')
|
77
|
+
@config_syncs[name]['dest'] = '/sync'
|
78
|
+
end
|
79
|
+
|
69
80
|
# for each strategy check if a custom image has been defined and inject that into the sync-endpoints
|
70
81
|
# which do fit for this strategy
|
71
82
|
%w(rsync unison).each do |strategy|
|
@@ -89,7 +100,7 @@ module Docker_sync
|
|
89
100
|
end
|
90
101
|
|
91
102
|
def validate_sync_config(name, sync_config)
|
92
|
-
config_mandatory = %w[src
|
103
|
+
config_mandatory = %w[src]
|
93
104
|
config_mandatory.push('sync_host_port') if sync_config['sync_strategy'] == 'rsync' #TODO: Implement autodisovery for other strategies
|
94
105
|
config_mandatory.each do |key|
|
95
106
|
raise ("#{name} does not have #{key} configuration value set - this is mandatory") unless sync_config.key?(key)
|
@@ -132,13 +132,13 @@ module Docker_Sync
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def stop_container
|
135
|
-
`docker stop #{get_container_name}`
|
135
|
+
`docker ps | grep #{get_container_name} && docker stop #{get_container_name}`
|
136
136
|
end
|
137
137
|
|
138
138
|
def reset_container
|
139
139
|
stop_container
|
140
|
-
`docker rm #{get_container_name}`
|
141
|
-
`docker volume rm #{get_volume_name}`
|
140
|
+
`docker ps -a | grep #{get_container_name} && docker rm #{get_container_name}`
|
141
|
+
`docker volume ls -q | grep #{get_volume_name} && docker volume rm #{get_volume_name}`
|
142
142
|
end
|
143
143
|
|
144
144
|
def clean
|
@@ -217,13 +217,13 @@ module Docker_Sync
|
|
217
217
|
end
|
218
218
|
|
219
219
|
def stop_container
|
220
|
-
`docker stop #{get_container_name}`
|
220
|
+
`docker ps | grep #{get_container_name} && docker stop #{get_container_name}`
|
221
221
|
end
|
222
222
|
|
223
223
|
def reset_container
|
224
224
|
stop_container
|
225
|
-
`docker rm #{get_container_name}`
|
226
|
-
`docker volume rm #{get_volume_name}`
|
225
|
+
`docker ps -a | grep #{get_container_name} && docker rm #{get_container_name}`
|
226
|
+
`docker volume ls -q | grep #{get_volume_name} && docker volume rm #{get_volume_name}`
|
227
227
|
end
|
228
228
|
|
229
229
|
def clean
|
data/tasks/sync/sync.thor
CHANGED
@@ -152,7 +152,7 @@ class Sync < Thor
|
|
152
152
|
|
153
153
|
# Check to see if we're already running:
|
154
154
|
if daemon_running?
|
155
|
-
say_status '
|
155
|
+
say_status 'warning', 'docker-sync already started for this configuration', :yellow
|
156
156
|
exit 1
|
157
157
|
end
|
158
158
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugen Mayer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|