Add mappers for host and plugin manager clients
This commit is contained in:
parent
3f7b7ee65a
commit
de18081a35
@ -268,9 +268,11 @@ require Vagrant.source_root.join("plugins/commands/serve/mappers/communicator.rb
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/direct.rb").to_s
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/environment.rb").to_s
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/guest.rb").to_s
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/host.rb").to_s
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/known_types.rb").to_s
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/machine.rb").to_s
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/pathname.rb").to_s
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/plugin_manager.rb").to_s
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/project.rb").to_s
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/state_bag.rb").to_s
|
||||
require Vagrant.source_root.join("plugins/commands/serve/mappers/synced_folder.rb").to_s
|
||||
|
||||
56
plugins/commands/serve/mappers/host.rb
Normal file
56
plugins/commands/serve/mappers/host.rb
Normal file
@ -0,0 +1,56 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class HostProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.Host" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::Host,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::Host.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
# Build a guest client from a FuncSpec value
|
||||
class HostFromSpec < Mapper
|
||||
def initialize
|
||||
inputs = [].tap do |i|
|
||||
i << Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.Host" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
i << Input.new(type: Broker)
|
||||
end
|
||||
super(inputs: inputs, output: Client::Host, func: method(:converter))
|
||||
end
|
||||
|
||||
def converter(proto, broker)
|
||||
Client::Host.load(proto.value.value, broker: broker)
|
||||
end
|
||||
end
|
||||
|
||||
# Build a guest client from a proto instance
|
||||
class HostFromProto < Mapper
|
||||
def initialize
|
||||
inputs = [].tap do |i|
|
||||
i << Input.new(type: SDK::Args::Host)
|
||||
i << Input.new(type: Broker)
|
||||
end
|
||||
super(inputs: inputs, output: Client::Host, func: method(:converter))
|
||||
end
|
||||
|
||||
def converter(proto, broker)
|
||||
Client::Host.load(proto, broker: broker)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
22
plugins/commands/serve/mappers/plugin_manager.rb
Normal file
22
plugins/commands/serve/mappers/plugin_manager.rb
Normal file
@ -0,0 +1,22 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class PluginManagerFromProto < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: SDK::Args::PluginManager),
|
||||
Input.new(type: Broker),
|
||||
],
|
||||
output: Client::PluginManager,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(proto, broker)
|
||||
Client::PluginManager.load(proto, broker: broker)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user