class DockerSync::SyncStrategy::Native
Public Class Methods
new(sync_name, options)
click to toggle source
# File lib/docker-sync/sync_strategy/native.rb, line 11 def initialize(sync_name, options) @sync_name = sync_name @options = options begin Dependencies::Docker.ensure! rescue StandardError => e say_status 'error', "#{@sync_name} has been configured to sync with native docker volume, but docker is not found", :red say_status 'error', e.message, :red exit 1 end end
Public Instance Methods
clean()
click to toggle source
# File lib/docker-sync/sync_strategy/native.rb, line 40 def clean delete_volume end
get_volume_name()
click to toggle source
# File lib/docker-sync/sync_strategy/native.rb, line 32 def get_volume_name @sync_name end
run()
click to toggle source
# File lib/docker-sync/sync_strategy/native.rb, line 24 def run create_volume end
start_container()
click to toggle source
# File lib/docker-sync/sync_strategy/native.rb, line 36 def start_container # noop end
stop()
click to toggle source
# File lib/docker-sync/sync_strategy/native.rb, line 44 def stop # noop end
sync()
click to toggle source
# File lib/docker-sync/sync_strategy/native.rb, line 28 def sync # noop end
Private Instance Methods
create_volume()
click to toggle source
# File lib/docker-sync/sync_strategy/native.rb, line 50 def create_volume run_cmd "docker volume create --opt type=none --opt device=\"#{@options['src']}\" --opt o=bind "\ "--name #{get_volume_name}" say_status 'success', "Docker volume for #{get_volume_name} created", :white end
delete_volume()
click to toggle source
# File lib/docker-sync/sync_strategy/native.rb, line 57 def delete_volume run_cmd "docker volume ls -q | grep #{get_volume_name} && docker volume rm #{get_volume_name}" end
run_cmd(cmd)
click to toggle source
# File lib/docker-sync/sync_strategy/native.rb, line 61 def run_cmd(cmd) say_status 'command', cmd, :white if @options['verbose'] `#{cmd}` end