diff options
Diffstat (limited to 'test/security/sslendpoints/ports/ports.go')
-rw-r--r-- | test/security/sslendpoints/ports/ports.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/security/sslendpoints/ports/ports.go b/test/security/sslendpoints/ports/ports.go new file mode 100644 index 000000000..823e07531 --- /dev/null +++ b/test/security/sslendpoints/ports/ports.go @@ -0,0 +1,18 @@ +package ports + +import ( + v1 "k8s.io/api/core/v1" +) + +// FilterNodePorts extracts NodePorts from ServiceList. +func FilterNodePorts(services *v1.ServiceList) (map[uint16]string, bool) { + nodeports := make(map[uint16]string) + for _, service := range services.Items { + for _, port := range service.Spec.Ports { + if port.NodePort != 0 { + nodeports[uint16(port.NodePort)] = service.ObjectMeta.Name + } + } + } + return nodeports, len(nodeports) > 0 +} |