Add mappers for core plugin manager

This commit is contained in:
sophia 2022-03-24 11:07:45 -05:00 committed by Paul Hinze
parent b3003e8cb6
commit 05244e67c1
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 37 additions and 1 deletions

View File

@ -3,7 +3,7 @@ module VagrantPlugins
class Client
class CorePluginManager < Client
def get_plugin(type)
resp = client.get_plugins(
resp = client.get_plugin(
SDK::CorePluginManager::GetPluginRequest.new(
type: type
)

View File

@ -17,6 +17,42 @@ module VagrantPlugins
Client::PluginManager.load(proto, broker: broker)
end
end
class CorePluginManagerFromProto < Mapper
def initialize
super(
inputs: [
Input.new(type: SDK::Args::CorePluginManager),
Input.new(type: Broker),
],
output: Client::CorePluginManager,
func: method(:converter)
)
end
def converter(proto, broker)
Client::CorePluginManager.load(proto, broker: broker)
end
end
class CorePluginManagerProtoFromSpec < Mapper
def initialize
super(
inputs: [Input.new(type: SDK::FuncSpec::Value) { |arg|
arg.type == "hashicorp.vagrant.sdk.Args.CorePluginManager" &&
!arg&.value&.value.nil?
}
],
output: SDK::Args::CorePluginManager,
func: method(:converter),
)
end
def converter(fv)
SDK::Args::CorePluginManager.decode(fv.value.value)
end
end
end
end
end