Collect config defined by community plugins
This commit is contained in:
parent
6421b671e1
commit
85271c616e
5
Vagrantfile
vendored
5
Vagrantfile
vendored
@ -4,6 +4,9 @@
|
||||
# Ruby, run unit tests, etc.
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vbguest.auto_update = false
|
||||
config.vbguest.installer_options = { foo: 1, bar: 2 }
|
||||
|
||||
config.vagrant.host = "linux"
|
||||
|
||||
config.ssh.connect_timeout = 30
|
||||
@ -24,6 +27,8 @@ Vagrant.configure("2") do |config|
|
||||
|
||||
["a", "b"].each do |m|
|
||||
config.vm.define m do |c|
|
||||
c.vbguest.installer_options[:zort] = 3
|
||||
|
||||
c.vagrant.host = "ubuntu"
|
||||
c.winrm.host = "computer-#{m}"
|
||||
c.vm.hostname = "computer-#{m}"
|
||||
|
||||
@ -634,6 +634,10 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
||||
repeated :plugins, :string, 2
|
||||
repeated :sensitive, :string, 3
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Vagrantfile.GeneralConfig" do
|
||||
optional :type, :string, 1
|
||||
optional :config, :message, 2, "google.protobuf.Any"
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Vagrantfile.MachineConfig" do
|
||||
optional :name, :string, 1
|
||||
optional :config_vm, :message, 2, "hashicorp.vagrant.sdk.Vagrantfile.ConfigVM"
|
||||
@ -641,6 +645,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
||||
optional :config_winrm, :message, 4, "hashicorp.vagrant.sdk.Vagrantfile.ConfigWinRM"
|
||||
optional :config_winssh, :message, 5, "hashicorp.vagrant.sdk.Vagrantfile.ConfigWinssh"
|
||||
optional :config_vagrant, :message, 6, "hashicorp.vagrant.sdk.Vagrantfile.ConfigVagrant"
|
||||
repeated :plugin_configs, :message, 7, "hashicorp.vagrant.sdk.Vagrantfile.GeneralConfig"
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Vagrantfile.Provisioner" do
|
||||
optional :name, :string, 1
|
||||
@ -837,6 +842,7 @@ module Hashicorp
|
||||
Vagrantfile::ConfigWinRM = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Vagrantfile.ConfigWinRM").msgclass
|
||||
Vagrantfile::ConfigWinssh = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Vagrantfile.ConfigWinssh").msgclass
|
||||
Vagrantfile::ConfigVagrant = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Vagrantfile.ConfigVagrant").msgclass
|
||||
Vagrantfile::GeneralConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Vagrantfile.GeneralConfig").msgclass
|
||||
Vagrantfile::MachineConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Vagrantfile.MachineConfig").msgclass
|
||||
Vagrantfile::Provisioner = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Vagrantfile.Provisioner").msgclass
|
||||
Vagrantfile::Provider = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Vagrantfile.Provider").msgclass
|
||||
|
||||
@ -17,6 +17,7 @@ module VagrantPlugins
|
||||
PROVISION_PROTO_CLS = Hashicorp::Vagrant::Sdk::Vagrantfile::Provisioner
|
||||
SYNCED_FOLDER_PROTO_CLS = Hashicorp::Vagrant::Sdk::Vagrantfile::SyncedFolder
|
||||
NETWORK_PROTO_CLS = Hashicorp::Vagrant::Sdk::Vagrantfile::Network
|
||||
GENERAL_CONFIG_CLS = Hashicorp::Vagrant::Sdk::Vagrantfile::GeneralConfig
|
||||
|
||||
CONFIG_VM_CLS = Hashicorp::Vagrant::Sdk::Vagrantfile::ConfigVM
|
||||
CONFIG_SSH_CLS = Hashicorp::Vagrant::Sdk::Vagrantfile::ConfigSSH
|
||||
@ -79,6 +80,14 @@ module VagrantPlugins
|
||||
extract_synced_folders(config_vm_proto.synced_folders, vm_config.synced_folders)
|
||||
extract_provider(config_vm_proto.providers, vm_config)
|
||||
|
||||
plugin_configs = []
|
||||
root_config.__internal_state["keys"].each do |name, config|
|
||||
# A builtin plugin
|
||||
# TODO: find a better way to check the module
|
||||
next if config.class.to_s.split("::")[0] == "VagrantPlugins"
|
||||
plugin_configs << extract_plugin_config(name, config)
|
||||
end
|
||||
|
||||
machine_configs << Hashicorp::Vagrant::Sdk::Vagrantfile::MachineConfig.new(
|
||||
name: mach.to_s,
|
||||
config_vm: config_vm_proto,
|
||||
@ -86,7 +95,7 @@ module VagrantPlugins
|
||||
config_ssh: config_ssh_proto,
|
||||
config_winrm: config_winrm_proto,
|
||||
config_winssh: config_winssh_proto,
|
||||
|
||||
plugin_configs: plugin_configs
|
||||
)
|
||||
end
|
||||
|
||||
@ -288,6 +297,14 @@ module VagrantPlugins
|
||||
config_any = Google::Protobuf::Any.pack(config_struct)
|
||||
config_cls.new(config: config_any)
|
||||
end
|
||||
|
||||
def extract_plugin_config(type, config)
|
||||
protoize = config.instance_variables_hash
|
||||
protoize = clean_up_config_object(protoize)
|
||||
config_struct = Google::Protobuf::Struct.from_hash(protoize)
|
||||
config_any = Google::Protobuf::Any.pack(config_struct)
|
||||
GENERAL_CONFIG_CLS.new(type: type, config: config_any)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user