This ensures that rsync can be installed on an Alpine Linux machine where the apk cache may not be current. Display a warning if the vagrant-alpine plugin is installed, since Alpine guest support has been merged into Vagrant core.
This commit is contained in:
parent
55994824a4
commit
2fa44f5b8f
|
@ -8,7 +8,7 @@ module VagrantPlugins
|
|||
|
||||
def self.rsync_install(machine)
|
||||
machine.communicate.tap do |comm|
|
||||
comm.sudo('apk add rsync')
|
||||
comm.sudo('apk add --update-cache rsync')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,6 +45,22 @@ module VagrantPlugins
|
|||
require_relative 'cap/smb'
|
||||
Cap::SMB
|
||||
end
|
||||
|
||||
def self.check_community_plugin
|
||||
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
|
||||
if plugins.keys.include?("vagrant-alpine")
|
||||
$stderr.puts <<-EOF
|
||||
WARNING: Vagrant has detected the `vagrant-alpine` plugin. This plugin's
|
||||
functionality has been merged into the main Vagrant project and should be
|
||||
considered deprecated. To uninstall the plugin, run the command shown below:
|
||||
|
||||
vagrant plugin uninstall vagrant-alpine
|
||||
|
||||
EOF
|
||||
end
|
||||
end
|
||||
|
||||
self.check_community_plugin
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,9 +16,9 @@ describe 'VagrantPlugins::GuestAlpine::Cap::RSync' do
|
|||
VagrantPlugins::GuestAlpine::Plugin.components.guest_capabilities[:alpine].get(:rsync_install)
|
||||
end
|
||||
|
||||
it 'should install rsync' do
|
||||
it 'should install rsync with --update-cache flag' do
|
||||
# communicator.should_receive(:sudo).with('apk add rsync')
|
||||
expect(communicator).to receive(:sudo).with('apk add rsync')
|
||||
expect(communicator).to receive(:sudo).with('apk add --update-cache rsync')
|
||||
allow_message_expectations_on_nil
|
||||
described_class.rsync_install(machine)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
require File.expand_path("../../../../base", __FILE__)
|
||||
|
||||
|
||||
describe VagrantPlugins::GuestAlpine::Plugin do
|
||||
let(:manager) { double("manager") }
|
||||
|
||||
before do
|
||||
allow(Vagrant::Plugin::Manager).to receive(:instance).and_return(manager)
|
||||
end
|
||||
|
||||
context "when vagrant-alpine plugin is not installed" do
|
||||
before do
|
||||
allow(manager).to receive(:installed_plugins).and_return({})
|
||||
end
|
||||
|
||||
it "should not display a warning" do
|
||||
expect($stderr).to_not receive(:puts)
|
||||
VagrantPlugins::GuestAlpine::Plugin.check_community_plugin
|
||||
end
|
||||
end
|
||||
|
||||
context "when vagrant-alpine plugin is installed" do
|
||||
before do
|
||||
allow(manager).to receive(:installed_plugins).and_return({ "vagrant-alpine" => {} })
|
||||
end
|
||||
|
||||
it "should display a warning" do
|
||||
expect($stderr).to receive(:puts).with(/vagrant plugin uninstall vagrant-alpine/)
|
||||
VagrantPlugins::GuestAlpine::Plugin.check_community_plugin
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue