docker-sync 0.4.6 → 0.5.0.pre.beta1
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/bin/console +6 -0
- data/lib/docker-sync.rb +2 -1
- data/lib/docker-sync/config/project_config.rb +13 -12
- data/lib/docker-sync/dependencies.rb +39 -0
- data/lib/docker-sync/dependencies/docker.rb +23 -0
- data/lib/docker-sync/dependencies/docker_driver.rb +20 -0
- data/lib/docker-sync/dependencies/fswatch.rb +14 -0
- data/lib/docker-sync/dependencies/package_manager.rb +24 -0
- data/lib/docker-sync/dependencies/package_managers/apt.rb +24 -0
- data/lib/docker-sync/dependencies/package_managers/base.rb +47 -0
- data/lib/docker-sync/dependencies/package_managers/brew.rb +24 -0
- data/lib/docker-sync/dependencies/package_managers/none.rb +23 -0
- data/lib/docker-sync/dependencies/package_managers/pkg.rb +24 -0
- data/lib/docker-sync/dependencies/package_managers/yum.rb +24 -0
- data/lib/docker-sync/dependencies/rsync.rb +14 -0
- data/lib/docker-sync/dependencies/unison.rb +15 -0
- data/lib/docker-sync/dependencies/unox.rb +40 -0
- data/lib/docker-sync/environment.rb +19 -0
- data/lib/docker-sync/execution.rb +11 -35
- data/lib/docker-sync/sync_manager.rb +10 -3
- data/lib/docker-sync/sync_process.rb +16 -18
- data/lib/docker-sync/sync_strategy/native.rb +3 -4
- data/lib/docker-sync/sync_strategy/native_osx.rb +11 -11
- data/lib/docker-sync/sync_strategy/rsync.rb +15 -7
- data/lib/docker-sync/sync_strategy/unison.rb +13 -12
- data/lib/docker-sync/update_check.rb +5 -0
- data/lib/docker-sync/upgrade_check.rb +2 -1
- data/lib/docker-sync/watch_strategy/dummy.rb +1 -1
- data/lib/docker-sync/watch_strategy/fswatch.rb +4 -5
- data/lib/docker-sync/watch_strategy/remotelogs.rb +3 -3
- data/lib/docker-sync/watch_strategy/unison.rb +2 -2
- data/tasks/daemon/daemon.thor +0 -1
- data/tasks/stack/stack.thor +8 -9
- data/tasks/sync/sync.thor +16 -19
- metadata +21 -9
- data/lib/docker-sync/preconditions/preconditions_linux.rb +0 -51
- data/lib/docker-sync/preconditions/preconditions_osx.rb +0 -174
- data/lib/docker-sync/preconditions/strategy.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a4d176110d1f999724b01ecd8613697ba9b1ae5
|
4
|
+
data.tar.gz: 656df917cfe74ca3c12aeb1c829bb62a6367f99b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 716e8408005a3cb1ebdfffeb11b7f4f87812b944b3f5746bc88b4764e54fd0094a85e3955078c39df62e8615e744f3ec396089472481c16243e8db4ed726978e
|
7
|
+
data.tar.gz: cbaa7c0fa625d650d7b51fd0b9cd5ce2901e361e9f8753098bf17538bf5b1111596696dc17bf504a459ae02142243164f8eafbb9c868f5972193ff8026623ed4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0-beta1
|
data/bin/console
CHANGED
@@ -6,5 +6,11 @@ require 'docker-sync'
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
|
+
# ActiveSupport stuff for readability (specially `1.second` and stuff like that)
|
10
|
+
require 'active_support'
|
11
|
+
require 'active_support/core_ext/numeric/time'
|
12
|
+
require 'active_support/core_ext/integer/time'
|
13
|
+
require 'active_support/core_ext/object/blank'
|
14
|
+
|
9
15
|
require 'pry'
|
10
16
|
Pry.start
|
data/lib/docker-sync.rb
CHANGED
@@ -2,7 +2,7 @@ require 'singleton'
|
|
2
2
|
require 'docker-sync/config/config_locator'
|
3
3
|
require 'docker-sync/config/config_serializer'
|
4
4
|
require 'forwardable'
|
5
|
-
|
5
|
+
|
6
6
|
module DockerSync
|
7
7
|
class ProjectConfig
|
8
8
|
extend Forwardable
|
@@ -47,17 +47,24 @@ module DockerSync
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def unison_required?
|
50
|
-
|
50
|
+
# noinspection RubyUnusedLocalVariable
|
51
|
+
config['syncs'].any? { |sync_config|
|
51
52
|
sync_config['sync_strategy'] == 'unison' || sync_config['watch_strategy'] == 'unison'
|
52
53
|
}
|
53
54
|
end
|
54
55
|
|
55
56
|
def rsync_required?
|
56
|
-
|
57
|
+
# noinspection RubyUnusedLocalVariable
|
58
|
+
config['syncs'].any? { |sync_config|
|
57
59
|
sync_config['sync_strategy'] == 'rsync'
|
58
60
|
}
|
59
61
|
end
|
60
62
|
|
63
|
+
def fswatch_required?
|
64
|
+
config['syncs'].any? { |sync_config|
|
65
|
+
sync_config['watch_strategy'] == 'fswatch'
|
66
|
+
}
|
67
|
+
end
|
61
68
|
|
62
69
|
private
|
63
70
|
|
@@ -134,15 +141,9 @@ module DockerSync
|
|
134
141
|
end
|
135
142
|
|
136
143
|
def default_sync_strategy
|
137
|
-
if
|
138
|
-
|
139
|
-
|
140
|
-
if DockerSync::Preconditions::Strategy.instance.is_driver_docker_for_mac?
|
141
|
-
return 'native_osx'
|
142
|
-
else
|
143
|
-
return 'unison'
|
144
|
-
end
|
145
|
-
end
|
144
|
+
return 'native' if Environment.linux?
|
145
|
+
return 'native_osx' if Environment.mac? && Dependencies::Docker::Driver.docker_for_mac?
|
146
|
+
return 'unison' if Environment.mac?
|
146
147
|
end
|
147
148
|
|
148
149
|
def default_watch_strategy(sync_config)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'thor/shell'
|
3
|
+
|
4
|
+
Dir[
|
5
|
+
File.join(__dir__, 'dependencies', 'package_managers', 'base.rb'),
|
6
|
+
File.join(__dir__, 'dependencies', '**', '*.rb')
|
7
|
+
].each { |f| require f }
|
8
|
+
|
9
|
+
module DockerSync
|
10
|
+
module Dependencies
|
11
|
+
UNSUPPORTED_OPERATING_SYSTEM = 'Unsupported operating system. Are you sure you need DockerSync?'.freeze
|
12
|
+
|
13
|
+
def self.ensure_all!(config)
|
14
|
+
return if ENV['DOCKER_SYNC_SKIP_DEPENDENCIES_CHECK']
|
15
|
+
return ensure_all_for_mac!(config) if Environment.mac?
|
16
|
+
return ensure_all_for_linux!(config) if Environment.linux?
|
17
|
+
return ensure_all_for_freebsd!(config) if Environment.freebsd?
|
18
|
+
raise(UNSUPPORTED_OPERATING_SYSTEM)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.ensure_all_for_mac!(config)
|
22
|
+
PackageManager.ensure!
|
23
|
+
Docker.ensure!
|
24
|
+
Unison.ensure! if config.unison_required?
|
25
|
+
Rsync.ensure! if config.rsync_required?
|
26
|
+
Fswatch.ensure! if config.fswatch_required?
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.ensure_all_for_linux!(_config)
|
30
|
+
Docker.ensure!
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.ensure_all_for_freebsd!(config)
|
34
|
+
Docker.ensure!
|
35
|
+
Unison.ensure! if config.unison_required?
|
36
|
+
Rsync.ensure! if config.rsync_required?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module DockerSync
|
2
|
+
module Dependencies
|
3
|
+
module Docker
|
4
|
+
DOCKER_NOT_AVAILABLE = 'Could not find Docker. Please install it (see https://docs.docker.com/compose/install/) and try again.'.freeze
|
5
|
+
DOCKER_NOT_RUNNING = 'No docker daemon seems to be running. Did you start docker-engine / docker-for-mac / docker-machine?'.freeze
|
6
|
+
|
7
|
+
def self.available?
|
8
|
+
return @available if defined? @available
|
9
|
+
@available = find_executable0('docker')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.running?
|
13
|
+
return @running if defined? @running
|
14
|
+
@running = system('docker ps &> /dev/null')
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.ensure!
|
18
|
+
raise(DOCKER_NOT_AVAILABLE) unless available?
|
19
|
+
raise(DOCKER_NOT_RUNNING) unless running?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DockerSync
|
2
|
+
module Dependencies
|
3
|
+
module Docker
|
4
|
+
module Driver
|
5
|
+
def self.docker_for_mac?
|
6
|
+
return false unless Environment.mac?
|
7
|
+
return @docker_for_mac if defined? @docker_for_mac
|
8
|
+
@docker_for_mac = system('ps x | grep MacOS | grep -q com.docker.osx.hyperkit.linux')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.docker_toolbox?
|
12
|
+
return false unless Environment.mac? || Environment.freebsd?
|
13
|
+
return false unless find_executable0('docker-machine')
|
14
|
+
return @docker_toolbox if defined? @docker_toolbox
|
15
|
+
@docker_toolbox = system('docker info | grep -q "Operating System: Boot2Docker"')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DockerSync
|
2
|
+
module Dependencies
|
3
|
+
module Fswatch
|
4
|
+
def self.available?
|
5
|
+
return @available if defined? @available
|
6
|
+
@available = find_executable0('fswatch')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.ensure!
|
10
|
+
PackageManager.install_package('fswatch') unless available?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module DockerSync
|
4
|
+
module Dependencies
|
5
|
+
module PackageManager
|
6
|
+
class << self
|
7
|
+
extend Forwardable
|
8
|
+
def_delegators :package_manager, :available?, :ensure!, :install_package
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.package_manager
|
12
|
+
return @package_manager if defined? @package_manager
|
13
|
+
supported_package_managers.each do |package_manager|
|
14
|
+
return @package_manager = package_manager if package_manager.available?
|
15
|
+
end
|
16
|
+
@package_manager = PackageManager::None
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.supported_package_managers
|
20
|
+
ObjectSpace.each_object(::Class).select { |klass| klass < self::Base && klass != self::None }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DockerSync
|
2
|
+
module Dependencies
|
3
|
+
module PackageManager
|
4
|
+
class Apt < Base
|
5
|
+
APT_NOT_AVAILABLE = 'APT is not installed. Please install it and try again.'.freeze
|
6
|
+
|
7
|
+
def self.available?
|
8
|
+
return @available if defined? @available
|
9
|
+
@available = find_executable0('apt-get')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.ensure!
|
13
|
+
raise(APT_NOT_AVAILABLE) unless available?
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def install_cmd
|
19
|
+
"apt-get install -y #{package}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module DockerSync
|
4
|
+
module Dependencies
|
5
|
+
module PackageManager
|
6
|
+
class Base
|
7
|
+
DID_NOT_INSTALL_PACKAGE = 'Did not install required package. Please install it manually and try again.'.freeze
|
8
|
+
FAILED_TO_INSTALL_PACKAGE = 'Failed to install required package. Please install it manually and try again.'.freeze
|
9
|
+
|
10
|
+
extend Forwardable
|
11
|
+
def_delegators :"Thor::Shell::Color.new", :say_status, :yes?
|
12
|
+
|
13
|
+
attr_reader :package
|
14
|
+
|
15
|
+
def self.install_package(*args)
|
16
|
+
ensure!
|
17
|
+
new(*args).send(:install_package)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(package)
|
21
|
+
@package = package
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def install_package
|
27
|
+
say_status 'warning', "Could not find #{package}. Trying to install it now.", :yellow
|
28
|
+
ask_user_confirmation
|
29
|
+
say_status 'command', install_cmd, :white
|
30
|
+
raise(FAILED_TO_INSTALL_PACKAGE) unless perform_installation
|
31
|
+
end
|
32
|
+
|
33
|
+
def ask_user_confirmation
|
34
|
+
raise(DID_NOT_INSTALL_PACKAGE) unless yes?("Install #{package} for you? [y/N]")
|
35
|
+
end
|
36
|
+
|
37
|
+
def perform_installation
|
38
|
+
defined?(Bundler) ? Bundler.clean_system(install_cmd) : system(install_cmd)
|
39
|
+
end
|
40
|
+
|
41
|
+
def install_cmd
|
42
|
+
raise NotImplementedError
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DockerSync
|
2
|
+
module Dependencies
|
3
|
+
module PackageManager
|
4
|
+
class Brew < Base
|
5
|
+
BREW_NOT_AVAILABLE = 'Brew is not installed. Please install it (see https://brew.sh) and try again.'.freeze
|
6
|
+
|
7
|
+
def self.available?
|
8
|
+
return @available if defined? @available
|
9
|
+
@available = find_executable0('brew')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.ensure!
|
13
|
+
raise(BREW_NOT_AVAILABLE) unless available?
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def install_cmd
|
19
|
+
"brew install #{package}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module DockerSync
|
2
|
+
module Dependencies
|
3
|
+
module PackageManager
|
4
|
+
class None < Base
|
5
|
+
NO_PACKAGE_MANAGER_AVAILABLE = 'No package manager was found. Please either install one of those supported (brew, apt, rpm) or install all dependencies manually.'.freeze
|
6
|
+
|
7
|
+
def self.available?
|
8
|
+
@available ||= true
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.ensure!
|
12
|
+
# noop
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def install_cmd
|
18
|
+
raise(NO_PACKAGE_MANAGER_AVAILABLE)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DockerSync
|
2
|
+
module Dependencies
|
3
|
+
module PackageManager
|
4
|
+
class Pkg < Base
|
5
|
+
PKG_NOT_AVAILABLE = 'PKG is not installed. Please install it and try again.'.freeze
|
6
|
+
|
7
|
+
def self.available?
|
8
|
+
return @available if defined? @available
|
9
|
+
@available = find_executable0('pkg')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.ensure!
|
13
|
+
raise(PKG_NOT_AVAILABLE) unless available?
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def install_cmd
|
19
|
+
"pkg install -y #{package}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DockerSync
|
2
|
+
module Dependencies
|
3
|
+
module PackageManager
|
4
|
+
class Yum < Base
|
5
|
+
YUM_NOT_AVAILABLE = 'Yum is not installed. Please install it and try again.'.freeze
|
6
|
+
|
7
|
+
def self.available?
|
8
|
+
return @available if defined? @available
|
9
|
+
@available = find_executable0('yum')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.ensure!
|
13
|
+
raise(YUM_NOT_AVAILABLE) unless available?
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def install_cmd
|
19
|
+
"yum install -y #{package}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DockerSync
|
2
|
+
module Dependencies
|
3
|
+
module Rsync
|
4
|
+
def self.available?
|
5
|
+
return @available if defined? @available
|
6
|
+
@available = find_executable0('rsync')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.ensure!
|
10
|
+
PackageManager.install_package('rsync') unless available?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DockerSync
|
2
|
+
module Dependencies
|
3
|
+
module Unison
|
4
|
+
def self.available?
|
5
|
+
return @available if defined? @available
|
6
|
+
@available = find_executable0('unison')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.ensure!
|
10
|
+
PackageManager.install_package('unison') unless available?
|
11
|
+
Unox.ensure!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module DockerSync
|
4
|
+
module Dependencies
|
5
|
+
module Unox
|
6
|
+
LEGACY_UNOX_WARNING = 'You installed unison-fsmonitor (unox) the old legacy way (i.e. not using brew). We need to fix that.'.freeze
|
7
|
+
FAILED_TO_REMOVE_LEGACY_UNOX = 'Failed to remove legacy unison-fsmonitor (unox). Please delete /usr/local/bin/unison-fsmonitor manually and try again.'.freeze
|
8
|
+
|
9
|
+
class << self
|
10
|
+
extend Forwardable
|
11
|
+
def_delegators :"Thor::Shell::Color.new", :say_status, :yes?
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.available?
|
15
|
+
return @available if defined? @available
|
16
|
+
cmd = 'brew list unox &> /dev/null'
|
17
|
+
@available = defined?(Bundler) ? Bundler.clean_system(cmd) : system(cmd)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.ensure!
|
21
|
+
return if available?
|
22
|
+
cleanup_non_brew_version!
|
23
|
+
PackageManager.install_package('eugenmayer/dockersync/unox')
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.cleanup_non_brew_version!
|
27
|
+
return unless non_brew_version_installed?
|
28
|
+
uninstall_cmd = 'sudo rm -f /usr/local/bin/unison-fsmonitor'
|
29
|
+
say_status 'warning', LEGACY_UNOX_WARNING, :yellow
|
30
|
+
raise(FAILED_TO_REMOVE_LEGACY_UNOX) unless yes?('Uninstall legacy unison-fsmonitor (unox)? (y/N)')
|
31
|
+
say_status 'command', uninstall_cmd, :white
|
32
|
+
system(uninstall_cmd)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.non_brew_version_installed?
|
36
|
+
!available? && File.exist?('/usr/local/bin/unison-fsmonitor')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|