From f722b156613bc2e8220e5916ea56fa618439d3cc Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 11 Aug 2021 15:05:32 -0400 Subject: [PATCH] Remove references to SDK from remote machine index --- lib/vagrant/machine_index/remote.rb | 15 ++-------- lib/vagrant/plugin/v2/command.rb | 2 ++ .../commands/serve/client/machine_index.rb | 29 ++++++++++++------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/vagrant/machine_index/remote.rb b/lib/vagrant/machine_index/remote.rb index 21e8d955a..15b64523a 100644 --- a/lib/vagrant/machine_index/remote.rb +++ b/lib/vagrant/machine_index/remote.rb @@ -25,10 +25,7 @@ module Vagrant # @return [Boolean] true if delete is successful def delete(uuid) @machines.delete(uuid) - ref = Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier.new( - id: uuid - ) - @client.delete(ref) + @client.delete(uuid) end # Accesses a machine by UUID @@ -36,10 +33,7 @@ module Vagrant # @param [String] uuid for the machine to access. # @return [MachineIndex::Entry] def get(uuid) - ref = Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier.new( - id: uuid - ) - @client.get(ref) + @client.get(uuid) end # Tests if the index has the given UUID. @@ -47,10 +41,7 @@ module Vagrant # @param [String] uuid # @return [Boolean] def include?(uuid) - ref = Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier.new( - id: uuid - ) - @client.include?(ref) + @client.include?(uuid) end def release(entry) diff --git a/lib/vagrant/plugin/v2/command.rb b/lib/vagrant/plugin/v2/command.rb index d766396c3..194cd82ef 100644 --- a/lib/vagrant/plugin/v2/command.rb +++ b/lib/vagrant/plugin/v2/command.rb @@ -137,6 +137,8 @@ module Vagrant # Vagrantfiles often have constants, so people would otherwise # constantly (heh) get "already initialized constant" warnings. begin + # TODO: Remove reference to client here. This won't work + # running legacy vagrant directly. env = entry.vagrant_env( @env.home_path, ui_class: @env.ui_class, client: @env.client) rescue Vagrant::Errors::EnvironmentNonExistentCWD diff --git a/plugins/commands/serve/client/machine_index.rb b/plugins/commands/serve/client/machine_index.rb index e4b4ea541..020546066 100644 --- a/plugins/commands/serve/client/machine_index.rb +++ b/plugins/commands/serve/client/machine_index.rb @@ -20,26 +20,35 @@ module VagrantPlugins @broker = broker end - # @param [Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier] + # @param [string] # @return [Boolean] true if delete is successful - def delete(target) - @logger.debug("deleting machine #{target} from index") - @client.delete(target) + def delete(uuid) + @logger.debug("deleting machine with id #{uuid} from index") + ref = Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier.new( + id: uuid + ) + @client.delete(ref) true end - # @param [Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier] + # @param [string] # @return [MachineIndex::Entry] - def get(ref) - @logger.debug("getting machine with ref #{ref} from index") + def get(uuid) + @logger.debug("getting machine with id #{uuid} from index") + ref = Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier.new( + id: uuid + ) resp = @client.get(ref) return machine_to_entry(resp) end - # @param [Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier] + # @param [string] # @return [Boolean] - def include?(ref) - @logger.debug("checking for machine with ref #{ref} in index") + def include?(uuid) + @logger.debug("checking for machine with id #{uuid} in index") + ref = Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier.new( + id: uuid + ) @client.includes(ref).exists end