Remove to_proto from config and update unset value constant

This commit is contained in:
Chris Roberts 2022-06-13 17:05:43 -07:00
parent 55512ca0ef
commit 4128441aac

View File

@ -12,7 +12,8 @@ module Vagrant
# was never set, and a value that is nil (explicitly). Best practice
# is to initialize all variables to this value, then the {#merge}
# method below will "just work" in many cases.
UNSET_VALUE = Object.new
UNSET_VALUE = :__UNSET__VALUE__
if Vagrant.server_mode?
GENERAL_CONFIG_CLS = Hashicorp::Vagrant::Sdk::Vagrantfile::GeneralConfig
@ -162,24 +163,6 @@ module Vagrant
config.delete_if{|k,_| k.start_with?("_") }
config
end
def to_proto(type)
mapper = VagrantPlugins::CommandServe::Mappers.new
protoize = self.instance_variables_hash
protoize.map do |k,v|
# Get embedded default struct
if v.is_a?(Vagrant.plugin("2", :config))
hashed_config = v.instance_variables_hash
hashed_config.delete_if{|k,v| k.start_with?("_") }
protoize[k] = hashed_config
end
end
protoize = clean_up_config_object(protoize)
config_struct = mapper.map(protoize, to: Hashicorp::Vagrant::Sdk::Args::Hash)
config_any = Google::Protobuf::Any.pack(config_struct)
GENERAL_CONFIG_CLS.new(type: type, config: config_any)
end
end
end
end