docker-sync 0.0.11 → 0.0.12

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: 5187439aee543a2580cae6188d1ff4e36a2d2fdc
4
- data.tar.gz: 63ee4e96be043f0c1b7744e63c2c5da14575c2e9
3
+ metadata.gz: 22787f972ef84ff342df17b05894ec25b79ec521
4
+ data.tar.gz: 5d7a83c05ec3194d7292b9f2ab2798bfc9909c76
5
5
  SHA512:
6
- metadata.gz: 45f6b738ef5138f7a9617694c519d83713cc7af09607f6ace0b3fd1125b37b820de4646448c09866c94d6ea325a729b81dc9bd88fab4524a138a8a114b34ff8d
7
- data.tar.gz: 444d000796341735047b6f725e39ab2cbaa8bf1131161d6d1c093544d68328b5a48ad2b284f005137a2c05e32b81dd88d17b215889a935cf479a83461c192470
6
+ metadata.gz: 4a5141387dd95c343f467c9d72bc32038b953e2ec56d5d71ff8e378b667a230333bb8345c5bc049c31c7e6e5d2fa8a9a2c54ea8eef7b1d7eef427adcf1603f12
7
+ data.tar.gz: 8ddf36c4068404754d969de94d00a70ea56a528f4d127fc600b7d01d656f39b2430e6bc63f30c55a4cba4df85a7555875e6474bb0747e1277f93d7d6009c7f68
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.0.12
@@ -2,7 +2,7 @@
2
2
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
3
 
4
4
  require 'thor'
5
- require 'update_check'
5
+ require 'docker-sync/update_check'
6
6
 
7
7
  thor = File.expand_path('../../tasks/sync', __FILE__)
