core: MachineIndex preserves the local data path for an env
This commit is contained in:
parent
7da9ad0fa6
commit
646f0fa907
|
@ -332,6 +332,11 @@ module Vagrant
|
||||||
# @return [String]
|
# @return [String]
|
||||||
attr_reader :id
|
attr_reader :id
|
||||||
|
|
||||||
|
# The path for the "local data" directory for the environment.
|
||||||
|
#
|
||||||
|
# @return [Pathname]
|
||||||
|
attr_accessor :local_data_path
|
||||||
|
|
||||||
# The name of the machine.
|
# The name of the machine.
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
|
@ -377,14 +382,19 @@ module Vagrant
|
||||||
return if !raw
|
return if !raw
|
||||||
|
|
||||||
@id = id
|
@id = id
|
||||||
|
@local_data_path = raw["local_data_path"]
|
||||||
@name = raw["name"]
|
@name = raw["name"]
|
||||||
@provider = raw["provider"]
|
@provider = raw["provider"]
|
||||||
@state = raw["state"]
|
@state = raw["state"]
|
||||||
@vagrantfile_name = raw["vagrantfile_name"]
|
@vagrantfile_name = raw["vagrantfile_name"]
|
||||||
@vagrantfile_path = Pathname.new(raw["vagrantfile_path"])
|
@vagrantfile_path = raw["vagrantfile_path"]
|
||||||
# TODO(mitchellh): parse into a proper datetime
|
# TODO(mitchellh): parse into a proper datetime
|
||||||
@updated_at = raw["updated_at"]
|
@updated_at = raw["updated_at"]
|
||||||
@extra_data = raw["extra_data"] || {}
|
@extra_data = raw["extra_data"] || {}
|
||||||
|
|
||||||
|
# Convert to proper types
|
||||||
|
@local_data_path = Pathname.new(@local_data_path) if @local_data_path
|
||||||
|
@vagrantfile_path = Pathname.new(@vagrantfile_path) if @vagrantfile_path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a {Vagrant::Environment} for this entry.
|
# Creates a {Vagrant::Environment} for this entry.
|
||||||
|
@ -395,6 +405,7 @@ module Vagrant
|
||||||
Environment.new({
|
Environment.new({
|
||||||
cwd: @vagrantfile_path,
|
cwd: @vagrantfile_path,
|
||||||
home_path: home_path,
|
home_path: home_path,
|
||||||
|
local_data_path: @local_data_path,
|
||||||
vagrantfile_name: @vagrantfile_name,
|
vagrantfile_name: @vagrantfile_name,
|
||||||
}.merge(opts))
|
}.merge(opts))
|
||||||
end
|
end
|
||||||
|
@ -403,11 +414,12 @@ module Vagrant
|
||||||
# Converts to the structure used by the JSON
|
# Converts to the structure used by the JSON
|
||||||
def to_json_struct
|
def to_json_struct
|
||||||
{
|
{
|
||||||
|
"local_data_path" => @local_data_path.to_s,
|
||||||
"name" => @name,
|
"name" => @name,
|
||||||
"provider" => @provider,
|
"provider" => @provider,
|
||||||
"state" => @state,
|
"state" => @state,
|
||||||
"vagrantfile_name" => @vagrantfile_name,
|
"vagrantfile_name" => @vagrantfile_name,
|
||||||
"vagrantfile_path" => @vagrantfile_path,
|
"vagrantfile_path" => @vagrantfile_path.to_s,
|
||||||
"updated_at" => @updated_at,
|
"updated_at" => @updated_at,
|
||||||
"extra_data" => @extra_data,
|
"extra_data" => @extra_data,
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ describe Vagrant::MachineIndex do
|
||||||
"bar" => {
|
"bar" => {
|
||||||
"name" => "default",
|
"name" => "default",
|
||||||
"provider" => "vmware",
|
"provider" => "vmware",
|
||||||
|
"local_data_path" => "/foo",
|
||||||
"vagrantfile_path" => "/foo/bar/baz",
|
"vagrantfile_path" => "/foo/bar/baz",
|
||||||
"state" => "running",
|
"state" => "running",
|
||||||
"updated_at" => "foo",
|
"updated_at" => "foo",
|
||||||
|
@ -108,6 +109,7 @@ describe Vagrant::MachineIndex do
|
||||||
expect(result.id).to eq("bar")
|
expect(result.id).to eq("bar")
|
||||||
expect(result.name).to eq("default")
|
expect(result.name).to eq("default")
|
||||||
expect(result.provider).to eq("vmware")
|
expect(result.provider).to eq("vmware")
|
||||||
|
expect(result.local_data_path).to eq(Pathname.new("/foo"))
|
||||||
expect(result.vagrantfile_path).to eq(Pathname.new("/foo/bar/baz"))
|
expect(result.vagrantfile_path).to eq(Pathname.new("/foo/bar/baz"))
|
||||||
expect(result.state).to eq("running")
|
expect(result.state).to eq("running")
|
||||||
expect(result.updated_at).to eq("foo")
|
expect(result.updated_at).to eq("foo")
|
||||||
|
|
Loading…
Reference in New Issue