// Creates a new line for the result table
Creates a new line for the result table
// Creates a new line for the result table
func createTableLine(policy netv1.NetworkPolicy, ports []netv1.NetworkPolicyPort,
	policyType string) TableLine {
	var line TableLine
	line.networkPolicyName = policy.Name
	line.namespace = policy.Namespace
	line.policyType = policyType
	if policy.Spec.PodSelector.Size() == 0 {
		line.pods = Wildcard
	} else {
		line.pods = sortAndJoinLabels(policy.Spec.PodSelector.MatchLabels)
	}
	if len(ports) == 0 {
		line.policyPort = Wildcard
	} else {
		for _, port := range ports {
			line.policyPort = addCharIfNotEmpty(line.policyPort, "\n") +
				fmt.Sprintf("%s:%s", getProtocol(*port.Protocol), port.Port)
		}
	}
	return line
}
func createTableLine ( policy netv1 . NetworkPolicy , ports [ ] netv1 . NetworkPolicyPort , policyType string ) TableLine { var line TableLine line . networkPolicyName = policy . Name line . namespace = policy . Namespace line . policyType = policyType if policy . Spec . PodSelector . Size ( ) == 0 { line . pods = Wildcard } else { line . pods = sortAndJoinLabels ( policy . Spec . PodSelector . MatchLabels ) } if len ( ports ) == 0 { line . policyPort = Wildcard } else { for _ , port := range ports { line . policyPort = addCharIfNotEmpty ( line . policyPort , " \n " ) + fmt . Sprintf ( " " , getProtocol ( * port . Protocol ) , port . Port ) } } return line }
Creates a new line for the result table
Creates a new line for the result table