Merge pull request #309 from hashicorp/fix-docker-by-supporting-machine-with-no-box
Make Docker provider work again post config refactor
This commit is contained in:
commit
27d08534cf
2
go.mod
2
go.mod
@ -46,7 +46,7 @@ require (
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/hashicorp/hcl/v2 v2.11.1
|
||||
github.com/hashicorp/nomad/api v0.0.0-20200814140818-42de70466a9d
|
||||
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220707165921-a8b5817e43f5
|
||||
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220708181224-89ddccf33610
|
||||
github.com/hashicorp/yamux v0.0.0-20200609203250-aecfd211c9ce // indirect
|
||||
github.com/imdario/mergo v0.3.11
|
||||
github.com/improbable-eng/grpc-web v0.13.0
|
||||
|
||||
6
go.sum
6
go.sum
@ -361,10 +361,8 @@ github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJb
|
||||
github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
|
||||
github.com/hashicorp/nomad/api v0.0.0-20200814140818-42de70466a9d h1:afuZ/KNbxwUgjEzq2NXO2bRKZgsIJQgFxgIRGETF0/A=
|
||||
github.com/hashicorp/nomad/api v0.0.0-20200814140818-42de70466a9d/go.mod h1:DCi2k47yuUDzf2qWAK8E1RVmWgz/lc0jZQeEnICTxmY=
|
||||
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220701171937-4cbbeaea0e70 h1:Pqn/v5JGkP20UNz8gyq/bm4OBdhitEqxs5y/+CmaeFY=
|
||||
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220701171937-4cbbeaea0e70/go.mod h1:bdjvCJEaP+EFbg9vKdYuT5WuCfnFbemm0FEn4KtZaqU=
|
||||
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220707165921-a8b5817e43f5 h1:ik4/++5TqY2LCBrSAiJHMKV+FGb1ZhnrdD00kyZRejg=
|
||||
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220707165921-a8b5817e43f5/go.mod h1:bdjvCJEaP+EFbg9vKdYuT5WuCfnFbemm0FEn4KtZaqU=
|
||||
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220708181224-89ddccf33610 h1:LGVRHdDzPPrHzQ7YjwOXO09+x71WmWjABLwMBepbu6A=
|
||||
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220708181224-89ddccf33610/go.mod h1:bdjvCJEaP+EFbg9vKdYuT5WuCfnFbemm0FEn4KtZaqU=
|
||||
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
||||
github.com/hashicorp/yamux v0.0.0-20200609203250-aecfd211c9ce h1:7UnVY3T/ZnHUrfviiAgIUjg2PXxsQfs5bphsG8F7Keo=
|
||||
github.com/hashicorp/yamux v0.0.0-20200609203250-aecfd211c9ce/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
||||
|
||||
@ -173,6 +173,9 @@ func (b *Box) loadMetadata() (metadata *BoxMetadata, err error) {
|
||||
}
|
||||
|
||||
func (b *Box) matches(box core.Box) (bool, error) {
|
||||
if box == nil {
|
||||
return false, nil
|
||||
}
|
||||
name, err := box.Name()
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@ -71,6 +71,10 @@ func (m *Machine) Box() (b core.Box, err error) {
|
||||
|
||||
return nil, err
|
||||
}
|
||||
if boxName == nil {
|
||||
m.logger.Debug("vagrantfile has no box, so returning nil")
|
||||
return nil, nil
|
||||
}
|
||||
provider, err := m.ProviderName()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -64,6 +64,10 @@ module Vagrant
|
||||
# @return [Box]
|
||||
def box
|
||||
box = client.box
|
||||
# The box itself can be nil in some cases (e.g. for the docker provider)
|
||||
if box.nil?
|
||||
return nil
|
||||
end
|
||||
# If the version isn't set, then the box has not being tracked
|
||||
# by Vagrant.
|
||||
if box.version.empty?
|
||||
@ -295,10 +299,13 @@ module Vagrant
|
||||
synced_folder_clients = client.synced_folders
|
||||
synced_folder_clients.each do |f|
|
||||
next if f[:folder][:disabled]
|
||||
# :type will be populated when the Vagrantfile has an explicit type
|
||||
# coming from the user and empty otherwise. when it is empty we can
|
||||
# infer the type from the name of the plugin we get back
|
||||
if f[:folder][:type].to_s != ""
|
||||
impl = f[:folder][:type].to_sym
|
||||
else
|
||||
impl = :virtualbox
|
||||
impl = f[:plugin].name.to_sym
|
||||
end
|
||||
sf = Vagrant::Plugin::Remote::SyncedFolder.new(client: f[:plugin])
|
||||
folder_opts = scoped_hash_override(f[:folder], impl)
|
||||
|
||||
@ -697,6 +697,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Target.Machine" do
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Target.Machine.BoxResponse" do
|
||||
proto3_optional :box, :message, 1, "hashicorp.vagrant.sdk.Args.Box"
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Target.Machine.SetIDRequest" do
|
||||
optional :id, :string, 1
|
||||
end
|
||||
@ -1185,6 +1188,7 @@ module Hashicorp
|
||||
Target::GetUUIDResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Target.GetUUIDResponse").msgclass
|
||||
Target::SetUUIDRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Target.SetUUIDRequest").msgclass
|
||||
Target::Machine = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Target.Machine").msgclass
|
||||
Target::Machine::BoxResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Target.Machine.BoxResponse").msgclass
|
||||
Target::Machine::SetIDRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Target.Machine.SetIDRequest").msgclass
|
||||
Target::Machine::GetIDResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Target.Machine.GetIDResponse").msgclass
|
||||
Target::Machine::SetStateRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Target.Machine.SetStateRequest").msgclass
|
||||
|
||||
@ -441,7 +441,7 @@ module Hashicorp
|
||||
rpc :GetID, ::Google::Protobuf::Empty, ::Hashicorp::Vagrant::Sdk::Target::Machine::GetIDResponse
|
||||
rpc :SetState, ::Hashicorp::Vagrant::Sdk::Target::Machine::SetStateRequest, ::Google::Protobuf::Empty
|
||||
rpc :GetState, ::Google::Protobuf::Empty, ::Hashicorp::Vagrant::Sdk::Args::Target::Machine::State
|
||||
rpc :Box, ::Google::Protobuf::Empty, ::Hashicorp::Vagrant::Sdk::Args::Box
|
||||
rpc :Box, ::Google::Protobuf::Empty, ::Hashicorp::Vagrant::Sdk::Target::Machine::BoxResponse
|
||||
rpc :Guest, ::Google::Protobuf::Empty, ::Hashicorp::Vagrant::Sdk::Args::Guest
|
||||
rpc :ConnectionInfo, ::Google::Protobuf::Empty, ::Hashicorp::Vagrant::Sdk::Args::Hash
|
||||
rpc :UID, ::Google::Protobuf::Empty, ::Hashicorp::Vagrant::Sdk::Target::Machine::UIDResponse
|
||||
|
||||
@ -14,7 +14,10 @@ module VagrantPlugins
|
||||
# @return [Vagrant::Box] box backing machine
|
||||
def box
|
||||
b = client.box(Empty.new)
|
||||
box_client = Box.load(b, broker: broker)
|
||||
if b == nil || b.box == nil
|
||||
return nil
|
||||
end
|
||||
box_client = Box.load(b.box, broker: broker)
|
||||
box = Vagrant::Box.new(
|
||||
box_client.name,
|
||||
box_client.provider.to_sym,
|
||||
|
||||
@ -114,7 +114,7 @@ describe Vagrant::Machine::Remote do
|
||||
it "returns a hash with synced_folders returned from the client" do
|
||||
synced_folder_clients = [
|
||||
{
|
||||
plugin: double("plugin"),
|
||||
plugin: double("plugin", name: "syncedfoldertype"),
|
||||
folder: {
|
||||
disabled: false,
|
||||
source: "/some/source",
|
||||
@ -127,7 +127,7 @@ describe Vagrant::Machine::Remote do
|
||||
output = subject.synced_folders
|
||||
|
||||
expect(output).to match(
|
||||
virtualbox: a_hash_including(
|
||||
syncedfoldertype: a_hash_including(
|
||||
"/some/destination" => a_hash_including(
|
||||
disabled: false,
|
||||
guestpath: "/some/destination",
|
||||
@ -141,7 +141,7 @@ describe Vagrant::Machine::Remote do
|
||||
it "works with multiple folders for a given impl" do
|
||||
synced_folder_clients = [
|
||||
{
|
||||
plugin: double("pluginone"),
|
||||
plugin: double("pluginone", name: "syncedfoldertype"),
|
||||
folder: {
|
||||
disabled: false,
|
||||
source: "/one",
|
||||
@ -149,7 +149,7 @@ describe Vagrant::Machine::Remote do
|
||||
}
|
||||
},
|
||||
{
|
||||
plugin: double("plugintwo"),
|
||||
plugin: double("plugintwo", name: "syncedfoldertype"),
|
||||
folder: {
|
||||
disabled: false,
|
||||
source: "/two",
|
||||
@ -162,7 +162,7 @@ describe Vagrant::Machine::Remote do
|
||||
output = subject.synced_folders
|
||||
|
||||
expect(output).to match(
|
||||
virtualbox: a_hash_including(
|
||||
syncedfoldertype: a_hash_including(
|
||||
"/first" => a_hash_including(
|
||||
disabled: false,
|
||||
guestpath: "/first",
|
||||
@ -190,7 +190,7 @@ describe Vagrant::Machine::Remote do
|
||||
}
|
||||
},
|
||||
{
|
||||
plugin: double("plugintwo"),
|
||||
plugin: double("plugintwo", name: "syncedfoldertype"),
|
||||
folder: {
|
||||
disabled: false,
|
||||
source: "/yesme",
|
||||
@ -203,7 +203,7 @@ describe Vagrant::Machine::Remote do
|
||||
output = subject.synced_folders
|
||||
|
||||
expect(output).to match(
|
||||
virtualbox: a_hash_including(
|
||||
syncedfoldertype: a_hash_including(
|
||||
"/pickme" => a_hash_including(
|
||||
disabled: false,
|
||||
guestpath: "/pickme",
|
||||
@ -212,7 +212,7 @@ describe Vagrant::Machine::Remote do
|
||||
),
|
||||
)
|
||||
)
|
||||
expect(output[:virtualbox]).to_not have_key("/noway")
|
||||
expect(output[:syncedfoldertype]).to_not have_key("/noway")
|
||||
end
|
||||
|
||||
it "honors explicitly set folder type" do
|
||||
@ -227,7 +227,7 @@ describe Vagrant::Machine::Remote do
|
||||
}
|
||||
},
|
||||
{
|
||||
plugin: double("plugintwo"),
|
||||
plugin: double("plugintwo", name: "syncedfoldertype"),
|
||||
folder: {
|
||||
disabled: false,
|
||||
source: "/imnormal",
|
||||
@ -240,7 +240,7 @@ describe Vagrant::Machine::Remote do
|
||||
output = subject.synced_folders
|
||||
|
||||
expect(output).to match(
|
||||
virtualbox: a_hash_including(
|
||||
syncedfoldertype: a_hash_including(
|
||||
"/iamdefaulttype" => a_hash_including(
|
||||
disabled: false,
|
||||
guestpath: "/iamdefaulttype",
|
||||
@ -257,7 +257,6 @@ describe Vagrant::Machine::Remote do
|
||||
),
|
||||
)
|
||||
)
|
||||
expect(output[:virtualbox]).to_not have_key("/noway")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user