provisioners/file: validate source relative to Vagrantfile path
[GH-5252]
This commit is contained in:
parent
6c2fb24ff4
commit
2fc8d99f6d
|
@ -91,6 +91,7 @@ BUG FIXES:
|
|||
`which` since that doesn't exist on some systems. [GH-5170]
|
||||
- provisioners/chef-zero: support more chef-zero/local mode attributes [GH-5339]
|
||||
- provisioners/docker: use docker.com instead of docker.io [GH-5216]
|
||||
- provisioners/file: validation of source is relative to Vagrantfile [GH-5252]
|
||||
- pushes/atlas: send additional box metadata [GH-5283]
|
||||
- pushes/ftp: improve check for remote directory existence [GH-5549]
|
||||
- synced\_folders/rsync: add `IdentitiesOnly=yes` to the rsync command. [GH-5175]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require "pathname"
|
||||
|
||||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
|
@ -15,10 +17,10 @@ module VagrantPlugins
|
|||
errors << I18n.t("vagrant.provisioners.file.no_dest_file")
|
||||
end
|
||||
if source
|
||||
s = File.expand_path(source)
|
||||
if ! File.exist?(s)
|
||||
s = Pathname.new(source).expand_path(machine.env.root_path)
|
||||
if !s.exist?
|
||||
errors << I18n.t("vagrant.provisioners.file.path_invalid",
|
||||
path: s)
|
||||
path: s.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,13 @@ describe VagrantPlugins::FileUpload::Config do
|
|||
|
||||
subject { described_class.new }
|
||||
|
||||
let(:machine) { double("machine") }
|
||||
let(:env) do
|
||||
iso_env = isolated_environment
|
||||
iso_env.vagrantfile("")
|
||||
iso_env.create_vagrant_env
|
||||
end
|
||||
|
||||
let(:machine) { double("machine", env: env) }
|
||||
|
||||
describe "#validate" do
|
||||
it "returns an error if destination is not specified" do
|
||||
|
@ -33,7 +39,7 @@ describe VagrantPlugins::FileUpload::Config do
|
|||
end
|
||||
|
||||
it "returns an error if source file does not exist" do
|
||||
non_existing_file = "this/does/not/exist"
|
||||
non_existing_file = "/this/does/not/exist"
|
||||
|
||||
subject.source = non_existing_file
|
||||
subject.destination = "/tmp/foo"
|
||||
|
@ -58,7 +64,10 @@ describe VagrantPlugins::FileUpload::Config do
|
|||
end
|
||||
|
||||
it "passes with relative source path" do
|
||||
existing_relative_path = __FILE__
|
||||
path = env.root_path.join("foo")
|
||||
path.open("w+") { |f| f.write("hello") }
|
||||
|
||||
existing_relative_path = "foo"
|
||||
|
||||
subject.source = existing_relative_path
|
||||
subject.destination = "/tmp/foo"
|
||||
|
|
Loading…
Reference in New Issue