8
8
  Dir.glob(File.join(thor, '/**/*.thor')).each { |taskfile|
@@ -2,17 +2,17 @@
2
2
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
3
 
4
4
  require 'thor'
5
- require 'update_check'
5
+ require 'docker-sync/update_check'
6
6
 
7
- # ensure docker-compose is installed, if not, do so
8
- begin
9
- gem 'docker-compose'
10
- rescue Gem::LoadError
11
- puts "docker-compose gem is missing, installing 'gem install docker-compose'"
12
- system('gem install docker-compose')
13
- puts 'docker-compose ruby gem installed, please start docker-sync-stack again'
14
- exit 0
15
- end
7
+ # TODO: remove this later, not longer needed
8
+ #begin
9
+ # gem 'docker-compose'
10
+ #rescue Gem::LoadError
11
+ # puts "docker-compose gem is missing, installing 'gem install docker-compose'"
12
+ # system('gem install docker-compose')
13
+ # puts 'docker-compose ruby gem installed, please start docker-sync-stack again'
14
+ # exit 0
15
+ #end
16
16
 
17
17
  thor = File.expand_path('../../tasks/stack', __FILE__)
18
18
  Dir.glob(File.join(thor, '/**/*.thor')).each { |taskfile|
@@ -0,0 +1,33 @@
1
+ require 'docker/compose'
2
+
3
+ class ComposeManager
4
+ include Thor::Shell
5
+ @compose_session
6
+ @global_options
7
+ def initialize(global_options)
8
+ @global_options = global_options
9
+ compose_file_path = 'docker-compose.yml'
10
+ if @global_options.key?('compose-file-path')
11
+ path = File.expand_path(@global_options['compose-file-path'])
12
+ unless File.exist?(path)
13
+ raise("Your referenced docker-compose file in docker-sync.yml was not found at #{@global_options['compose-file-path']}")
14
+ end
15
+ compose_file_path = @global_options['compose-file-path']
16
+ end
17
+ @compose_session = Docker::Compose::Session.new(dir:'./', :file => compose_file_path)
18
+ end
19
+
20
+ def run
21
+ say_status 'ok','starting compose',:white
22
+ @compose_session.up
23
+ say_status 'success','started compose',:green
24
+ end
25
+
26
+ def stop
27
+ @compose_session.stop
28
+ end
29
+
30
+ def clean
31
+ @compose_session.down
32
+ end
33
+ end
@@ -4,18 +4,19 @@ require 'yaml'
4
4
  # this has basically completely reused from Thor::runner.rb - thank you!
5
5
 
6
6
  module DockerSyncConfig
7
- def global_config_location
7
+ def self.global_config_location
8
8
  return File.expand_path('~/.docker-sync-global.yml')
9
9
  end
10
10
 
11
- def is_first_run
11
+ def self.is_first_run
12
12
  global_config_path = global_config_location
13
13
  return !File.exist?(global_config_path)
14
14
  end
15
15
 
16
- def global_config
16
+ def self.global_config
17
17
  global_config_path = global_config_location
18
18
  date = DateTime.new(2001, 1, 1) #paste
19
+ # noinspection RubyStringKeysInHashInspection
19
20
  defaults = {'update_check'=>true, 'update_last_check' => date.iso8601(9), 'update_enforce' => true}
20
21
  if File.exist?(global_config_path)
21
22
  config = YAML.load_file(global_config_path)
@@ -26,13 +27,13 @@ module DockerSyncConfig
26
27
  end
27
28
  end
28
29
 
29
- def global_config_save(config)
30
+ def self.global_config_save(config)
30
31
  global_config_path = global_config_location
31
32
  File.open(global_config_path, 'w') {|f| f.write config.to_yaml }
32
33
  end
33
34
 
34
- def find_config
35
- files = find_config_file
35
+ def self.project_config_path
36
+ files = project_config_find
36
37
  if files.length > 0
37
38
  return files.pop
38
39
  else
@@ -41,7 +42,7 @@ module DockerSyncConfig
41
42
  end
42
43
 
43
44
  # this has been ruthlessly stolen from Thor/runner.rb - please do not hunt me for that :)
44
- def find_config_file(skip_lookup = false)
45
+ def self.project_config_find(skip_lookup = false)
45
46
  # Finds docker-sync.yml by traversing from your current directory down to the root
46
47
  # directory of your system. If at any time we find a docker-sync.yml file, we stop.
47
48
  #
@@ -66,7 +67,7 @@ module DockerSyncConfig
66
67
 
67
68
  unless skip_lookup
68
69
  Pathname.pwd.ascend do |path|
69
- docker_sync_files = globs_for_config(path).map { |g| Dir[g] }.flatten
70
+ docker_sync_files = globs_for_project_config(path).map { |g| Dir[g] }.flatten
70
71
  break unless docker_sync_files.empty?
71
72
  end
72
73
  end
@@ -77,12 +78,12 @@ module DockerSyncConfig
77
78
 
78
79
  # Where to look for docker-sync.yml files.
79
80
  #
80
- def globs_for_config(path)
81
+ def self.globs_for_project_config(path)
81
82
  path = escape_globs(path)
82
83
  ["#{path}/docker-sync.yml"]
83
84
  end
84
85
 
85
- def escape_globs(path)
86
+ def self.escape_globs(path)
86
87
  path.to_s.gsub(/[*?{}\[\]]/, '\\\\\\&')
87
88
  end
88
89
  end
@@ -17,14 +17,16 @@ module Execution
17
17
  end
18
18
 
19
19
  Thread.new {
20
- Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
20
+ Open3.popen3(command) do |_, stdout, stderr, _|
21
21
 
22
- while lineOut = stdout.gets
23
- say_status prefix, lineOut, color
22
+ # noinspection RubyAssignmentExpressionInConditionalInspection
23
+ while line_out = stdout.gets
24
+ say_status prefix, line_out, color
24
25
  end
25
26
 
26
- while lineErr = stderr.gets
27
- say_status prefix, lineErr, :red
27
+ # noinspection RubyAssignmentExpressionInConditionalInspection
28
+ while line_err = stderr.gets
29
+ say_status prefix, line_err, :red
28
30
  end
29
31
 
30
32
  end
@@ -1,44 +1,44 @@
1
1
  require 'mkmf'
2
2
 
3
3
  module Preconditions
4
- def check_all_preconditions
4
+ def self.check_all_preconditions
5
5
  docker_available
6
6
  docker_running
7
7
  fswatch_available
8
8
  end
9
9
 
10
- def docker_available
10
+ def self.docker_available
11
11
  if (find_executable0 'docker').nil?
12
12
  raise('Could not find docker binary in path. Please install it, e.g. using "brew install docker" or install docker-for-mac')
13
13
  end
14
14
  end
15
15
 
16
- def docker_running
16
+ def self.docker_running
17
17
  `docker ps`
18
18
  if $?.exitstatus > 0
19
19
  raise('No docker daemon seems to be running. Did you start your docker-for-mac / docker-machine?')
20
20
  end
21
21
  end
22
22
 
23
- def fswatch_available
23
+ def self.fswatch_available
24
24
  if (find_executable0 'fswatch').nil?
25
25
  raise('No fswatch available. Install it by "brew install fswatch"')
26
26
  end
27
27
  end
28
28
 
29
- def docker_sync_available
29
+ def self.docker_sync_available
30
30
  if (find_executable0 'docker-sync').nil?
31
31
  raise('No docker-sync available. Install it by "gem install docker-sync"')
32
32
  end
33
33
  end
34
34
 
35
- def rsync_available
35
+ def self.rsync_available
36
36
  if (find_executable0 'rsync').nil?
37
37
  raise('Could not find rsync binary in path. Please install it, e.g. using "brew install rsync"')
38
38
  end
39
39
  end
40
40
 
41
- def unison_available
41
+ def self.unison_available
42
42
  if (find_executable0 'unison').nil?
43
43
  raise('Could not find unison binary in path. Please install it, e.g. using "brew install unison"')
44
44
  end
@@ -1,8 +1,8 @@
1
1
  require 'thor/shell'
2
2
  # noinspection RubyResolve
3
- require 'docker_sync/sync_process'
3
+ require 'docker-sync/sync_process'
4
4
  # noinspection RubyResolve
5
- require 'execution'
5
+ require 'docker-sync/execution'
6
6
  require 'yaml'
7
7
 
8
8
  module Docker_Rsync
@@ -17,7 +17,6 @@ module Docker_Rsync
17
17
  @sync_processes = []
18
18
  @config_syncs = []
19
19
  @config_options = []
20
- @config_syncs = []
21
20
  @config_path = options[:config_path]
22
21
  load_configuration
23
22
  end
@@ -34,6 +33,10 @@ module Docker_Rsync
34
33
  upgrade_syncs_config
35
34
  end
36
35
 
36
+ def global_options
37
+ return @config_options
38
+ end
39
+
37
40
  def get_sync_points
38
41
  return @config_syncs
39
42
  end
@@ -41,13 +44,24 @@ module Docker_Rsync
41
44
  def upgrade_syncs_config
42
45
  @config_syncs.each do |name, config|
43
46
  @config_syncs[name]['config_path'] = @config_path
47
+ # expand the sync source to remove ~ and similar expressions in the path
44
48
  @config_syncs[name]['src'] = File.expand_path(@config_syncs[name]['src'])
49
+
50
+ # set the global verbose setting, if the sync-endpoint does not define a own one
45
51
  unless config.key?('verbose')
46
52
  @config_syncs[name]['verbose'] = false
47
53
  if @config_options.key?('verbose')
48
54
  @config_syncs[name]['verbose'] = @config_options['verbose']
49
55
  end
50
56
  end
57
+
58
+ # for each strategy check if a custom image has been defined and inject that into the sync-endpoints
59
+ # which do fit for this strategy
60
+ %w(rsync unison).each do |strategy|
61
+ if config.key?("#{strategy}_image") && @config_syncs[name]['sync_strategy'] == strategy
62
+ @config_syncs[name]['image'] = config["#{strategy}_image"]
63
+ end
64
+ end
51
65
  end
52
66
  end
53
67
 
@@ -108,7 +122,7 @@ module Docker_Rsync
108
122
  def join_threads
109
123
  begin
110
124
  @sync_processes.each do |sync_process|
111
- sync_process.watch_thread.join
125
+ sync_process.watch_thread.join unless sync_process.watch_thread.nil?
112
126
  end
113
127
 
114
128
  rescue SystemExit, Interrupt
@@ -132,7 +146,7 @@ module Docker_Rsync
132
146
  @sync_processes.each { |sync_process|
133
147
  sync_process.stop
134
148
  unless sync_process.watch_thread.nil?
135
- sync_process.watch_thread.kill
149
+ sync_process.watch_thread.kill unless sync_process.watch_thread.nil?
136
150
  end
137
151
  }
138
152
  end
@@ -1,9 +1,10 @@
1
1
  require 'thor/shell'
2
2
  # noinspection RubyResolve
3
- require 'docker_sync/sync_strategy/rsync'
4
- require 'docker_sync/sync_strategy/unison'
3
+ require 'docker-sync/sync_strategy/rsync'
4
+ require 'docker-sync/sync_strategy/unison'
5
5
  # noinspection RubyResolve
6
- require 'docker_sync/watch_strategy/fswatch'
6
+ require 'docker-sync/watch_strategy/fswatch'
7
+ require 'docker-sync/watch_strategy/dummy'
7
8
 
8
9
  module Docker_Sync
9
10
  class SyncProcess
@@ -48,6 +49,10 @@ module Docker_Sync
48
49
  case @options['watch_strategy']
49
50
  when 'fswatch'
50
51
  @watch_strategy = Docker_Sync::WatchStrategy::Fswatch.new(@sync_name, @options)
52
+ when 'disable'
53
+ @watch_strategy = Docker_Sync::WatchStrategy::Dummy.new(@sync_name, @options)
54
+ when 'dummy'
55
+ @watch_strategy = Docker_Sync::WatchStrategy::Dummy.new(@sync_name, @options)
51
56
  else
52
57
  @watch_strategy = Docker_Sync::WatchStrategy::Fswatch.new(@sync_name, @options)
53
58
  end
@@ -1,11 +1,10 @@
1
1
  require 'thor/shell'
2
- require 'preconditions'
2
+ require 'docker-sync/preconditions'
3
3
 
4
4
  module Docker_Sync
5
5
  module SyncStrategy
6
6
  class Rsync
7
7
  include Thor::Shell
8
- include Preconditions
9
8
 
10
9
  @options
11
10
  @sync_name
@@ -14,9 +13,15 @@ module Docker_Sync
14
13
  def initialize(sync_name, options)
15
14
  @sync_name = sync_name
16
15
  @options = options
16
+ # if a custom image is set, apply it
17
+ if @options.key?('image')
18
+ @docker_image = @options['image']
19
+ else
20
+ @docker_image = 'eugenmayer/rsync'
21
+ end
17
22
 
18
23
  begin
19
- rsync_available
24
+ Preconditions::rsync_available
20
25
  rescue Exception => e
21
26
  say_status 'error', "#{@sync_name} has been configured to sync with rsync, but no rsync binary available", :red
22
27
  say_status 'error', e.message, :red
@@ -88,7 +93,7 @@ module Docker_Sync
88
93
  user_mapping = get_user_mapping
89
94
  group_mapping = get_group_mapping
90
95
 
91
- cmd = "docker run -p '#{@options['sync_host_port']}:873' -v #{volume_name}:#{@options['dest']} #{user_mapping} #{group_mapping} -e VOLUME=#{@options['dest']} --name #{container_name} -d eugenmayer/rsync"
96
+ cmd = "docker run -p '#{@options['sync_host_port']}:873' -v #{volume_name}:#{@options['dest']} #{user_mapping} #{group_mapping} -e VOLUME=#{@options['dest']} --name #{container_name} -d #{@docker_image}"
92
97
  else # container already created, just start / reuse it
93
98
  say_status 'ok', "starting #{container_name} container", :white if @options['verbose']
94
99
  cmd = "docker start #{container_name}"
@@ -1,26 +1,27 @@
1
1
  require 'thor/shell'
2
- require 'preconditions'
2
+ require 'docker-sync/preconditions'
3
3
  require 'open3'
4
4
 
5
5
  module Docker_Sync
6
6
  module SyncStrategy
7
7
  class Unison
8
8
  include Thor::Shell
9
- include Preconditions
10
-
11
9
 
12
10
  @options
13
11
  @sync_name
14
12
  @watch_thread
15
- UNISON_IMAGE = 'leighmcculloch/unison'
16
- UNISON_VERSION = '2.48.3'
17
13
  UNISON_CONTAINER_PORT = '5000'
18
14
  def initialize(sync_name, options)
19
15
  @sync_name = sync_name
20
16
  @options = options
21
-
17
+ # if a custom image is set, apply it
18
+ if @options.key?('image')
19
+ @docker_image = @options['image']
20
+ else
21
+ @docker_image = 'eugenmayer/unison'
22
+ end
22
23
  begin
23
- unison_available
24
+ Preconditions::unison_available
24
25
  rescue Exception => e
25
26
  say_status 'error', "#{@sync_name} has been configured to sync with unison, but no unison available", :red
26
27
  say_status 'error', e.message, :red
@@ -80,7 +81,7 @@ module Docker_Sync
80
81
  exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" | grep #{container_name}`
81
82
  if exists == ''
82
83
  say_status 'ok', "creating #{container_name} container", :white if @options['verbose']
83
- cmd = "docker run -p '#{@options['sync_host_port']}:#{UNISON_CONTAINER_PORT}' -v #{volume_name}:#{@options['dest']} -e UNISON_VERSION=#{UNISON_VERSION} -e UNISON_WORKING_DIR=#{@options['dest']} --name #{container_name} -d #{UNISON_IMAGE}"
84
+ cmd = "docker run -p '#{@options['sync_host_port']}:#{UNISON_CONTAINER_PORT}' -v #{volume_name}:#{@options['dest']} -e UNISON_DIR=#{@options['dest']} --name #{container_name} -d #{@docker_image}"
84
85
  else
85
86
  say_status 'ok', "starting #{container_name} container", :white if @options['verbose']
86
87
  cmd = "docker start #{container_name}"
@@ -1,13 +1,12 @@
1
1
  require 'gem_update_checker'
2
2
  require 'thor/actions'
3
- require 'config'
3
+ require 'docker-sync/config'
4
4
 
5
5
  class UpdateChecker
6
6
  include Thor::Shell
7
- include DockerSyncConfig
8
7
  @config
9
8
  def initialize
10
- @config = global_config
9
+ @config = DockerSyncConfig::global_config
11
10
  end
12
11
 
13
12
  def run
@@ -18,7 +17,7 @@ class UpdateChecker
18
17
  unless should_run
19
18
  return
20
19
  end
21
- check_rsync_image unless is_first_run # do not check the image if its the first run - since this it will be downloaded anyway
20
+ check_rsync_image unless DockerSyncConfig::is_first_run # do not check the image if its the first run - since this it will be downloaded anyway
22
21
  check_and_warn(@config['update_enforce'])
23
22
  end
24
23
 
@@ -46,7 +45,7 @@ class UpdateChecker
46
45
  end
47
46
 
48
47
  def get_current_version
49
- path = File.expand_path('../../', __FILE__)
48
+ path = File.expand_path('../../../', __FILE__)
50
49
  return File.read("#{path}/VERSION")
51
50
  end
52
51
 
@@ -61,7 +60,7 @@ class UpdateChecker
61
60
  # update the timestamp
62
61
  now = DateTime.now
63
62
  @config['update_last_check'] = now.iso8601(9)
64
- global_config_save(@config)
63
+ DockerSyncConfig::global_config_save(@config)
65
64
 
66
65
  check = docker_sync_update_check
67
66
  if check.update_available
@@ -0,0 +1,42 @@
1
+ require 'thor/shell'
2
+ require 'docker-sync/execution'
3
+ require 'docker-sync/preconditions'
4
+
5
+ module Docker_Sync
6
+ module WatchStrategy
7
+ class Dummy
8
+ include Thor::Shell
9
+ include Execution
10
+
11
+ @options
12
+ @sync_name
13
+ @watch_thread
14
+
15
+ def initialize(sync_name, options)
16
+ @options = options
17
+ @sync_name = sync_name
18
+ @watch_thread = nil
19
+ end
20
+
21
+ def run
22
+ say_status 'success', 'Watcher disabled by configuration' if @options['verbose']
23
+ end
24
+
25
+ def stop
26
+ end
27
+
28
+ def clean
29
+ end
30
+
31
+ def watch
32
+ end
33
+
34
+ def watch_options
35
+ end
36
+
37
+ def watch_thread
38
+ return @watch_thread
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,13 +1,12 @@
1
1
  require 'thor/shell'
2
- require 'execution'
3
- require 'preconditions'
2
+ require 'docker-sync/execution'
3
+ require 'docker-sync/preconditions'
4
4
 
5
5
  module Docker_Sync
6
6
  module WatchStrategy
7
7
  class Fswatch
8
8
  include Thor::Shell
9
9
  include Execution
10
- include Preconditions
11
10
 
12
11
  @options
13
12
  @sync_name
@@ -18,7 +17,7 @@ module Docker_Sync
18
17
  @options = options
19
18
 
20
19
  begin
21
- fswatch_available
20
+ Preconditions::fswatch_available
22
21
  rescue Exception => e
23
22
  say_status 'error', e.message, :red
24
23
  exit 1
@@ -56,7 +55,7 @@ module Docker_Sync
56
55
 
57
56
  sync_command = 'thor sync:sync'
58
57
  begin
59
- docker_sync_available
58
+ Preconditions::docker_sync_available
60
59
  sync_command = 'docker-sync sync'
61
60
  rescue Exception => e
62
61
  say_status 'warning', 'docker-sync not available, assuming dev mode, using thor', :yellow
@@ -1,13 +1,10 @@
1
- require 'docker_sync/sync_manager'
2
- require 'config'
3
- require 'preconditions'
4
- require 'update_check'
5
- require 'compose'
6
-
1
+ require 'docker-sync/sync_manager'
2
+ require 'docker-sync/config'
3
+ require 'docker-sync/preconditions'
4
+ require 'docker-sync/update_check'
5
+ require 'docker/compose'
6
+ require 'docker-sync/compose'
7
7
  class Stack < Thor
8
- include DockerSyncConfig
9
- include Preconditions
10
-
11
8
  class_option :config, :aliases => '-c', :default => nil, :type => :string, :desc => 'Path of the docker_sync config'
12
9
  class_option :sync_name, :aliases => '-n', :type => :string, :desc => 'If given, only this sync configuration will be references/started/synced'
13
10
 
@@ -19,7 +16,7 @@ class Stack < Thor
19
16
  updates.run
20
17
 
21
18
  begin
22
- check_all_preconditions
19
+ Preconditions::check_all_preconditions
23
20
  rescue Exception => e
24
21
  say_status 'error', e.message, :red
25
22
  exit 1
@@ -29,7 +26,7 @@ class Stack < Thor
29
26
  config_path = options[:config]
30
27
  else
31
28
  begin
32
- config_path = find_config
29
+ config_path = DockerSyncConfig::project_config_path
33
30
  rescue Exception => e
34
31
  say_status 'error', e.message, :red
35
32
  return
@@ -38,8 +35,8 @@ class Stack < Thor
38
35
 
39
36
  @sync_manager = Docker_Rsync::SyncManager.new(:config_path => config_path)
40
37
  @sync_manager.run(options[:sync_name])
41
-
42
- @compose_manager = ComposeManager.new
38
+ global_options = @sync_manager.global_options
39
+ @compose_manager = ComposeManager.new(global_options)
43
40
 
44
41
  compose_thread = Thread.new {
45
42
  @compose_manager.run
@@ -65,7 +62,7 @@ class Stack < Thor
65
62
 
66
63
  def clean
67
64
  begin
68
- check_all_preconditions
65
+ Preconditions::check_all_preconditions
69
66
  rescue Exception => e
70
67
  say_status 'error', e.message, :red
71
68
  exit 1
@@ -75,17 +72,20 @@ class Stack < Thor
75
72
  config_path = options[:config]
76
73
  else
77
74
  begin
78
- config_path = find_config
75
+ config_path = DockerSyncConfig::project_config_path
79
76
  rescue Exception => e
80
77
  say_status 'error', e.message, :red
81
78
  return
82
79
  end
83
80
  end
84
- @compose_manager = ComposeManager.new
81
+ @sync_manager = Docker_Rsync::SyncManager.new(:config_path => config_path)
82
+ global_options = @sync_manager.global_options
83
+ # shutdown compose first
84
+ @compose_manager = ComposeManager.new(global_options)
85
85
  @compose_manager.clean
86
86
  say_status 'success', 'Finished cleaning up your app stack', :green
87
87
 
88
- @sync_manager = Docker_Rsync::SyncManager.new(:config_path => config_path)
88
+ # now shutdown sync
89
89
  @sync_manager.clean(options[:sync_name])
90
90
  say_status 'success', 'Finished cleanup. Removed stopped, removed sync container and removed there volumes', :green
91
91
  end
@@ -1,11 +1,9 @@
1
- require 'docker_sync/sync_manager'
2
- require 'config'
3
- require 'preconditions'
4
- require 'update_check'
1
+ require 'docker-sync/sync_manager'
2
+ require 'docker-sync/config'
3
+ require 'docker-sync/preconditions'
4
+ require 'docker-sync/update_check'
5
5
 
6
6
  class Sync < Thor
7
- include DockerSyncConfig
8
- include Preconditions
9
7
 
10
8
  class_option :config, :aliases => '-c',:default => nil, :type => :string, :desc => 'Path of the docker_sync config'
11
9
  class_option :sync_name, :aliases => '-n',:type => :string, :desc => 'If given, only this sync configuration will be references/started/synced'
@@ -17,7 +15,7 @@ class Sync < Thor
17
15
  updates.run
18
16
 
19
17
  begin
20
- check_all_preconditions
18
+ Preconditions::check_all_preconditions
21
19
  rescue Exception => e
22
20
  say_status 'error', e.message, :red
23
21
  exit 1
@@ -27,7 +25,7 @@ class Sync < Thor
27
25
  config_path = options[:config]
28
26
  else
29
27
  begin
30
- config_path = find_config
28
+ config_path = DockerSyncConfig::project_config_path
31
29
  rescue Exception => e
32
30
  say_status 'error', e.message, :red
33
31
  return
@@ -41,7 +39,7 @@ class Sync < Thor
41
39
  desc 'sync', 'sync - do not start a watcher'
42
40
  def sync
43
41
  begin
44
- check_all_preconditions
42
+ Preconditions::check_all_preconditions
45
43
  rescue Exception => e
46
44
  say_status 'error', e.message, :red
47
45
  exit 1
@@ -51,7 +49,7 @@ class Sync < Thor
51
49
  config_path = options[:config]
52
50
  else
53
51
  begin
54
- config_path = find_config
52
+ config_path = DockerSyncConfig::project_config_path
55
53
  rescue Exception => e
56
54
  say_status 'error', e.message, :red
57
55
  return
@@ -64,7 +62,7 @@ class Sync < Thor
64
62
  desc 'clean', 'Stop and clean up all sync endpoints'
65
63
  def clean
66
64
  begin
67
- check_all_preconditions
65
+ Preconditions::check_all_preconditions
68
66
  rescue Exception => e
69
67
  say_status 'error', e.message, :red
70
68
  exit 1
@@ -74,7 +72,7 @@ class Sync < Thor
74
72
  config_path = options[:config]
75
73
  else
76
74
  begin
77
- config_path = find_config
75
+ config_path = DockerSyncConfig::project_config_path
78
76
  rescue Exception => e
79
77
  say_status 'error', e.message, :red
80
78
  return
@@ -89,7 +87,7 @@ class Sync < Thor
89
87
  method_option :verbose, :default => false, :type => :boolean, :desc => 'Verbose output'
90
88
  def list
91
89
  begin
92
- check_all_preconditions
90
+ Preconditions::check_all_preconditions
93
91
  rescue Exception => e
94
92
  say_status 'error', e.message, :red
95
93
  exit 1
@@ -99,7 +97,7 @@ class Sync < Thor
99
97
  config_path = options[:config]
100
98
  else
101
99
  begin
102
- config_path = find_config
100
+ config_path = DockerSyncConfig::project_config_path
103
101
  rescue Exception => e
104
102
  say_status 'error', e.message, :red
105
103
  return
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.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-10 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -50,6 +50,20 @@ dependencies:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: 0.2.0
53
+ - !ruby/object:Gem::Dependency
54
+ name: docker-compose
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '='
58
+ - !ruby/object:Gem::Version
59
+ version: 0.8.3
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '='
65
+ - !ruby/object:Gem::Version
66
+ version: 0.8.3
53
67
  description: Sync your code live to docker-containers without losing any performance
54
68
  on OSX
55
69
  email: eugen.mayer@kontextwork.de
@@ -63,16 +77,17 @@ files:
63
77
  - VERSION
64
78
  - bin/docker-sync
65
79
  - bin/docker-sync-stack
66
- - lib/compose.rb
67
- - lib/config.rb
68
- - lib/docker_sync/sync_manager.rb
69
- - lib/docker_sync/sync_process.rb
70
- - lib/docker_sync/sync_strategy/rsync.rb
71
- - lib/docker_sync/sync_strategy/unison.rb
72
- - lib/docker_sync/watch_strategy/fswatch.rb
73
- - lib/execution.rb
74
- - lib/preconditions.rb
75
- - lib/update_check.rb
80
+ - lib/docker-sync/compose.rb
81
+ - lib/docker-sync/config.rb
82
+ - lib/docker-sync/execution.rb
83
+ - lib/docker-sync/preconditions.rb
84
+ - lib/docker-sync/sync_manager.rb
85
+ - lib/docker-sync/sync_process.rb
86
+ - lib/docker-sync/sync_strategy/rsync.rb
87
+ - lib/docker-sync/sync_strategy/unison.rb
88
+ - lib/docker-sync/update_check.rb
89
+ - lib/docker-sync/watch_strategy/dummy.rb
90
+ - lib/docker-sync/watch_strategy/fswatch.rb
76
91
  - tasks/stack/stack.thor
77
92
  - tasks/sync/sync.thor
78
93
  homepage: https://github.com/EugenMayer/docker_sync
@@ -1,23 +0,0 @@
1
- require 'docker/compose'
2
-
3
- class ComposeManager
4
- include Thor::Shell
5
- @compose_session
6
- def initialize
7
- @compose_session = Docker::Compose::Session.new(dir:'./')
8
- end
9
-
10
- def run
11
- say_status 'ok','starting compose',:white
12
- @compose_session.up
13
- say_status 'success','started compose',:green
14
- end
15
-
16
- def stop
17
- @compose_session.stop
18
- end
19
-
20
- def clean
21
- @compose_session.down
22
- end
23
- end