Get box update info

This commit is contained in:
sophia 2022-03-07 17:51:04 -06:00 committed by Paul Hinze
parent 495902a5df
commit 35c094f570
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 17 additions and 1 deletions

View File

@ -46,7 +46,7 @@ module Vagrant
end
def has_update?(version=nil, **opts)
client.has_update(version)
client.update_info(version)
end
def automatic_update_check_allowed?

View File

@ -21,6 +21,22 @@ module VagrantPlugins
res.has_update
end
# @param [String] version
# @return [Array] if there is an update available return an array of
# [metadata (hash), version (string), provider (string)],
# otherwise, return nil
def update_info(version)
res = client.update_info(SDK::Box::HasUpdateRequest.new(
version: version
))
if res.has_update
meta = mapper.map(res.metadata, to: Hash)
return [meta, res.new_version, res.new_provider]
else
nil
end
end
# @param [Sdk::Args::TargetIndex] index
# @return [Bool] is in use
def in_use(index)