Hard code less

This commit is contained in:
sophia 2021-01-21 16:26:15 -06:00 committed by Paul Hinze
parent 5fc0b22efd
commit cadcbe82f7
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 17 additions and 21 deletions

View File

@ -76,12 +76,16 @@ module Vagrant
machine: machine_ref
)
resp = @client.datadir(req)
Pathname.new(resp.datadir.data_dir)
resp.datadir
end
# TODO
def get_local_data_path(id)
nil
machine_ref = Hashicorp::Vagrant::Sdk::Ref::Machine.new(resource_id: id)
req = Hashicorp::Vagrant::Sdk::Machine::LocalDataPathRequest.new(
machine: machine_ref
)
resp = @client.localdatapath(req)
resp.path
end
def get_provider(id)
@ -93,7 +97,6 @@ module Vagrant
resp
end
def get_vagrantfile_name(id)
machine_ref = Hashicorp::Vagrant::Sdk::Ref::Machine.new(resource_id: id)
req = Hashicorp::Vagrant::Sdk::Machine::VagrantfileNameRequest.new(
@ -130,13 +133,16 @@ module Vagrant
provider_plugin = Vagrant.plugin("2").manager.providers[:virtualbox]
provider_cls = provider_plugin[0]
provider_options = provider_plugin[1]
datadir = get_data_dir(id)
vagrantfile_name = get_vagrantfile_name(id)
vagrantfile_path = get_vagrantfile_path(id)
env = Vagrant::Environment.new(
cwd: "/Users/sophia/project/vagrant-agogo",
home_path: "/Users/sophia/.vagrant.d",
cwd: vagrantfile_path, # TODO: this is probably not ideal
home_path: datadir.root_dir,
ui_class: Vagrant::UI::RemoteUI,
ui_opts: [ui_client],
vagrantfile_name: "Vagrantfile",
vagrantfile_name: vagrantfile_name,
)
Machine.new(
@ -276,17 +282,15 @@ module Vagrant
#
# @return [Pathname]
def data_dir
@client.get_data_dir(@machine_id)
dd = @client.get_data_dir(@machine_id)
Pathname.new(dd.data_dir)
end
# The Vagrantfile that this machine is attached to.
#
# @return [Vagrantfile]
def vagrantfile
path = @client.get_vagrantfile_path(@machine_id)
filename = @client.get_vagrantfile_name(@machine_id)
vagrantfile_path = path.join(filename)
# TODO: get vagrantfile parsed and return Vagrantfile
# TODO
end
# This calls an action on the provider. The provider may or may not

View File

@ -38,13 +38,6 @@ module VagrantPlugins
LOG.debug("Coming up")
machine = machine_arg_to_machine(req)
machine.ui.warn("hello from vagrant")
# ba = Vagrant::BatchAction.new
# LOG.debug("registering action")
# ba.action(machine, :up)
# LOG.debug("running action")
# ba.run
# LOG.debug("up?!")
Hashicorp::Vagrant::Sdk::Provider::ActionResp.new(success: true)
end
@ -61,7 +54,6 @@ module VagrantPlugins
machine = mclient.get_machine(machine_arg.resource_id, ui_client)
LOG.debug("got machine: ")
LOG.debug(machine.name)
LOG.debug("using provider: " + machine.provider_name)
machine
end