Allow communicator to use plugin config
This commit is contained in:
parent
ad74f18719
commit
3c360722df
@ -38,28 +38,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
||||
optional :box, :string, 2
|
||||
repeated :provisioners, :message, 3, "hashicorp.vagrant.Provisioner"
|
||||
end
|
||||
add_message "hashicorp.vagrant.CommunicatorSSH" do
|
||||
optional :guest_port, :string, 1
|
||||
optional :shell, :string, 2
|
||||
end
|
||||
add_message "hashicorp.vagrant.CommunicatorWinrm" do
|
||||
optional :username, :string, 1
|
||||
optional :password, :string, 2
|
||||
optional :host, :string, 3
|
||||
optional :port, :string, 4
|
||||
optional :guest_port, :string, 5
|
||||
end
|
||||
add_message "hashicorp.vagrant.CommunicatorWinssh" do
|
||||
optional :guest_port, :string, 1
|
||||
optional :shell, :string, 2
|
||||
optional :upload_directory, :string, 3
|
||||
end
|
||||
add_message "hashicorp.vagrant.Communicator" do
|
||||
oneof :type do
|
||||
optional :ssh, :message, 1, "hashicorp.vagrant.CommunicatorSSH"
|
||||
optional :winrm, :message, 2, "hashicorp.vagrant.CommunicatorWinrm"
|
||||
optional :winssh, :message, 3, "hashicorp.vagrant.CommunicatorWinssh"
|
||||
end
|
||||
optional :name, :string, 1
|
||||
optional :config, :message, 2, "google.protobuf.Any"
|
||||
end
|
||||
add_message "hashicorp.vagrant.Vagrantfile" do
|
||||
optional :path, :string, 1
|
||||
@ -80,9 +61,6 @@ module Hashicorp
|
||||
ParseVagrantfileResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.ParseVagrantfileResponse").msgclass
|
||||
Provisioner = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Provisioner").msgclass
|
||||
MachineConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.MachineConfig").msgclass
|
||||
CommunicatorSSH = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.CommunicatorSSH").msgclass
|
||||
CommunicatorWinrm = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.CommunicatorWinrm").msgclass
|
||||
CommunicatorWinssh = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.CommunicatorWinssh").msgclass
|
||||
Communicator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Communicator").msgclass
|
||||
Vagrantfile = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Vagrantfile").msgclass
|
||||
end
|
||||
|
||||
@ -7,6 +7,7 @@ require "pathname"
|
||||
|
||||
require 'vagrant/proto/gen/ruby-server_pb'
|
||||
require 'vagrant/proto/gen/ruby-server_services_pb'
|
||||
require 'google/protobuf/well_known_types'
|
||||
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
@ -53,20 +54,21 @@ module VagrantPlugins
|
||||
config_loader.set(:root, vagrantfile_path)
|
||||
v = Vagrant::Vagrantfile.new(config_loader, [:root])
|
||||
|
||||
ssh_config = v.config.ssh
|
||||
winrm_config = v.config.winrm
|
||||
sc = v.config.ssh
|
||||
ssh_config = Hashicorp::Vagrant::Sdk::SSHInfo.new(
|
||||
port: sc.guest_port.to_s, ssh_command: sc.shell
|
||||
)
|
||||
wc = v.config.winrm
|
||||
winrm_config = Hashicorp::Vagrant::Sdk::WinrmInfo.new(
|
||||
username: wc.username, password: wc.password, host: wc.host,
|
||||
port: wc.port, guest_port: wc.guest_port)
|
||||
|
||||
communicators = [
|
||||
Hashicorp::Vagrant::Communicator.new(
|
||||
ssh: Hashicorp::Vagrant::CommunicatorSSH.new(
|
||||
guest_port: ssh_config.guest_port.to_s, shell: ssh_config.shell
|
||||
),
|
||||
name: "ssh", config: Google::Protobuf::Any.pack(ssh_config)
|
||||
),
|
||||
Hashicorp::Vagrant::Communicator.new(
|
||||
winrm: Hashicorp::Vagrant::CommunicatorWinrm.new(
|
||||
username: winrm_config.username, password: winrm_config.password,
|
||||
host: winrm_config.host, port: winrm_config.port.to_s,
|
||||
guest_port: winrm_config.guest_port.to_s
|
||||
)
|
||||
name: "winrm", config: Google::Protobuf::Any.pack(winrm_config)
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user