fix network card fixer (#9311)
This commit is contained in:
parent
40947c2bf6
commit
3ad2f86cc2
|
@ -46,13 +46,22 @@ func (FixerVSphereNetworkDisk) Fix(input map[string]interface{}) (map[string]int
|
|||
hasNetwork = true
|
||||
}
|
||||
|
||||
// legacy syntax from when VSphere was 3rd party
|
||||
networkCardRaw, ok := builder["networkCard"]
|
||||
if ok {
|
||||
nic["networkCard"] = networkCardRaw
|
||||
nic["network_card"] = networkCardRaw
|
||||
delete(builder, "networkCard")
|
||||
hasNetwork = true
|
||||
}
|
||||
|
||||
// underscored syntax used when Packer merged vSphere
|
||||
networkCardRaw, ok = builder["network_card"]
|
||||
if ok {
|
||||
nic["network_card"] = networkCardRaw
|
||||
delete(builder, "network_card")
|
||||
hasNetwork = true
|
||||
}
|
||||
|
||||
if hasNetwork {
|
||||
networkAdapters = append(networkAdapters, nic)
|
||||
adaptersRaw, ok := builder["network_adapters"]
|
||||
|
|
|
@ -27,7 +27,30 @@ func TestFixerVSphereNetwork_Fix(t *testing.T) {
|
|||
"network_adapters": []interface{}{
|
||||
map[string]interface{}{
|
||||
"network": "",
|
||||
"networkCard": "vmxnet3",
|
||||
"network_card": "vmxnet3",
|
||||
},
|
||||
},
|
||||
"storage": []interface{}{
|
||||
map[string]interface{}{
|
||||
"disk_size": 5000,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Input: map[string]interface{}{
|
||||
"type": "vsphere-iso",
|
||||
"network": "",
|
||||
"network_card": "vmxnet3",
|
||||
"disk_size": 5000,
|
||||
},
|
||||
|
||||
Expected: map[string]interface{}{
|
||||
"type": "vsphere-iso",
|
||||
"network_adapters": []interface{}{
|
||||
map[string]interface{}{
|
||||
"network": "",
|
||||
"network_card": "vmxnet3",
|
||||
},
|
||||
},
|
||||
"storage": []interface{}{
|
||||
|
@ -52,7 +75,7 @@ func TestFixerVSphereNetwork_Fix(t *testing.T) {
|
|||
"network_adapters": []interface{}{
|
||||
map[string]interface{}{
|
||||
"network": "myNetwork",
|
||||
"networkCard": "vmxnet3",
|
||||
"network_card": "vmxnet3",
|
||||
},
|
||||
},
|
||||
"storage": []interface{}{
|
||||
|
@ -75,7 +98,7 @@ func TestFixerVSphereNetwork_Fix(t *testing.T) {
|
|||
"network_adapters": []interface{}{
|
||||
map[string]interface{}{
|
||||
"network": "net1",
|
||||
"networkCard": "vmxnet3",
|
||||
"network_card": "vmxnet3",
|
||||
},
|
||||
},
|
||||
"storage": []interface{}{
|
||||
|
@ -92,11 +115,11 @@ func TestFixerVSphereNetwork_Fix(t *testing.T) {
|
|||
"network_adapters": []interface{}{
|
||||
map[string]interface{}{
|
||||
"network": "myNetwork",
|
||||
"networkCard": "vmxnet3",
|
||||
"network_card": "vmxnet3",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"network": "net1",
|
||||
"networkCard": "vmxnet3",
|
||||
"network_card": "vmxnet3",
|
||||
},
|
||||
},
|
||||
"storage": []interface{}{
|
||||
|
|
Loading…
Reference in New Issue