Get box metadata client from box

This commit is contained in:
sophia 2022-03-22 10:45:19 -05:00 committed by Paul Hinze
parent 428c3b02fd
commit 1f5d66fd76
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 15 additions and 1 deletions

View File

@ -61,7 +61,7 @@ module VagrantPlugins
# @return [Hash] metadata (from metadata_url)
def metadata
res = client.metadata(Empty.new)
mapper.map(res.metadata, to: Hash)
mapper.map(res.metadata, to: Client::BoxMetadata)
end
# @return [String] metadata url

View File

@ -34,6 +34,20 @@ module VagrantPlugins
)
end
end
class BoxMetadataFromProto < Mapper
def initialize
inputs = [].tap do |i|
i << Input.new(type: SDK::Args::BoxMetadata)
i << Input.new(type: Broker)
end
super(inputs: inputs, output: Client::BoxMetadata, func: method(:converter))
end
def converter(proto, broker)
Client::BoxMetadata.load(proto, broker: broker)
end
end
end
end
end