virt-controller, template: stop initializing the ContainerPort slice
@@ -169,7 +169,7 @@ func securityContext(userId int64, privileged bool, requiredCapabilities *k8sv1.
}
func getPortsFromVMI(vmi *v1.VirtualMachineInstance) []k8sv1.ContainerPort {
- ports := make([]k8sv1.ContainerPort, 0)
+ var ports []k8sv1.ContainerPort
for _, iface := range vmi.Spec.Domain.Devices.Interfaces {
if iface.Ports != nil {
@@ -183,9 +183,5 @@ func getPortsFromVMI(vmi *v1.VirtualMachineInstance) []k8sv1.ContainerPort {
}
}
- if len(ports) == 0 {
- return nil
- }
-
return ports
}
