mirror of
https://github.com/hashicorp/vagrant.git
synced 2026-06-09 00:32:06 -04:00
Merge pull request #13373 from tomjn/patch-2
Check if the docker config is nil, fixes #13371
This commit is contained in:
commit
df5d8f11f5
2 changed files with 47 additions and 3 deletions
|
|
@ -348,9 +348,9 @@ module VagrantPlugins
|
|||
|
||||
network_info = inspect_network(all_networks)
|
||||
network_info.each do |network|
|
||||
config = Array(network["IPAM"]["Config"])
|
||||
if (config.size > 0 &&
|
||||
config.first["Subnet"] == subnet_string)
|
||||
config = Array(network.dig("IPAM", "Config"))
|
||||
next if config.empty? || !config.first.is_a?(Hash)
|
||||
if (config.first["Subnet"] == subnet_string)
|
||||
@logger.debug("Found existing network #{network["Name"]} already configured with #{subnet_string}")
|
||||
return network["Name"]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -729,6 +729,50 @@ describe VagrantPlugins::DockerProvider::Driver do
|
|||
expect { subject.network_defined?(subnet_string) }.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context "when IPAM information is missing" do
|
||||
let(:docker_network_struct) do
|
||||
[
|
||||
{
|
||||
"Name": "bridge",
|
||||
"Id": "ae74f6cc18bbcde86326937797070b814cc71bfc4a6d8e3e8cf3b2cc5c7f4a7d",
|
||||
"Created": "2019-03-20T14:10:06.313314662-07:00",
|
||||
"Scope": "local",
|
||||
"Driver": "bridge",
|
||||
"EnableIPv6": false,
|
||||
"Internal": false,
|
||||
"Attachable": false,
|
||||
"Ingress": false,
|
||||
"ConfigFrom": {
|
||||
"Network": ""
|
||||
},
|
||||
"ConfigOnly": false,
|
||||
"Containers": {
|
||||
"a1ee9b12bcea8268495b1f43e8d1285df1925b7174a695075f6140adb9415d87": {
|
||||
"Name": "vagrant-sandbox_docker-1_1553116237",
|
||||
"EndpointID": "fc1b0ed6e4f700cf88bb26a98a0722655191542e90df3e3492461f4d1f3c0cae",
|
||||
"MacAddress": "02:42:ac:11:00:02",
|
||||
"IPv4Address": "172.17.0.2/16",
|
||||
"IPv6Address": ""
|
||||
},
|
||||
"Options": {
|
||||
"com.docker.network.bridge.default_bridge": "true",
|
||||
"com.docker.network.bridge.enable_icc": "true",
|
||||
"com.docker.network.bridge.enable_ip_masquerade": "true",
|
||||
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
|
||||
"com.docker.network.bridge.name": "docker0",
|
||||
"com.docker.network.driver.mtu": "1500"
|
||||
},
|
||||
"Labels": {}
|
||||
},
|
||||
}
|
||||
].to_json
|
||||
end
|
||||
|
||||
it "should not raise an error" do
|
||||
expect { subject.network_defined?(subnet_string) }.not_to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#network_containing_address' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue